Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx/_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _SubcommandModule(Protocol):


# Map of command name to import path.
_COMMANDS: dict[str, str] = {}
_COMMANDS: dict[str, str] = {'quickstart': 'sphinx.cmd._quickstart'}


def _load_subcommand_descriptions() -> Iterator[tuple[str, str]]:
Expand Down
24 changes: 24 additions & 0 deletions sphinx/cmd/_quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""The module implementing the subcommand ``sphinx quickstart``.

This delegates everything to the module :mod:`sphinx.cmd.quickstart`, which
is the implementation for the historic standalone ``sphinx-quickstart`` command.
"""

from __future__ import annotations

from typing import TYPE_CHECKING

from . import quickstart

if TYPE_CHECKING:
import argparse

parser_description = quickstart.COMMAND_DESCRIPTION.lstrip()


def set_up_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
return quickstart.set_up_parser(parser)


def run(args: argparse.Namespace) -> int:
return quickstart.run(args)
26 changes: 17 additions & 9 deletions sphinx/cmd/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
else:
readline.parse_and_bind('tab: complete')

COMMAND_DESCRIPTION = __(
'\n'
'Generate required files for a Sphinx project.\n'
'\n'
'sphinx-quickstart is an interactive tool that asks some questions about your\n'
'project and then generates a complete documentation directory and sample\n'
'Makefile to be used with sphinx-build.\n',
)

EXTENSIONS = {
'autodoc': __('automatically insert docstrings from modules'),
'doctest': __('automatically test code snippets in doctest blocks'),
Expand Down Expand Up @@ -569,20 +578,15 @@ def valid_dir(d: dict[str, Any]) -> bool:


def get_parser() -> argparse.ArgumentParser:
description = __(
'\n'
'Generate required files for a Sphinx project.\n'
'\n'
'sphinx-quickstart is an interactive tool that asks some questions about your\n'
'project and then generates a complete documentation directory and sample\n'
'Makefile to be used with sphinx-build.\n',
)
parser = argparse.ArgumentParser(
usage='%(prog)s [OPTIONS] <PROJECT_DIR>',
epilog=__('For more information, visit <https://www.sphinx-doc.org/>.'),
description=description,
description=str(COMMAND_DESCRIPTION), # str() for resolving TranslationProxy
)
return set_up_parser(parser)


def set_up_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
parser.add_argument(
'-q',
'--quiet',
Expand Down Expand Up @@ -748,6 +752,10 @@ def main(argv: Sequence[str] = (), /) -> int:
except SystemExit as err:
return err.code # type: ignore[return-value]

return run(args)


def run(args: argparse.Namespace) -> int:
d = vars(args)
# delete None or False value
d = {k: v for k, v in d.items() if v is not None}
Expand Down
Loading