2017-03-18 03:25:48 -05:00
|
|
|
.. highlight:: console
|
|
|
|
|
2016-12-16 09:52:11 -06:00
|
|
|
Sphinx Developer's Guide
|
|
|
|
========================
|
|
|
|
|
|
|
|
.. topic:: Abstract
|
|
|
|
|
|
|
|
This document describes the development process of Sphinx, a documentation
|
|
|
|
system used by developers to document systems used by other developers to
|
|
|
|
develop other systems that may also be documented using Sphinx.
|
|
|
|
|
2016-12-17 09:10:40 -06:00
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
|
2017-04-18 23:08:36 -05:00
|
|
|
The Sphinx source code is managed using Git and is hosted on GitHub.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
git clone git://github.com/sphinx-doc/sphinx
|
|
|
|
|
|
|
|
.. rubric:: Community
|
|
|
|
|
|
|
|
sphinx-users <sphinx-users@googlegroups.com>
|
|
|
|
Mailing list for user support.
|
|
|
|
|
|
|
|
sphinx-dev <sphinx-dev@googlegroups.com>
|
|
|
|
Mailing list for development related discussions.
|
|
|
|
|
|
|
|
#sphinx-doc on irc.freenode.net
|
|
|
|
IRC channel for development questions and user support.
|
|
|
|
|
|
|
|
|
|
|
|
Bug Reports and Feature Requests
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
If you have encountered a problem with Sphinx or have an idea for a new
|
2017-04-18 23:08:36 -05:00
|
|
|
feature, please submit it to the `issue tracker`_ on GitHub or discuss it
|
2017-10-03 04:00:40 -05:00
|
|
|
on the `sphinx-dev`_ mailing list.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
For bug reports, please include the output produced during the build process
|
2017-10-03 04:00:40 -05:00
|
|
|
and also the log file Sphinx creates after it encounters an unhandled
|
2016-12-16 09:52:11 -06:00
|
|
|
exception. The location of this file should be shown towards the end of the
|
|
|
|
error message.
|
|
|
|
|
|
|
|
Including or providing a link to the source files involved may help us fix the
|
|
|
|
issue. If possible, try to create a minimal project that produces the error
|
|
|
|
and post that instead.
|
|
|
|
|
|
|
|
.. _`issue tracker`: https://github.com/sphinx-doc/sphinx/issues
|
2017-10-03 04:00:40 -05:00
|
|
|
.. _`sphinx-dev`: mailto:sphinx-dev@googlegroups.com
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
|
|
|
|
Contributing to Sphinx
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
The recommended way for new contributors to submit code to Sphinx is to fork
|
2017-04-18 23:08:36 -05:00
|
|
|
the repository on GitHub and then submit a pull request after
|
2016-12-16 09:52:11 -06:00
|
|
|
committing the changes. The pull request will then need to be approved by one
|
|
|
|
of the core developers before it is merged into the main repository.
|
|
|
|
|
|
|
|
#. Check for open issues or open a fresh issue to start a discussion around a
|
|
|
|
feature idea or a bug.
|
|
|
|
#. If you feel uncomfortable or uncertain about an issue or your changes, feel
|
2017-10-03 04:00:40 -05:00
|
|
|
free to email the *sphinx-dev* mailing list.
|
2017-04-18 23:08:36 -05:00
|
|
|
#. Fork `the repository`_ on GitHub to start making your changes to the
|
2020-02-09 05:28:23 -06:00
|
|
|
``master`` branch for next MAJOR version, or ``A.x`` branch for next
|
2019-01-12 07:22:42 -06:00
|
|
|
MINOR version (see `Branch Model`_).
|
2016-12-16 09:52:11 -06:00
|
|
|
#. Write a test which shows that the bug was fixed or that the feature works
|
|
|
|
as expected.
|
|
|
|
#. Send a pull request and bug the maintainer until it gets merged and
|
|
|
|
published. Make sure to add yourself to AUTHORS_ and the change to
|
|
|
|
CHANGES_.
|
|
|
|
|
|
|
|
.. _`the repository`: https://github.com/sphinx-doc/sphinx
|
|
|
|
.. _AUTHORS: https://github.com/sphinx-doc/sphinx/blob/master/AUTHORS
|
|
|
|
.. _CHANGES: https://github.com/sphinx-doc/sphinx/blob/master/CHANGES
|
|
|
|
|
|
|
|
|
|
|
|
Getting Started
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
These are the basic steps needed to start developing on Sphinx.
|
|
|
|
|
2017-04-18 23:08:36 -05:00
|
|
|
#. Create an account on GitHub.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
#. Fork the main Sphinx repository (`sphinx-doc/sphinx
|
2017-04-18 23:08:36 -05:00
|
|
|
<https://github.com/sphinx-doc/sphinx>`_) using the GitHub interface.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
#. Clone the forked repository to your machine. ::
|
|
|
|
|
|
|
|
git clone https://github.com/USERNAME/sphinx
|
|
|
|
cd sphinx
|
|
|
|
|
|
|
|
#. Checkout the appropriate branch.
|
|
|
|
|
2019-01-12 23:50:21 -06:00
|
|
|
Sphinx adopts Semantic Versioning 2.0.0 (refs: https://semver.org/ ).
|
2019-01-12 07:22:42 -06:00
|
|
|
|
|
|
|
For changes that preserves backwards-compatibility of API and features,
|
2020-02-09 05:28:23 -06:00
|
|
|
they should be included in the next MINOR release, use the ``A.x`` branch.
|
2019-01-12 23:50:21 -06:00
|
|
|
::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2020-02-09 05:28:23 -06:00
|
|
|
git checkout A.x
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2019-01-12 07:22:42 -06:00
|
|
|
For incompatible or other substantial changes that should wait until the
|
2019-01-12 23:50:21 -06:00
|
|
|
next MAJOR release, use the ``master`` branch.
|
|
|
|
|
|
|
|
For urgent release, a new PATCH branch must be branched from the newest
|
|
|
|
release tag (see `Branch Model`_ for detail).
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
#. Setup a virtual environment.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
This is not necessary for unit testing, thanks to ``tox``, but it is
|
|
|
|
necessary if you wish to run ``sphinx-build`` locally or run unit tests
|
|
|
|
without the help of ``tox``. ::
|
|
|
|
|
|
|
|
virtualenv ~/.venv
|
|
|
|
. ~/.venv/bin/activate
|
2016-12-16 09:52:11 -06:00
|
|
|
pip install -e .
|
|
|
|
|
|
|
|
#. Create a new working branch. Choose any name you like. ::
|
|
|
|
|
|
|
|
git checkout -b feature-xyz
|
|
|
|
|
|
|
|
#. Hack, hack, hack.
|
|
|
|
|
|
|
|
For tips on working with the code, see the `Coding Guide`_.
|
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
#. Test, test, test.
|
|
|
|
|
|
|
|
Testing is best done through ``tox``, which provides a number of targets and
|
|
|
|
allows testing against multiple different Python environments:
|
|
|
|
|
|
|
|
* To list all possible targets::
|
|
|
|
|
|
|
|
tox -av
|
|
|
|
|
|
|
|
* To run unit tests for a specific Python version, such as 3.6::
|
|
|
|
|
|
|
|
tox -e py36
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* To run unit tests for a specific Python version and turn on deprecation
|
|
|
|
warnings on so they're shown in the test output::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
PYTHONWARNINGS=all tox -e py36
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* To run code style and type checks::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
tox -e mypy
|
|
|
|
tox -e flake8
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* Arguments to ``pytest`` can be passed via ``tox``, e.g. in order to run a
|
2017-10-04 15:32:12 -05:00
|
|
|
particular test::
|
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
tox -e py36 tests/test_module.py::test_new_feature
|
2017-10-04 15:32:12 -05:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* To build the documentation::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
tox -e docs
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* To build the documentation in multiple formats::
|
2017-03-16 03:35:11 -05:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
tox -e docs -- -b html,latexpdf
|
2017-03-16 03:35:11 -05:00
|
|
|
|
2018-07-22 13:20:32 -05:00
|
|
|
* To run JavaScript tests with `Karma <https://karma-runner.github.io>`_,
|
|
|
|
execute the following commands (requires `Node.js <https://nodejs.org>`_)::
|
|
|
|
|
|
|
|
npm install
|
|
|
|
npm run test
|
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
You can also test by installing dependencies in your local environment. ::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
pip install .[test]
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
New unit tests should be included in the ``tests`` directory where
|
|
|
|
necessary:
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
* For bug fixes, first add a test that fails without your changes and passes
|
|
|
|
after they are applied.
|
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* Tests that need a ``sphinx-build`` run should be integrated in one of the
|
2016-12-16 09:52:11 -06:00
|
|
|
existing test modules if possible. New tests that to ``@with_app`` and
|
|
|
|
then ``build_all`` for a few assertions are not good since *the test suite
|
|
|
|
should not take more than a minute to run*.
|
|
|
|
|
|
|
|
#. Please add a bullet point to :file:`CHANGES` if the fix or feature is not
|
|
|
|
trivial (small doc updates, typo fixes). Then commit::
|
|
|
|
|
|
|
|
git commit -m '#42: Add useful new feature that does this.'
|
|
|
|
|
2017-04-18 23:08:36 -05:00
|
|
|
GitHub recognizes certain phrases that can be used to automatically
|
2016-12-16 09:52:11 -06:00
|
|
|
update the issue tracker.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
git commit -m 'Closes #42: Fix invalid markup in docstring of Foo.bar.'
|
|
|
|
|
|
|
|
would close issue #42.
|
|
|
|
|
2017-04-18 23:08:36 -05:00
|
|
|
#. Push changes in the branch to your forked repository on GitHub. ::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
git push origin feature-xyz
|
|
|
|
|
|
|
|
#. Submit a pull request from your branch to the respective branch (``master``
|
2020-02-09 05:28:23 -06:00
|
|
|
or ``A.x``).
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
#. Wait for a core developer to review your changes.
|
|
|
|
|
|
|
|
|
2020-03-28 08:37:22 -05:00
|
|
|
Translations
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The Sphinx core messages and documentations are translated on `Transifex
|
|
|
|
<https://www.transifex.com/>`_. Please join `Sphinx project on Transifex
|
|
|
|
<https://www.transifex.com/sphinx-doc/>`_ and translate them.
|
|
|
|
|
|
|
|
|
2016-12-16 09:52:11 -06:00
|
|
|
Core Developers
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The core developers of Sphinx have write access to the main repository. They
|
|
|
|
can commit changes, accept/reject pull requests, and manage items on the issue
|
|
|
|
tracker.
|
|
|
|
|
|
|
|
You do not need to be a core developer or have write access to be involved in
|
|
|
|
the development of Sphinx. You can submit patches or create pull requests
|
|
|
|
from forked repositories and have a core developer add the changes for you.
|
|
|
|
|
|
|
|
The following are some general guidelines for core developers:
|
|
|
|
|
|
|
|
* Questionable or extensive changes should be submitted as a pull request
|
|
|
|
instead of being committed directly to the main repository. The pull
|
|
|
|
request should be reviewed by another core developer before it is merged.
|
|
|
|
|
|
|
|
* Trivial changes can be committed directly but be sure to keep the repository
|
|
|
|
in a good working state and that all tests pass before pushing your changes.
|
|
|
|
|
|
|
|
* When committing code written by someone else, please attribute the original
|
|
|
|
author in the commit message and any relevant :file:`CHANGES` entry.
|
|
|
|
|
|
|
|
|
|
|
|
Coding Guide
|
|
|
|
------------
|
|
|
|
|
|
|
|
* Try to use the same code style as used in the rest of the project. See the
|
|
|
|
`Pocoo Styleguide`__ for more information.
|
|
|
|
|
|
|
|
__ http://flask.pocoo.org/docs/styleguide/
|
|
|
|
|
|
|
|
* For non-trivial changes, please update the :file:`CHANGES` file. If your
|
|
|
|
changes alter existing behavior, please document this.
|
|
|
|
|
|
|
|
* New features should be documented. Include examples and use cases where
|
|
|
|
appropriate. If possible, include a sample that is displayed in the
|
|
|
|
generated output.
|
|
|
|
|
|
|
|
* When adding a new configuration variable, be sure to document it and update
|
2019-01-07 01:29:11 -06:00
|
|
|
:file:`sphinx/cmd/quickstart.py` if it's important enough.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
* Add appropriate unit tests.
|
|
|
|
|
|
|
|
|
|
|
|
Debugging Tips
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
* Delete the build cache before building documents if you make changes in the
|
|
|
|
code by running the command ``make clean`` or using the
|
|
|
|
:option:`sphinx-build -E` option.
|
|
|
|
|
2017-10-03 04:00:40 -05:00
|
|
|
* Use the :option:`sphinx-build -P` option to run ``pdb`` on exceptions.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
* Use ``node.pformat()`` and ``node.asdom().toxml()`` to generate a printable
|
|
|
|
representation of the document structure.
|
|
|
|
|
|
|
|
* Set the configuration variable :confval:`keep_warnings` to ``True`` so
|
|
|
|
warnings will be displayed in the generated output.
|
|
|
|
|
|
|
|
* Set the configuration variable :confval:`nitpicky` to ``True`` so that Sphinx
|
|
|
|
will complain about references without a known target.
|
|
|
|
|
|
|
|
* Set the debugging options in the `Docutils configuration file
|
|
|
|
<http://docutils.sourceforge.net/docs/user/config.html>`_.
|
|
|
|
|
2019-05-29 11:07:05 -05:00
|
|
|
* JavaScript stemming algorithms in ``sphinx/search/*.py`` (except ``en.py``)
|
|
|
|
are generated by this
|
2016-12-16 09:52:11 -06:00
|
|
|
`modified snowballcode generator <https://github.com/shibukawa/snowball>`_.
|
2017-05-29 11:43:56 -05:00
|
|
|
Generated `JSX <https://jsx.github.io/>`_ files are
|
2016-12-16 09:52:11 -06:00
|
|
|
in `this repository <https://github.com/shibukawa/snowball-stemmer.jsx>`_.
|
2017-03-18 03:25:48 -05:00
|
|
|
You can get the resulting JavaScript files using the following command::
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2018-07-22 13:20:32 -05:00
|
|
|
npm install
|
|
|
|
node_modules/.bin/grunt build # -> dest/*.global.js
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2018-02-06 08:38:46 -06:00
|
|
|
|
|
|
|
Branch Model
|
|
|
|
------------
|
|
|
|
|
2019-01-12 07:22:42 -06:00
|
|
|
Sphinx project uses following branches for developing that conforms to Semantic
|
|
|
|
Versioning 2.0.0 (refs: https://semver.org/ ).
|
2018-02-06 08:38:46 -06:00
|
|
|
|
|
|
|
``master``
|
2019-01-12 07:22:42 -06:00
|
|
|
Development for MAJOR version.
|
2019-01-12 23:50:21 -06:00
|
|
|
All changes including incompatible behaviors and public API updates are
|
|
|
|
allowed.
|
2018-02-06 08:38:46 -06:00
|
|
|
|
2020-02-09 05:28:23 -06:00
|
|
|
``A.x`` (ex. ``2.x``)
|
|
|
|
Where ``A.x`` is the ``MAJOR.MINOR`` release. Used to maintain current
|
2019-01-12 07:22:42 -06:00
|
|
|
MINOR release. All changes are allowed if the change preserves
|
|
|
|
backwards-compatibility of API and features.
|
|
|
|
|
|
|
|
Only the most recent ``MAJOR.MINOR`` branch is currently retained. When a
|
|
|
|
new MAJOR version is released, the old ``MAJOR.MINOR`` branch will be
|
|
|
|
deleted and replaced by an equivalent tag.
|
|
|
|
|
2020-02-09 05:28:23 -06:00
|
|
|
``A.B.x`` (ex. ``2.4.x``)
|
|
|
|
Where ``A.B.x`` is the ``MAJOR.MINOR.PATCH`` release. Only
|
2019-01-12 07:22:42 -06:00
|
|
|
backwards-compatible bug fixes are allowed. In Sphinx project, PATCH
|
|
|
|
version is used for urgent bug fix.
|
|
|
|
|
|
|
|
``MAJOR.MINOR.PATCH`` branch will be branched from the ``v`` prefixed
|
2019-01-12 23:50:21 -06:00
|
|
|
release tag (ex. make 2.3.1 that branched from v2.3.0) when a urgent
|
|
|
|
release is needed. When new PATCH version is released, the branch will be
|
|
|
|
deleted and replaced by an equivalent tag (ex. v2.3.1).
|
2018-02-06 08:38:46 -06:00
|
|
|
|
|
|
|
|
2016-12-16 09:52:11 -06:00
|
|
|
Deprecating a feature
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
There are a couple reasons that code in Sphinx might be deprecated:
|
|
|
|
|
|
|
|
* If a feature has been improved or modified in a backwards-incompatible way,
|
|
|
|
the old feature or behavior will be deprecated.
|
|
|
|
|
|
|
|
* Sometimes Sphinx will include a backport of a Python library that's not
|
|
|
|
included in a version of Python that Sphinx currently supports. When Sphinx
|
|
|
|
no longer needs to support the older version of Python that doesn't include
|
|
|
|
the library, the library will be deprecated in Sphinx.
|
|
|
|
|
2017-12-22 12:50:51 -06:00
|
|
|
As the :ref:`deprecation-policy` describes, the first release of Sphinx that
|
|
|
|
deprecates a feature (``A.B``) should raise a ``RemovedInSphinxXXWarning``
|
|
|
|
(where ``XX`` is the Sphinx version where the feature will be removed) when the
|
|
|
|
deprecated feature is invoked. Assuming we have good test coverage, these
|
|
|
|
warnings are converted to errors when running the test suite with warnings
|
|
|
|
enabled::
|
|
|
|
|
|
|
|
pytest -Wall
|
|
|
|
|
|
|
|
Thus, when adding a ``RemovedInSphinxXXWarning`` you need to eliminate or
|
|
|
|
silence any warnings generated when running the tests.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
.. _deprecation-policy:
|
|
|
|
|
|
|
|
Deprecation policy
|
|
|
|
------------------
|
|
|
|
|
2019-01-12 23:50:21 -06:00
|
|
|
MAJOR and MINOR releases may deprecate certain features from previous
|
|
|
|
releases. If a feature is deprecated in a release A.x, it will continue to
|
2019-01-12 07:22:42 -06:00
|
|
|
work in all A.x.x versions (for all versions of x). It will continue to work
|
|
|
|
in all B.x.x versions but raise deprecation warnings. Deprecated features
|
|
|
|
will be removed at the C.0.0. It means the deprecated feature will work during
|
|
|
|
2 MAJOR releases at least.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
So, for example, if we decided to start the deprecation of a function in
|
2019-01-12 07:22:42 -06:00
|
|
|
Sphinx 2.x:
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2019-01-12 07:22:42 -06:00
|
|
|
* Sphinx 2.x will contain a backwards-compatible replica of the function
|
|
|
|
which will raise a ``RemovedInSphinx40Warning``.
|
2020-03-15 13:15:56 -05:00
|
|
|
This is a subclass of :exc:`python:PendingDeprecationWarning`, i.e. it
|
|
|
|
will not get displayed by default.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2020-03-15 13:15:56 -05:00
|
|
|
* Sphinx 3.x will still contain the backwards-compatible replica, but
|
|
|
|
``RemovedInSphinx40Warning`` will be a subclass of
|
|
|
|
:exc:`python:DeprecationWarning` then, and gets displayed by default.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2019-01-12 07:22:42 -06:00
|
|
|
* Sphinx 4.0 will remove the feature outright.
|
2016-12-16 09:52:11 -06:00
|
|
|
|
2020-03-15 13:15:56 -05:00
|
|
|
Deprecation warnings
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Sphinx will enable its ``RemovedInNextVersionWarning`` warnings by default,
|
|
|
|
if :envvar:`python:PYTHONWARNINGS` is not set.
|
|
|
|
Therefore you can disable them using:
|
2016-12-16 09:52:11 -06:00
|
|
|
|
|
|
|
* ``PYTHONWARNINGS= make html`` (Linux/Mac)
|
|
|
|
* ``export PYTHONWARNINGS=`` and do ``make html`` (Linux/Mac)
|
|
|
|
* ``set PYTHONWARNINGS=`` and do ``make html`` (Windows)
|
2017-05-07 02:46:44 -05:00
|
|
|
|
2020-03-15 13:15:56 -05:00
|
|
|
But you can also explicitly enable the pending ones using e.g.
|
|
|
|
``PYTHONWARNINGS=default`` (see the
|
|
|
|
:ref:`Python docs on configuring warnings <python:describing-warning-filters>`)
|
|
|
|
for more details.
|
|
|
|
|
2017-05-07 02:46:44 -05:00
|
|
|
Unit Testing
|
|
|
|
------------
|
|
|
|
|
|
|
|
Sphinx has been tested with pytest runner. Sphinx developers write unit tests
|
|
|
|
using pytest notation. Utility functions and pytest fixtures for testing are
|
|
|
|
provided in ``sphinx.testing``. If you are a developer of Sphinx extensions,
|
|
|
|
you can write unit tests with using pytest. At this time, ``sphinx.testing``
|
|
|
|
will help your test implementation.
|
|
|
|
|
2017-05-22 13:46:49 -05:00
|
|
|
How to use pytest fixtures that are provided by ``sphinx.testing``?
|
2017-05-07 02:46:44 -05:00
|
|
|
You can require ``'sphinx.testing.fixtures'`` in your test modules or
|
|
|
|
``conftest.py`` files like this::
|
|
|
|
|
|
|
|
pytest_plugins = 'sphinx.testing.fixtures'
|
|
|
|
|
|
|
|
If you want to know more detailed usage, please refer to ``tests/conftest.py``
|
|
|
|
and other ``test_*.py`` files under ``tests`` directory.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
Prior to Sphinx - 1.5.2, Sphinx was running the test with nose.
|
|
|
|
|
|
|
|
.. versionadded:: 1.6
|
|
|
|
``sphinx.testing`` as a experimental.
|
2018-07-22 13:20:32 -05:00
|
|
|
|
|
|
|
.. versionadded:: 1.8
|
|
|
|
Sphinx also runs JavaScript tests.
|
2020-03-28 08:37:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
Release procedures
|
|
|
|
------------------
|
|
|
|
|
|
|
|
The release procedures are listed on ``utils/release-checklist``.
|
|
|
|
|
|
|
|
|
|
|
|
Locale Updates
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The parts of messages in Sphinx that go into builds are translated into several
|
|
|
|
locales. The translations are kept as gettext ``.po`` files translated from the
|
|
|
|
master template :file:`sphinx/locale/sphinx.pot`.
|
|
|
|
|
|
|
|
Sphinx uses `Babel <http://babel.pocoo.org/en/latest/>`_ to extract messages
|
|
|
|
and maintain the catalog files. It is integrated in ``setup.py``:
|
|
|
|
|
|
|
|
* Use ``python setup.py extract_messages`` to update the ``.pot`` template.
|
|
|
|
* Use ``python setup.py update_catalog`` to update all existing language
|
|
|
|
catalogs in ``sphinx/locale/*/LC_MESSAGES`` with the current messages in the
|
|
|
|
template file.
|
|
|
|
* Use ``python setup.py compile_catalog`` to compile the ``.po`` files to binary
|
|
|
|
``.mo`` files and ``.js`` files.
|
|
|
|
|
|
|
|
When an updated ``.po`` file is submitted, run compile_catalog to commit both
|
|
|
|
the source and the compiled catalogs.
|
|
|
|
|
|
|
|
When a new locale is submitted, add a new directory with the ISO 639-1 language
|
|
|
|
identifier and put ``sphinx.po`` in there. Don't forget to update the possible
|
|
|
|
values for :confval:`language` in ``doc/usage/configuration.rst``.
|
|
|
|
|
|
|
|
The Sphinx core messages can also be translated on `Transifex
|
|
|
|
<https://www.transifex.com/>`_. There exists a client tool named ``tx`` in the
|
|
|
|
Python package "transifex_client", which can be used to pull translations in
|
|
|
|
``.po`` format from Transifex. To do this, go to ``sphinx/locale`` and then run
|
|
|
|
``tx pull -f -l LANG`` where LANG is an existing language identifier. It is
|
|
|
|
good practice to run ``python setup.py update_catalog`` afterwards to make sure
|
|
|
|
the ``.po`` file has the canonical Babel formatting.
|