Skip to content

Commit

Permalink
apidoc: Rename CliOptions to ApidocOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 7, 2025
1 parent 2c117bb commit 8e6883f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions sphinx/ext/apidoc/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from sphinx import __display_version__
from sphinx.cmd.quickstart import EXTENSIONS
from sphinx.ext.apidoc._generate import (
CliOptions,
ApidocOptions,
create_modules_toc_file,
recurse_tree,
)
Expand Down Expand Up @@ -284,7 +284,7 @@ def main(argv: Sequence[str] = (), /) -> int:
return 0


def _parse_args(argv: Sequence[str], /) -> CliOptions:
def _parse_args(argv: Sequence[str], /) -> ApidocOptions:
parser = get_parser()
args = parser.parse_args(argv or sys.argv[1:])

Expand All @@ -308,10 +308,10 @@ def _parse_args(argv: Sequence[str], /) -> CliOptions:
elif isinstance(args.automodule_options, str):
args.automodule_options = set(args.automodule_options.split(','))

return CliOptions(**args.__dict__)
return ApidocOptions(**args.__dict__)


def _full_quickstart(opts: CliOptions, /, *, modules: list[str]) -> None:
def _full_quickstart(opts: ApidocOptions, /, *, modules: list[str]) -> None:
from sphinx.cmd import quickstart as qs

modules.sort()
Expand Down
20 changes: 10 additions & 10 deletions sphinx/ext/apidoc/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def is_packagedir(dirname: str | None = None, files: list[str] | None = None) ->
return any(f for f in files if is_initpy(f))


def write_file(name: str, text: str, opts: CliOptions) -> Path:
def write_file(name: str, text: str, opts: ApidocOptions) -> Path:
"""Write the output file for module/package <name>."""
fname = Path(opts.destdir, f'{name}.{opts.suffix}')
if opts.dryrun:
Expand All @@ -80,7 +80,7 @@ def write_file(name: str, text: str, opts: CliOptions) -> Path:
def create_module_file(
package: str | None,
basename: str,
opts: CliOptions,
opts: ApidocOptions,
user_template_dir: str | None = None,
) -> Path:
"""Build the text of the file and write the file."""
Expand Down Expand Up @@ -108,7 +108,7 @@ def create_package_file(
master_package: str | None,
subroot: str,
py_files: list[str],
opts: CliOptions,
opts: ApidocOptions,
subs: list[str],
is_namespace: bool,
excludes: Sequence[re.Pattern[str]] = (),
Expand Down Expand Up @@ -173,7 +173,7 @@ def create_package_file(

def create_modules_toc_file(
modules: list[str],
opts: CliOptions,
opts: ApidocOptions,
name: str = 'modules',
user_template_dir: str | None = None,
) -> Path:
Expand Down Expand Up @@ -201,7 +201,7 @@ def create_modules_toc_file(


def is_skipped_package(
dirname: str | Path, opts: CliOptions, excludes: Sequence[re.Pattern[str]] = ()
dirname: str | Path, opts: ApidocOptions, excludes: Sequence[re.Pattern[str]] = ()
) -> bool:
"""Check if we want to skip this module."""
if not Path(dirname).is_dir():
Expand All @@ -218,7 +218,7 @@ def is_skipped_package(


def is_skipped_module(
filename: str | Path, opts: CliOptions, _excludes: Sequence[re.Pattern[str]]
filename: str | Path, opts: ApidocOptions, _excludes: Sequence[re.Pattern[str]]
) -> bool:
"""Check if we want to skip this module."""
filename = Path(filename)
Expand All @@ -232,7 +232,7 @@ def is_skipped_module(
def walk(
rootpath: str,
excludes: Sequence[re.Pattern[str]],
opts: CliOptions,
opts: ApidocOptions,
) -> Iterator[tuple[str, list[str], list[str]]]:
"""Walk through the directory and list files and subdirectories up."""
for root, subs, files in os.walk(rootpath, followlinks=opts.followlinks):
Expand Down Expand Up @@ -261,7 +261,7 @@ def walk(


def has_child_module(
rootpath: str, excludes: Sequence[re.Pattern[str]], opts: CliOptions
rootpath: str, excludes: Sequence[re.Pattern[str]], opts: ApidocOptions
) -> bool:
"""Check the given directory contains child module/s (at least one)."""
return any(files for _root, _subs, files in walk(rootpath, excludes, opts))
Expand All @@ -270,7 +270,7 @@ def has_child_module(
def recurse_tree(
rootpath: str | os.PathLike[str],
excludes: Sequence[re.Pattern[str]],
opts: CliOptions,
opts: ApidocOptions,
user_template_dir: str | None = None,
) -> tuple[list[Path], list[str]]:
"""
Expand Down Expand Up @@ -352,7 +352,7 @@ def is_excluded(root: str | Path, excludes: Sequence[re.Pattern[str]]) -> bool:


@dataclasses.dataclass(frozen=True, kw_only=True, slots=True)
class CliOptions:
class ApidocOptions:
"""Options for apidoc."""

module_path: Path
Expand Down

0 comments on commit 8e6883f

Please sign in to comment.