Skip to content
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

Add sphinx._cli #10877

Merged
merged 7 commits into from
Apr 29, 2024
Merged

Add sphinx._cli #10877

merged 7 commits into from
Apr 29, 2024

Conversation

AA-Turner
Copy link
Member

@AA-Turner AA-Turner commented Sep 28, 2022

This is the first step towards a new sphinx command.

References: #5618, #6938

I took inspiration from @stephenfin's approach but this is a different tack.

Feature or Bugfix

  • Feature

Sample output

(sphinx) I:\Development\sphinx>python -m sphinx._cli.__init__ --version
sphinx 5.3.0+/ac2a54de9

(sphinx) I:\Development\sphinx>python -m sphinx._cli.__init__ --help    
Usage: sphinx [--version] [--help] [--quiet] <command> [<args>]
                                                               
   Manage documentation with Sphinx.                           
                                                               
Options:                                                       
  --version, -V   Show the version and exit.                   
  --help, -h, -?  Show this message and exit.                  
  --quiet, -q     Only print errors and warnings.

For more information, visit <https://www.sphinx-doc.org/en/master/man/>.

(sphinx) I:\Development\sphinx>

A

@AA-Turner AA-Turner force-pushed the sphinx-cli branch 4 times, most recently from 32a6161 to 24db75c Compare September 28, 2022 10:05
@AA-Turner AA-Turner modified the milestones: 5.3.0, 6.x Oct 13, 2022
@AA-Turner AA-Turner changed the base branch from 5.x to master October 16, 2022 15:26
Copy link

@ashb ashb left a comment

Choose a reason for hiding this comment

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

(I came across this issue due to looking for a way to build multiple sphinx builders in a single command/call)

I'm not sure what Sphinx's policy is on pulling in dependencies, but might it be worth considering some of:

They handle a lot of the "boilerplate" of dealing with arg parsing, subcommads, output and terminal color/encoding etc. (I'm absolutely not trying to bikeshed here)

@stephenfin
Copy link
Contributor

stephenfin commented May 18, 2023

Sample output

(sphinx) I:\Development\sphinx>python -m sphinx._cli.__init__ --version
sphinx 5.3.0+/ac2a54de9

(sphinx) I:\Development\sphinx>python -m sphinx._cli.__init__ --help    
Usage: sphinx [--version] [--help] [--quiet] <command> [<args>]
                                                               
   Manage documentation with Sphinx.                           
                                                               
Options:                                                       
  --version, -V   Show the version and exit.                   
  --help, -h, -?  Show this message and exit.                  
  --quiet, -q     Only print errors and warnings.

For more information, visit <https://www.sphinx-doc.org/en/master/man/>.

(sphinx) I:\Development\sphinx>

Out of curiosity, what's the rational for not providing a sphinx executable? I get that python -m <module-name> is the preferred pattern for something like pip because it helps you understand which version of Python you're running on (per python/cpython#66491), but for a tool like Sphinx the fact that it's written in Python should be irrelevant to anyone bar a Sphinx extension author or Sphinx core developer. Surely an unambiguous sphinx command would be preferable for "normal" people? 😄

sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@stephenfin stephenfin left a comment

Choose a reason for hiding this comment

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

Couple of comments inline

@AA-Turner
Copy link
Member Author

Out of curiosity, what's the rational for not providing a sphinx executable?

This PR is intended to be the first in a series, and just introduces the new CLI infrastructure -- I don't want to provide sphinx before at least the main build command is ready.

A

sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
sphinx/_cli/__init__.py Show resolved Hide resolved
sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
sphinx/_cli/__init__.py Outdated Show resolved Hide resolved
sphinx/_cli/util/colour.py Outdated Show resolved Hide resolved
sphinx/_cli/util/colour.py Show resolved Hide resolved
sphinx/_cli/util/errors.py Outdated Show resolved Hide resolved
sphinx/_cli/util/errors.py Show resolved Hide resolved
sphinx/_cli/util/errors.py Show resolved Hide resolved
@AA-Turner AA-Turner merged commit c41aab8 into sphinx-doc:master Apr 29, 2024
23 checks passed
@AA-Turner AA-Turner deleted the sphinx-cli branch April 29, 2024 02:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants