From 3e1b572fee36f8dd21a8afa0459da630461d2f63 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 13 Aug 2024 17:24:37 +1000 Subject: [PATCH] Document attributes, signals (#157) Requires https://github.com/qgis/QGIS/pull/58372 --- process_links.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/process_links.py b/process_links.py index 7f770fd5986c..1e3c3adc60dc 100644 --- a/process_links.py +++ b/process_links.py @@ -13,6 +13,23 @@ with open("pyqgis_conf.yml") as f: cfg = yaml.safe_load(f) +from sphinx.ext.autodoc import Documenter +old_get_doc = Documenter.get_doc + + +def new_get_doc(self) -> list[list[str]] | None: + try: + if self.object_name in self.parent.__attribute_docs__: + docs = self.parent.__attribute_docs__[self.object_name] + return [docs.split('\n')] + except AttributeError: + pass + + return old_get_doc(self) + + +Documenter.get_doc = new_get_doc + # https://github.com/sphinx-doc/sphinx/blob/685e3fdb49c42b464e09ec955e1033e2a8729fff/sphinx/ext/autodoc/__init__.py#L51 # adapted to handle signals