File: local_customization.py

package info (click to toggle)
python-trio 0.29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,920 kB
  • sloc: python: 28,766; sh: 144; makefile: 25
file content (38 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import annotations

from typing import TYPE_CHECKING

from docutils.parsers.rst import directives as directives
from sphinx import addnodes
from sphinx.domains.python import PyClasslike
from sphinx.ext.autodoc import (
    ClassLevelDocumenter as ClassLevelDocumenter,
    FunctionDocumenter as FunctionDocumenter,
    MethodDocumenter as MethodDocumenter,
    Options as Options,
)

if TYPE_CHECKING:
    from sphinx.addnodes import desc_signature
    from sphinx.application import Sphinx

"""

.. interface:: The nursery interface

   .. attribute:: blahblah

"""


class Interface(PyClasslike):
    def handle_signature(self, sig: str, signode: desc_signature) -> tuple[str, str]:
        signode += addnodes.desc_name(sig, sig)
        return sig, ""

    def get_index_text(self, modname: str, name_cls: tuple[str, str]) -> str:
        return f"{name_cls[0]} (interface in {modname})"


def setup(app: Sphinx) -> None:
    app.add_directive_to_domain("py", "interface", Interface)