Repository navigation
Speed up doc build by factor of 2 by defining substitutions via sphinxcontrib-globalsubs instead of common_links.rst - #2281
Conversation
|
Thank you for submitting a pull request (PR) to PlasmaPy! ✨ The future of the project depends on contributors like you, so we deeply appreciate it! 🌱 Our contributor guide has information on:
The bottom of this page shows several checks that are run for every PR. Don't worry if something broke! We break stuff all the time. 😺 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well. 🌸 You can find us in our chat room or weekly community meeting & office hours. Here are some tips:
If this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. ✅ If you don't get a review within a few days, please feel free to send us a reminder. Please also use SI units within PlasmaPy, except when there is strong justification otherwise or in some examples. We thank you once again! |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #2281 +/- ##
=======================================
Coverage 98.35% 98.35%
=======================================
Files 99 99
Lines 8554 8554
=======================================
Hits 8413 8413
Misses 141 141
☔ View full report in Codecov by Sentry. |
|
|
From #2277:
In the most recent doc build, it was 384 s, which doesn't include the changes from #2272. Better! (I did these on my work computer using |
|
Merging in #2272 gets it down to 317 s. Much better! And that's still with a bunch of links in |
There was a problem hiding this comment.
Previously, the contents of this file were included in rst_prolog, which is a Sphinx configuration variable containing text that gets appended to every file and docstring before Sphinx processes it. We had been using it to define substitutions. However, adding this to every source file and docstring added ∼3 minutes to an already long documentation build. Replacing this file via sphinxcontrib-globalsubs was the main point of this PR.
|
Benchmark on my home computer using
With #2272 and this PR, we've sped up the Sphinx build by a factor of two! |
There was a problem hiding this comment.
This is the main file to review. Thank you!
| global_substitutions = ( | ||
| plasmapy_subs | doc_subs | numpy_subs | astropy_subs | processed_links | ||
| ) |
There was a problem hiding this comment.
Union operator for dictionaries...added in Python 3.9!
|
The main thing to review is Most of the changes in the rest of the documentation are associated with changing reStructuredText links into reStructuredText substitutions (i.e. changing the Thank you! |
sphinxcontrib-globalsubs instead of common_links.rst
This PR implements
sphinxcontrib-globalsubsas a Sphinx extension to allow us to define reStructuredText substitutions that can be used throughout PlasmaPy's documentation.The substitutions are now defined in
docs/_global_substitutions.py, which defines theglobal_substitutionsdict which is imported indocs/conf.py, and is whatsphinxcontrib-globalsubsuses to define global substitutions. I moved all substitutions out ofcommon_links.rst. Substitutions are now defined in_global_substitutions.pyvia a dictionary, or in the file the substitutions are used in.Motivation and context
Prior to this pull request, we defined global reStructuredText substitutions in
docs/common_links.rst. The contents ofcommon_links.rstgot added to therst_epilogSphinx configuration variable, which is used to append text to every reStructuredText source file. The problem with this approach is that it can add ∼2–3 minutes to an already slow documentation build. This PR lets us skip usingrst_epilogand thus speeds up the documentation build.Related issues
See #2277 and #2280 for more detail. Closes #2280. Also discussed in astropy/astropy#15149. I learned about
sphinxcontrib-globalsubsin sphinx-doc/sphinx#2173.