diff --git a/sphinx/ext/apidoc/_cli.py b/sphinx/ext/apidoc/_cli.py index e13b915a1..09645b3db 100644 --- a/sphinx/ext/apidoc/_cli.py +++ b/sphinx/ext/apidoc/_cli.py @@ -13,12 +13,8 @@ from typing import TYPE_CHECKING, Any import sphinx.locale from sphinx import __display_version__ from sphinx.cmd.quickstart import EXTENSIONS -from sphinx.ext.apidoc._generate import ( - ApidocOptions, - create_modules_toc_file, - recurse_tree, -) -from sphinx.ext.apidoc._shared import LOGGER, _remove_old_files +from sphinx.ext.apidoc._generate import create_modules_toc_file, recurse_tree +from sphinx.ext.apidoc._shared import LOGGER, ApidocOptions, _remove_old_files from sphinx.locale import __ from sphinx.util.osutil import ensuredir diff --git a/sphinx/ext/apidoc/_generate.py b/sphinx/ext/apidoc/_generate.py index e43b698ee..00701cee3 100644 --- a/sphinx/ext/apidoc/_generate.py +++ b/sphinx/ext/apidoc/_generate.py @@ -1,6 +1,5 @@ from __future__ import annotations -import dataclasses import glob import os import os.path @@ -18,6 +17,8 @@ if TYPE_CHECKING: import re from collections.abc import Iterator, Sequence + from sphinx.ext.apidoc._shared import ApidocOptions + # automodule options if 'SPHINX_APIDOC_OPTIONS' in os.environ: @@ -349,37 +350,3 @@ def is_excluded(root: str | Path, excludes: Sequence[re.Pattern[str]]) -> bool: """ root_str = str(root) return any(exclude.match(root_str) for exclude in excludes) - - -@dataclasses.dataclass(frozen=True, kw_only=True, slots=True) -class ApidocOptions: - """Options for apidoc.""" - - module_path: Path - exclude_pattern: list[str] - destdir: Path - quiet: bool = False - maxdepth: int = 4 - force: bool = False - followlinks: bool = False - dryrun: bool = False - separatemodules: bool = False - includeprivate: bool = False - tocfile: str = 'modules' - noheadings: bool = False - modulefirst: bool = False - implicit_namespaces: bool = False - automodule_options: set[str] = dataclasses.field(default_factory=set) - suffix: str = 'rst' - - remove_old: bool = False - - # --full only - full: bool = False - append_syspath: bool = False - header: str = '' - author: str | None = None - version: str | None = None - release: str | None = None - extensions: list[str] | None = None - templatedir: str | None = None diff --git a/sphinx/ext/apidoc/_shared.py b/sphinx/ext/apidoc/_shared.py index 7489f9d3e..2473e65d3 100644 --- a/sphinx/ext/apidoc/_shared.py +++ b/sphinx/ext/apidoc/_shared.py @@ -1,5 +1,6 @@ from __future__ import annotations +import dataclasses from typing import TYPE_CHECKING from sphinx.locale import __ @@ -28,3 +29,38 @@ def _remove_old_files( exc.strerror, type='autodoc', ) + + +@dataclasses.dataclass(frozen=True, kw_only=True, slots=True) +class ApidocOptions: + """Options for apidoc.""" + + module_path: Path + destdir: Path + + exclude_pattern: Sequence[str] = () + quiet: bool = False + maxdepth: int = 4 + force: bool = False + followlinks: bool = False + dryrun: bool = False + separatemodules: bool = False + includeprivate: bool = False + tocfile: str = 'modules' + noheadings: bool = False + modulefirst: bool = False + implicit_namespaces: bool = False + automodule_options: set[str] = dataclasses.field(default_factory=set) + suffix: str = 'rst' + + remove_old: bool = False + + # --full only + full: bool = False + append_syspath: bool = False + header: str = '' + author: str | None = None + version: str | None = None + release: str | None = None + extensions: Sequence[str] | None = None + templatedir: str | None = None