Skip to content

Commit 782c3a2

Browse files
Use tags in docs building to split up requirements
The goal is to allow a build of just the `man` pages with a minimal set of dependencies, like: sphinx-build \ --tag man \ -c docs/html \ -d docs/build/doctrees/man \ -b man \ docs/man \ docs/build/man This is for the sake of people distributing `pip` who want to build the man pages (but not the HTML ones) along side the application. This is an alternative to the approach proposed in[1] and similarly addresses[2] Link: #12900 [1] Link: #12881 [2]
1 parent f5ff4fa commit 782c3a2

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

docs/html/conf.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,30 @@
1212
sys.path.insert(0, docs_dir)
1313

1414
# -- General configuration ------------------------------------------------------------
15-
1615
extensions = [
17-
# first-party extensions
18-
"sphinx.ext.autodoc",
19-
"sphinx.ext.todo",
20-
"sphinx.ext.intersphinx",
21-
# our extensions
16+
# extensions common to all builds
2217
"pip_sphinxext",
23-
# third-party extensions
24-
"myst_parser",
25-
"sphinx_copybutton",
26-
"sphinx_inline_tabs",
27-
"sphinxcontrib.towncrier",
28-
"sphinx_issues",
2918
]
3019

20+
# 'tags' is a injected by sphinx
21+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-tags
22+
if "man" not in tags: # type: ignore[name-defined] # noqa: F821
23+
# extensions not needed for building man pages
24+
extensions.extend(
25+
(
26+
# first-party extensions
27+
"sphinx.ext.autodoc",
28+
"sphinx.ext.todo",
29+
"sphinx.ext.intersphinx",
30+
# third-party extensions
31+
"myst_parser",
32+
"sphinx_copybutton",
33+
"sphinx_inline_tabs",
34+
"sphinxcontrib.towncrier",
35+
"sphinx_issues",
36+
),
37+
)
38+
3139
# General information about the project.
3240
project = "pip"
3341
copyright = "The pip developers"

news/13168.doc.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Added support for building only the man pages with minimal dependencies using
2+
the sphinx-build ``--tag man`` option. This enables distributors to generate man
3+
pages without requiring HTML documentation dependencies.

noxfile.py

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def get_sphinx_build_command(kind: str) -> List[str]:
146146
return [
147147
"sphinx-build",
148148
"--keep-going",
149+
"--tag",
150+
kind,
149151
"-W",
150152
"-c", "docs/html", # see note above
151153
"-d", "docs/build/doctrees/" + kind,

0 commit comments

Comments
 (0)