diff --git a/docs/html/conf.py b/docs/html/conf.py
index be95eca2941..a31396bc13c 100644
--- a/docs/html/conf.py
+++ b/docs/html/conf.py
@@ -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",
+ "sphinxcontrib.towncrier",
+ "sphinx_issues",
+ ),
+ )
+
# General information about the project.
project = "pip"
copyright = "The pip developers"
diff --git a/news/13168.doc.rst b/news/13168.doc.rst
new file mode 100644
index 00000000000..7681e00fcdb
--- /dev/null
+++ b/news/13168.doc.rst
@@ -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.
diff --git a/noxfile.py b/noxfile.py
index 70e24a01142..1df695ea3b7 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -146,6 +146,8 @@ def get_sphinx_build_command(kind: str) -> List[str]:
return [
"sphinx-build",
"--keep-going",
+ "--tag",
+ kind,
"-W",
"-c", "docs/html", # see note above
"-d", "docs/build/doctrees/" + kind,