quickstart.rst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .. _quickstart:
  2. ==========
  3. Quickstart
  4. ==========
  5. After :ref:`installation <install>`, using ``sphinx-multiversion`` should be fairly straightforward.
  6. To be able to build multiple versions of Sphinx documentation, ``sphinx-multiversion`` acts as wrapper for ``sphinx-build``.
  7. If you're already using Sphinx documentation for your project, you can now use ``sphinx-multiversion`` to build the HTML documentation.
  8. You can check if it works by running:
  9. .. code-block:: bash
  10. # Without sphinx-multiversion
  11. sphinx-build docs build/html
  12. # With sphinx-multiversion
  13. sphinx-multiversion docs build/html
  14. Don't worry - no version picker will show up in the generated HTML yet.
  15. You need to :ref:`configure <configuration>` the extension first.
  16. .. seealso::
  17. If you're not using Sphinx yet, have a look at the `tutorial <sphinx_tutorial_>`_.
  18. Next, you need to add the extension to the :file:`conf.py` file.
  19. .. code-block:: python
  20. extensions = [
  21. "sphinx_multiversion",
  22. ]
  23. To make the different versions show up in the HTML, you also need to add a custom template. For example, you could create a new template named :file:`versioning.html` with the following content:
  24. .. code-block:: html
  25. {% if versions %}
  26. <h3>{{ _('Versions') }}</h3>
  27. <ul>
  28. {%- for item in versions %}
  29. <li><a href="{{ item.url }}">{{ item.name }}</a></li>
  30. {%- endfor %}
  31. </ul>
  32. {% endif %}
  33. .. seealso::
  34. You can also list branches, tags, released versions and development branches separately.
  35. See :ref:`Templates <templates>` for details.
  36. Assuming that you're using a theme with sidebar widget support, you just need to make sure that the file is inside the ``templates_path`` and add it to the `html_sidebars <sphinx_html_sidebars_>`_ variable.
  37. .. code-block:: python
  38. templates_path = [
  39. "_templates",
  40. ]
  41. html_sidebars = {
  42. '**': [
  43. 'versioning.html',
  44. ],
  45. }
  46. Now rebuild the documentation:
  47. .. code-block:: bash
  48. sphinx-multiversion docs build/html
  49. Done!
  50. .. seealso::
  51. By default, all local branches and tags will be included. If you only want to include certain branches/tags or also include remote branches, see :ref:`Configuration <configuration>`.
  52. .. _sphinx_tutorial: http://www.sphinx-doc.org/en/stable/tutorial.html
  53. .. _sphinx_html_sidebars: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars