Skip to content

DOC: Use pipx as the docs parser program name - #2007

Open
karlhillx wants to merge 2 commits into
pypa:mainfrom
karlhillx:fix/2005-docs-parser-prog
Open

DOC: Use pipx as the docs parser program name#2007
karlhillx wants to merge 2 commits into
pypa:mainfrom
karlhillx:fix/2005-docs-parser-prog

Conversation

@karlhillx

Copy link
Copy Markdown

Closes #2005.

The docs build renders the CLI reference from build_parser(), which derives
the program name from sys.argv[0] via prog_name(). During the Sphinx build
that value is sphinx-build, so the generated run subparser is named
sphinx-build run instead of pipx run.

Let get_command_parser() accept an explicit prog and have build_parser()
pass prog="pipx", so the docs parser is always named pipx regardless of
sys.argv[0]. Add a regression test asserting both the root and nested
subparser program names, plus a changelog.d/2005.doc.md fragment.

Copilot AI lite review requested due to automatic review settings August 15, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the generated CLI reference in the Sphinx docs so it consistently shows pipx as the program name (instead of inheriting sys.argv[0] like sphinx-build during documentation builds).

Changes:

  • Adds an optional prog override to get_command_parser() and uses it in build_parser() to force prog="pipx" for docs generation.
  • Adds a regression test asserting both the root parser prog and the nested run subparser prog.
  • Adds a changelog fragment documenting the docs output fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/pipx/main.py Allows explicitly overriding the argparse prog and forces pipx for the docs parser returned by build_parser().
tests/test_main.py Adds a regression test ensuring docs parser naming stays pipx even when sys.argv[0] is sphinx-build.
changelog.d/2005.doc.md Documents the CLI reference output correction in the changelog fragments.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/pipx/main.py
Comment on lines 1761 to 1764
parser = argparse.ArgumentParser(
prog=prog_name(),
prog=prog or prog_name(),
formatter_class=LineWrapRawTextHelpFormatter,
description=PIPX_DESCRIPTION,
Comment thread tests/test_main.py Outdated
Comment on lines +76 to +78
assert parser.prog == "pipx"
subparsers = next(a for a in parser._actions if isinstance(a, argparse._SubParsersAction))
assert subparsers.choices["run"].prog == "pipx run"
@karlhillx
karlhillx force-pushed the fix/2005-docs-parser-prog branch from 1b55b75 to 1fb5dc3 Compare August 15, 2026 12:21
build_parser() derives the program name from sys.argv[0] via prog_name(),
which is sphinx-build during the docs build, so the generated run subparser
is named 'sphinx-build run'. Let get_command_parser() accept an explicit
prog and have build_parser() pass prog="pipx". Closes pypa#2005.
@karlhillx
karlhillx force-pushed the fix/2005-docs-parser-prog branch from bf541b3 to 1a5d504 Compare August 15, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doc for pipx run uses sphinx-build as script name

2 participants