Repository navigation
DOC: Speed up Sphinx build by using sphinxcontrib-globalsubs - #16162
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
|
For the record, the last |
|
This is fantastic! I've always wondered how we could get rid of the |
Another win for procrastination-driven development! 😹 |
|
I just checked, the RTD build for this PR took 926 seconds or 15.4 mins. That's 10% speed up? |
sphinxcontrib-globalsubssphinxcontrib-globalsubs
sphinxcontrib-globalsubssphinxcontrib-globalsubs
Thank you for checking this! The ∼20% improvement was on the It looks like the |
eerovaher
left a comment
There was a problem hiding this comment.
I can approve for coordinates.
|
@namurphy , when do you think this is ready to be taken out of draft? Thanks! |
|
I'm still figuring out moving the remaining contents of I think...this can wait until tomorrow! |
|
pre-commit.ci autofix |
| "sphinx_design", | ||
| "Jinja2>=3.1.3", | ||
| "tomli; python_version < '3.11'", | ||
| "sphinxcontrib-globalsubs >= 0.1.1", |
There was a problem hiding this comment.
One possible concern is that this is an early version of sphinxcontrib-globalsubs, which was released last year. But, we've been using it in PlasmaPy for a while now with no problems, and it wouldn't be that much work to go back to common_links.txt.
There was a problem hiding this comment.
Since this only affects doc build and RTD is green, probably okay.
|
Ready for review! The most recent build took 878 s, which is about 15% less than the ∼1038 s baseline. |
taldcroft
left a comment
There was a problem hiding this comment.
Fine for io.ascii and time.
pllim
left a comment
There was a problem hiding this comment.
Final timing:
- This PR: Completed March 7, 2024. 4:20 p.m. Build took 878 seconds 🚀
main: Completed March 8, 2024. 2:46 a.m. Build took 1035 seconds
I think we have enough approvals. Let's speed things up. Thank you very much!
| "StructuredUnit": ":class:`~astropy.units.StructuredUnit`", | ||
| # Utils | ||
| "Masked": ":class:`~astropy.utils.masked.Masked`", | ||
| # Minimum versions |
There was a problem hiding this comment.
I think we lost the ability to be able to dynamically insert new minversion listing for dependencies (which tend to keep growing nowdays).
That said, docs/conf.py is easier to discover than docs/common_links.txt in general, plus the speed up. So the benefit of this PR outweighs the risk of forgetting to insert a new entry here.
| <https://www.python.org/dev/peps/pep-0008/>`_. All of the PEP8 testing | ||
| so that they check Python source code for |PEP8|. All of the PEP8 testing | ||
| options require the `pytest-pep8 plugin | ||
| <https://pypi.org/project/pytest-pep8>`_, which must be installed |
There was a problem hiding this comment.
Side note: I never even installed pytest-pep8. The dev guide could probably use some serious clean-up but that is a battle for another day.
| "sphinx_design", | ||
| "Jinja2>=3.1.3", | ||
| "tomli; python_version < '3.11'", | ||
| "sphinxcontrib-globalsubs >= 0.1.1", |
There was a problem hiding this comment.
Since this only affects doc build and RTD is green, probably okay.
* Apply sphinxcontrib-globalsubs to substitutions across the package * Remove unused substitutions/links * Add comments to conf.py * Move over common_links.rst to conf.py
Astropy presently uses
docs/common_links.txtto store global substitutions that can be used throughout the documentation. The contents of this file are read in throughdocs/conf.pyand then added torst_prolog. Becauserst_prologgets added to the beginning of every reStructuredText file and docstring, a lengthyrst_prologcan add minutes to the documentation build (see #15149). 🐌The
sphinxcontrib-globalsubsextension allows us to create theglobal_substitutionsdictionary indocs/conf.pyto contain substitutions for use throughout the documentation, eliminating the need to prependrst_prologto files and docstrings.A clean doc build prior to this PR locally took 7.2 min. After moving most of the common links to
global_substitutionsindocs/conf.py, a clean documentation build took 5.8 min. The doc build was shortened by 20%. 🎆 For these timings, I usedmake html -j 2so that the documentation build was done on two processors. (These times do not include the creation of a Python environment.)Because
sphinxcontrib-globalsubsonly works with substitutions, I had to convert some links in the docs to substitutions (i.e.,SciPy_→|SciPy|).I still need to clean this up a bit & document this a bit better. There's still some content in
docs/common_links.txtthat will require a bit more work. I'd also like to define these substitutions in a separate file which can then get imported todocs/conf.py, but I had some trouble getting that to work, so I may do this in a follow-up PR.Closes #15149. This was inspired by PlasmaPy/PlasmaPy#2277, PlasmaPy/PlasmaPy#2280, & PlasmaPy/PlasmaPy#2281. There's some related discussion on how to speed up the documentation build in CI in #16161.