Debian Codegraph @

docs/source/local_customization.py

raw
1 from __future__ import annotations
2
3 from typing import TYPE_CHECKING
4
5 from docutils.parsers.rst import directives as directives
6 from sphinx import addnodes
7 from sphinx.domains.python import PyClasslike
8 from sphinx.ext.autodoc import (
9 ClassLevelDocumenter as ClassLevelDocumenter,
10 FunctionDocumenter as FunctionDocumenter,
11 MethodDocumenter as MethodDocumenter,
12 Options as Options,
13 )
14
15 if TYPE_CHECKING:
16 from sphinx.addnodes import desc_signature
17 from sphinx.application import Sphinx
18
19 """
20
21 .. interface:: The nursery interface
22
23 .. attribute:: blahblah
24
25 """
26
27
28 class Interface(PyClasslike):
29 def handle_signature(self, sig: str, signode: desc_signature) -> tuple[str, str]:
30 signode += addnodes.desc_name(sig, sig)
31 return sig, ""
32
33 def get_index_text(self, modname: str, name_cls: tuple[str, str]) -> str:
34 return f"{name_cls[0]} (interface in {modname})"
35
36
37 def setup(app: Sphinx) -> None:
38 app.add_directive_to_domain("py", "interface", Interface)