Skip to content

Commit 14694d4

Browse files
authored
Make sphinx.ext.autodoc._directive private (#14090)
1 parent 0170148 commit 14694d4

File tree

4 files changed

+4
-29
lines changed

4 files changed

+4
-29
lines changed

sphinx/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ def add_autodocumenter(self, cls: type[Documenter], override: bool = False) -> N
16271627
Add *override* keyword.
16281628
"""
16291629
logger.debug('[app] adding autodocumenter: %r', cls)
1630-
from sphinx.ext.autodoc.directive import AutodocDirective
1630+
from sphinx.ext.autodoc._directive import AutodocDirective
16311631

16321632
objtype = cls.objtype # type: ignore[attr-defined]
16331633
self.registry.add_documenter(objtype, cls)

sphinx/ext/autodoc/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import sphinx
1313
from sphinx.config import ENUM
14+
from sphinx.ext.autodoc._directive import AutodocDirective
1415
from sphinx.ext.autodoc._directive_options import (
15-
Options,
1616
annotation_option,
1717
bool_option,
1818
class_doc_from_option,
@@ -29,7 +29,6 @@
2929
from sphinx.ext.autodoc._sentinels import ALL, EMPTY, SUPPRESS, UNINITIALIZED_ATTR
3030
from sphinx.ext.autodoc._sentinels import INSTANCE_ATTR as INSTANCEATTR
3131
from sphinx.ext.autodoc._sentinels import SLOTS_ATTR as SLOTSATTR
32-
from sphinx.ext.autodoc.directive import AutodocDirective
3332
from sphinx.ext.autodoc.typehints import _merge_typehints
3433

3534
if TYPE_CHECKING:
@@ -44,7 +43,7 @@
4443
# This class is only used in ``sphinx.ext.autodoc.directive``,
4544
# but we export it here for compatibility.
4645
# See: https://github.com/sphinx-doc/sphinx/issues/4538
47-
'Options',
46+
# 'Options',
4847
# Option spec functions.
4948
# Exported for compatibility.
5049
'annotation_option',

sphinx/ext/autodoc/directive.py renamed to sphinx/ext/autodoc/_directive.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from sphinx.ext.autodoc._property_types import _AutodocObjType
2222

23-
2423
logger = logging.getLogger(__name__)
2524

2625

@@ -64,14 +63,7 @@ class AutodocDirective(SphinxDirective):
6463
final_argument_whitespace = True
6564

6665
def run(self) -> list[Node]:
67-
reporter = self.state.document.reporter
68-
69-
try:
70-
source, lineno = reporter.get_source_and_line( # type: ignore[attr-defined]
71-
self.lineno
72-
)
73-
except AttributeError:
74-
source, lineno = (None, None)
66+
source, lineno = self.get_source_info()
7567
logger.debug('[autodoc] %s:%s: input:\n%s', source, lineno, self.block_text)
7668

7769
# get target object type / strip prefix (auto-)

sphinx/ext/autodoc/_directive_options.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,6 @@ def merge_members_option(options: dict[str, Any]) -> None:
169169
members.append(member)
170170

171171

172-
class Options(dict[str, object]): # NoQA: FURB189
173-
"""A dict/attribute hybrid that returns None on nonexisting keys."""
174-
175-
def __repr__(self) -> str:
176-
return f'Options({super().__repr__()})'
177-
178-
def copy(self) -> Options:
179-
return Options(super().copy())
180-
181-
def __getattr__(self, name: str) -> Any:
182-
try:
183-
return self[name.replace('_', '-')]
184-
except KeyError:
185-
return None
186-
187-
188172
_OPTION_SPEC_COMMON: Final[OptionSpec] = {
189173
'no-index': bool_option,
190174
'no-index-entry': bool_option,

0 commit comments

Comments
 (0)