From 1adbbce97d5926abfcc8612b03cbddf60c5939a9 Mon Sep 17 00:00:00 2001 From: Frank Sachsenheim Date: Thu, 28 Dec 2023 18:43:18 +0100 Subject: [PATCH] docs: Improves presentation of NamedTuple subclasses --- docs/api/querying.rst | 1 + docs/api/typing.rst | 1 + docs/conf.py | 1 + docs/sphinx-extensions/namedtuples.py | 12 ++++++++++++ 4 files changed, 15 insertions(+) create mode 100644 docs/sphinx-extensions/namedtuples.py diff --git a/docs/api/querying.rst b/docs/api/querying.rst index f9940ec..78aec20 100644 --- a/docs/api/querying.rst +++ b/docs/api/querying.rst @@ -4,3 +4,4 @@ Queries with XPath & CSS ======================== .. automodule:: _delb.xpath + :no-inherited-members: diff --git a/docs/api/typing.rst b/docs/api/typing.rst index 8b8b3a8..0776d91 100644 --- a/docs/api/typing.rst +++ b/docs/api/typing.rst @@ -39,3 +39,4 @@ Methods that add nodes to a tree take a variety of input data: Definitions that are used for convenient tree building are held in: .. autoclass:: _delb.nodes._TagDefinition + :no-inherited-members: diff --git a/docs/conf.py b/docs/conf.py index 992b2ac..2791023 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,6 +40,7 @@ extensions = [ # in sphinx-extensions "class_members_categories", + "namedtuples", # from the cheeseshop "autodocsumm", "sphinx_copybutton", diff --git a/docs/sphinx-extensions/namedtuples.py b/docs/sphinx-extensions/namedtuples.py new file mode 100644 index 0000000..e6fd5f6 --- /dev/null +++ b/docs/sphinx-extensions/namedtuples.py @@ -0,0 +1,12 @@ +def setup(app): + app.connect("autodoc-process-docstring", namedtuple_strip_alias_reference) + return { + "version": "0.1", + "parallel_read_safe": True, + "parallel_write_safe": True, + } + + +def namedtuple_strip_alias_reference(app, what, name, obj, options, lines): + if lines and lines[0].startswith("Alias for field number "): + lines.clear()