123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- .. _configuration:
- =============
- Configuration
- =============
- ``sphinx-multiversion`` reads your Sphinx :file:`conf.py` file for configuration.
- As usual, you can also override certain options by using ``-D var=value`` on the command line.
- This is what the default configuration looks like:
- .. code-block:: python
-
- smv_tag_whitelist = r'^.*$'
-
- smv_branch_whitelist = r'^.*$'
-
- smv_remote_whitelist = None
-
- smv_released_pattern = r'^tags/.*$'
-
- smv_outputdir_format = '{ref.name}'
-
- smv_prefer_remote_refs = False
- You can override all of these values inside your :file:`conf.py`.
- .. note::
- You can check which tags/branches are matched by running ``sphinx-multiversion`` with the ``--dump-metadata`` flag. Branches or tags that don't contain both the sphinx source directory and the :file:`conf.py` file will be skipped automatically.
- Tag/Branch/Remote whitelists
- ============================
- Tags, Branches and Remotes are included by `Regular Expressions <python_regex_>`_.
- Here are some examples:
- .. code-block:: python
- smv_tag_whitelist = r'^.*$'
- smv_tag_whitelist = r'^v\d+\.\d+$'
- smv_branch_whitelist = r'^.*$'
- smv_branch_whitelist = r'^(?!master).*$'
- smv_remote_whitelist = None
- smv_remote_whitelist = r'^.*$'
- smv_remote_whitelist = r'^(origin|upstream)$'
- .. note::
- To list values to match, you can use ``git branch``, ``git tag`` and ``git remote``.
- Release Pattern
- ===============
- A Regular Expression is used to determine if a version of the documentation has been released or if it's a development version.
- To allow more flexibility, the regex is evaluated over the full refname.
- Here are some examples:
- .. code-block:: python
- smv_released_pattern = r'^tags/.*$'
- smv_released_pattern = r'^heads/\d+\.\d+$'
- smv_released_pattern = r'^(tags/.*|heads/\d+\.\d+)$'
- smv_released_pattern = r'^(heads|remotes/[^/]+)/(?!:master).*$'
- .. note::
- To list all refnames , you can use:
- .. code-block:: bash
- git for-each-ref --format "%(refname)" | sed 's/^refs\///g'
- Output Directory Format
- =======================
- Each version will be built into a seperate subdirectory of the Sphinx output directory.
- The ``smv_outputdir_format`` setting determines the directory structure for the subdirectories. It is a new-style Python formatting string with two parameters - ``ref`` and ``config``.
- Here are some examples:
- .. code-block:: python
- smv_outputdir_format = '{ref.name}'
- smv_outputdir_format = '{ref.commit}'
- smv_outputdir_format = '{ref.commit:.7s}'
- smv_outputdir_format = '{ref.refname}'
- smv_outputdir_format = '{ref.source}/{ref.name}'
- smv_outputdir_format = 'versions/{config.release}'
- smv_outputdir_format = '{config.version}/{ref.name}'
- .. seealso::
- Have a look at `PyFormat <python_format_>`_ for information how to use new-style Python formatting.
- Overriding Configuration Variables
- ==================================
- You can override configuration variables the same way as you're used to with ``sphinx-build``.
- Since ``sphinx-multiversion`` copies the branch data into a temporary directory and builds them there while leaving the current working directory unchanged, relative paths in your :file:`conf.py` will refer to the path of the version *you're building from*, not the path of the version you are trying to build documentation for.
- Sometimes it might be necessary to override the configured path via a command line overide.
- ``sphinx-multiversion`` allows you to insert placeholders into your override strings that will automatically be replaced with the correct value for the version you're building the documentation for.
- Here's an example for the `exhale extension <exhale_>`_:
- .. code-block:: python
- sphinx-multiversion docs build/html -D 'exhale_args.containmentFolder=${sourcedir}/api'
- .. note::
- Make sure to enclose the override string in single quotes (``'``) to prevent the shell from treating it as an environment variable and replacing it before it's passed to ``sphinx-multiversion``.
- .. note::
- To see a list of available placeholder names and their values for each version you can use the ``--dump-metadata`` flag.
- .. _python_regex: https://docs.python.org/3/howto/regex.html
- .. _python_format: https://pyformat.info/
- .. _exhale: https://exhale.readthedocs.io/en/latest/
|