mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
rearranging a few docs and small updates
This commit is contained in:
parent
924befa07e
commit
c7085162d1
@ -15,7 +15,9 @@ group. The name of the entry point needs to match your builder's
|
|||||||
:attr:`~.Builder.name` attribute, which is the name passed to the
|
:attr:`~.Builder.name` attribute, which is the name passed to the
|
||||||
:option:`sphinx-build -b` option. The entry point value should equal the
|
:option:`sphinx-build -b` option. The entry point value should equal the
|
||||||
dotted name of the extension module. Here is an example of how an entry point
|
dotted name of the extension module. Here is an example of how an entry point
|
||||||
for 'mybuilder' can be defined in the extension's ``setup.py``::
|
for 'mybuilder' can be defined in the extension's ``setup.py``
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
# ...
|
# ...
|
@ -11,3 +11,10 @@ wish to use Sphinx with existing extensions, refer to :doc:`/usage/index`.
|
|||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
tutorials/index
|
tutorials/index
|
||||||
|
builders
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:caption: Theming
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
theming
|
||||||
|
@ -231,6 +231,7 @@ function as a callback for :event:`html-page-context`.
|
|||||||
return "Your string is %s" % mystring
|
return "Your string is %s" % mystring
|
||||||
# Add it to the page's context
|
# Add it to the page's context
|
||||||
context['my_func'] = my_func
|
context['my_func'] = my_func
|
||||||
|
|
||||||
# Your extension's setup function
|
# Your extension's setup function
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.connect("html-page-context", setup_my_func)
|
app.connect("html-page-context", setup_my_func)
|
||||||
@ -244,7 +245,7 @@ Now, you will have access to this function in jinja like so:
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
Inject javsacript based on user configuration
|
Inject JavaScript based on user configuration
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
If your extension makes use of JavaScript, it can be useful to allow users
|
If your extension makes use of JavaScript, it can be useful to allow users
|
||||||
@ -257,15 +258,34 @@ configuration.
|
|||||||
|
|
||||||
First, you may append ``_t`` to the end of any static files included with your
|
First, you may append ``_t`` to the end of any static files included with your
|
||||||
extension. This will cause Sphinx to process these files with the templating
|
extension. This will cause Sphinx to process these files with the templating
|
||||||
engine, allowing you to embed variables and control behavior. See
|
engine, allowing you to embed variables and control behavior.
|
||||||
:ref:`theming-static-templates` for more information.
|
|
||||||
|
For example, the following JavaScript structure:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
mymodule/
|
||||||
|
├── _static
|
||||||
|
│ └── myjsfile.js_t
|
||||||
|
└── mymodule.py
|
||||||
|
|
||||||
|
Will result in the following static file placed in your HTML's build output:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
_build/
|
||||||
|
└── html
|
||||||
|
└── _static
|
||||||
|
└── myjsfile.js
|
||||||
|
|
||||||
|
See :ref:`theming-static-templates` for more information.
|
||||||
|
|
||||||
Second, you may use the :meth:`Sphinx.add_js_file` method without pointing it
|
Second, you may use the :meth:`Sphinx.add_js_file` method without pointing it
|
||||||
to a file. Normally, this method is used to insert a new JavaScript file
|
to a file. Normally, this method is used to insert a new JavaScript file
|
||||||
into your site. However, if you do *not* pass a file path, but instead pass
|
into your site. However, if you do *not* pass a file path, but instead pass
|
||||||
a string to the "body" argument, then this text will be inserted as JavaScript
|
a string to the "body" argument, then this text will be inserted as JavaScript
|
||||||
into your site's head. This allows you to insert variables into your project's
|
into your site's head. This allows you to insert variables into your project's
|
||||||
javascript from Python.
|
JavaScript from Python.
|
||||||
|
|
||||||
For example, the following code will read in a user-configured value and then
|
For example, the following code will read in a user-configured value and then
|
||||||
insert this value as a JavaScript variable, which your extension's JavaScript
|
insert this value as a JavaScript variable, which your extension's JavaScript
|
@ -9,7 +9,6 @@ Refer to the following tutorials to get started with extension development.
|
|||||||
:caption: General extension tutorials
|
:caption: General extension tutorials
|
||||||
|
|
||||||
overview
|
overview
|
||||||
builders
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:caption: Directive tutorials
|
:caption: Directive tutorials
|
||||||
@ -18,9 +17,3 @@ Refer to the following tutorials to get started with extension development.
|
|||||||
helloworld
|
helloworld
|
||||||
todo
|
todo
|
||||||
recipe
|
recipe
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:caption: Theming
|
|
||||||
:maxdepth: 1
|
|
||||||
|
|
||||||
theming-dev
|
|
||||||
|
@ -19,7 +19,7 @@ use the :meth:`Sphinx.setup_extension` method. This will
|
|||||||
activate another extension at run-time, ensuring that you have access to its
|
activate another extension at run-time, ensuring that you have access to its
|
||||||
functionality.
|
functionality.
|
||||||
|
|
||||||
For example, the following code activates the "recommonmark" extension:
|
For example, the following code activates the ``recommonmark`` extension:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ Themes
|
|||||||
|
|
||||||
This section provides information about using pre-existing HTML themes. If
|
This section provides information about using pre-existing HTML themes. If
|
||||||
you wish to create your own theme, refer to
|
you wish to create your own theme, refer to
|
||||||
:doc:`/development/tutorials/theming-dev`.
|
:doc:`/development/theming`.
|
||||||
|
|
||||||
Sphinx supports changing the appearance of its HTML output via *themes*. A
|
Sphinx supports changing the appearance of its HTML output via *themes*. A
|
||||||
theme is a collection of HTML templates, stylesheet(s) and other static files.
|
theme is a collection of HTML templates, stylesheet(s) and other static files.
|
||||||
@ -81,7 +81,7 @@ zipfile-based theme::
|
|||||||
html_theme = "dotted"
|
html_theme = "dotted"
|
||||||
|
|
||||||
For more information on the design of themes, including information about
|
For more information on the design of themes, including information about
|
||||||
writing your own themes, refer to :doc:`/development/tutorials/theming-dev`.
|
writing your own themes, refer to :doc:`/development/theming`.
|
||||||
|
|
||||||
.. _builtin-themes:
|
.. _builtin-themes:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user