faq.rst 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. .. _faq:
  2. ==========================
  3. Frequently Asked Questions
  4. ==========================
  5. Why another tool for versioning Sphinx docs?
  6. ============================================
  7. While there are several sphinx extensions out there (e.g. `sphinxcontrib-versioning <sphinxcontrib_versioning_>`_ or `sphinx-versions <sphinx_versions_>`_) none of them seem to work correctly with recent sphinx versions (as of March 2020).
  8. Their code heavily relies on monkey-patching Sphinx internals at runtime, which is error-prone and makes the code a mess.
  9. In contrast, the extension part of ``sphinx-multiversion`` does not do any fancy patching, it just provides some HTML context variables.
  10. How does it work?
  11. =================
  12. Instead of running `sphinx build`, just run `sphinx-multiversion` from the root of your Git repository.
  13. It reads your Sphinx :file:`conf.py` file from the currently checked out Git branch for configuration, then generates a list of versions from local or remote tags and branches.
  14. This data is written to a JSON file - if you want to have a look what data will be generated, you can use the ``--dump-metadata`` flag.
  15. Then it copies the data for each version into separate temporary directories, builds the documentation from each of them and writes the output to the output directory.
  16. The :file:`conf.py` file from the currently checked out branch will be used to build old versions, so it's not necessary to make changes old branches or tags to add support for ``sphinx-multiversion``.
  17. This also means that theme improvements, template changes, etc. will automatically be applied to old versions without needing to add commits.
  18. Do I need to make changes to old branches or tags?
  19. ==================================================
  20. No, you don't. ``sphinx-multiversion`` will always use the :file:`conf.py` file from your currently checked out branch.
  21. The downside is that this behaviour restricts the kinds of changes you may do to your configuration, because it needs to retain compatibility with old branches.
  22. For example, if your :file:`conf.py` file hardcodes a path (e.g. for opening a file), but that file does not exist in some older branches that you want to build documentation for, this will cause issues.
  23. In these cases you will need to add a check if a file actually exists and adapt the path accordingly.
  24. What are the license terms of ``sphinx-multiversion``?
  25. ======================================================
  26. ``sphinx-multiversion`` is licensed under the terms of the `BSD 2-Clause license <bsd_2clause_license_>`_.
  27. .. _sphinxcontrib_versioning: https://github.com/sphinx-contrib/sphinxcontrib-versioning
  28. .. _sphinx_versions: https://github.com/Smile-SA/sphinx-versions
  29. .. _bsd_2clause_license: https://choosealicense.com/licenses/bsd-2-clause/