apidoc: Move ApidocOptions to `sphinx.ext.apidoc._shared`

This commit is contained in:
Adam Turner 2025-01-10 02:10:40 +00:00
parent d42cfa702f
commit 95df419f49
3 changed files with 40 additions and 41 deletions

View File

@ -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

View File

@ -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

View File

@ -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