Skip to content

Commit

Permalink
Use tags in docs building to split up requirements
Browse files Browse the repository at this point in the history
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: pypa#12900 [1]
Link: pypa#12881 [2]
  • Loading branch information
matthewhughes934 committed Jan 15, 2025
1 parent 8018643 commit c3c3cf3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
32 changes: 20 additions & 12 deletions docs/html/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,30 @@
sys.path.insert(0, docs_dir)

# -- General configuration ------------------------------------------------------------

extensions = [
# first-party extensions
"sphinx.ext.autodoc",
"sphinx.ext.todo",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
# our extensions
# extensions common to 'man' and 'html' builds
"pip_sphinxext",
# third-party extensions
"myst_parser",
"sphinx_copybutton",
"sphinx_inline_tabs",
"sphinxcontrib.towncrier",
]

# 'tags' is a special object handled by sphinx
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-tags
if "html" in tags: # type: ignore[name-defined] # noqa: F821
# html specific deps
extensions.extend(
(
# first-party extensions
"sphinx.ext.autodoc",
"sphinx.ext.todo",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
# third-party extensions
"myst_parser",
"sphinx_copybutton",
"sphinx_inline_tabs",
"sphinxcontrib.towncrier",
),
)

# General information about the project.
project = "pip"
copyright = "The pip developers"
Expand Down
2 changes: 2 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c3c3cf3

Please sign in to comment.