-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use tags in docs building to split up requirements #13168
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,30 @@ | |
sys.path.insert(0, docs_dir) | ||
|
||
# -- General configuration ------------------------------------------------------------ | ||
|
||
extensions = [ | ||
# first-party extensions | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.todo", | ||
"sphinx.ext.intersphinx", | ||
# our extensions | ||
# extensions common to all builds | ||
"pip_sphinxext", | ||
# third-party extensions | ||
"myst_parser", | ||
"sphinx_copybutton", | ||
"sphinx_inline_tabs", | ||
"sphinxcontrib.towncrier", | ||
"sphinx_issues", | ||
] | ||
|
||
# 'tags' is a injected by sphinx | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-tags | ||
if "man" not in tags: # type: ignore[name-defined] # noqa: F821 | ||
# extensions not needed for building man pages | ||
extensions.extend( | ||
( | ||
# first-party extensions | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.todo", | ||
"sphinx.ext.intersphinx", | ||
# third-party extensions | ||
"myst_parser", | ||
"sphinx_copybutton", | ||
"sphinx_inline_tabs", | ||
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two seem to be the only genuine 'HTML-only' extensions. Perhaps the condition might be better expressed as You could also look at the Python docs, where we use a pattern to check if an extension is importable, and if so add it to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
👍 this was also suggested above (#13168 (comment)) and I agree it makes this clearer (and simplifies the code!) so trying that: 033c31c |
||
"sphinxcontrib.towncrier", | ||
"sphinx_issues", | ||
), | ||
) | ||
|
||
# General information about the project. | ||
project = "pip" | ||
copyright = "The pip developers" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Added support for building only the man pages with minimal dependencies using | ||
the sphinx-build ``--tag man`` option. This enables distributors to generate man | ||
pages without requiring HTML documentation dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurred to me that maybe if the extension loading was to be moved to the
setup()
entry point, the builder name would already be known by then and so this might not even have to use tags but would rely on the requested builders.Another approach I used in the past, in a little different context, was scanning for the builder args in
sys.argv
: sphinx-contrib/spelling#55 (comment) / cherrypy/cheroot@63097fb#diff-85933aa74a2d66c3e4dcdf7a9ad8397f5a7971080d34ef1108296a7c6b69e7e3R12-R15.