Skip to content

Commit

Permalink
Only write class toc for class objects
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 19, 2024
1 parent 0ae6b2f commit 8167ccd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
23 changes: 1 addition & 22 deletions rst/qgis_pydoc_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,5 @@ $HEADER_CONTENT
:undoc-members:
:exclude-members: $EXCLUDE_METHODS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:enums:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS
$TABLE_OF_CONTENTS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:methods:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:static_methods:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:signals:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:attributes:
:exclude-members: $EXCLUDE_METHODS
31 changes: 30 additions & 1 deletion scripts/make_api_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,32 @@ def _recursive_substitute(self, **kws):
:parts: 1
"""

class_toc = """
.. autoautosummary:: qgis.$PACKAGE.$CLASS
:enums:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS
.. autoautosummary:: qgis.$PACKAGE.$CLASS
:methods:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS
.. autoautosummary:: qgis.$PACKAGE.$CLASS
:static_methods:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS
.. autoautosummary:: qgis.$PACKAGE.$CLASS
:signals:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS
.. autoautosummary:: qgis.$PACKAGE.$CLASS
:attributes:
:exclude-members: $EXCLUDE_METHODS
"""

MODULE_TOC_MAX_COLUMN_SIZES = [300, 500]


Expand Down Expand Up @@ -271,12 +297,14 @@ def generate_docs():
for class_name, _class in extract_package_classes(package):
exclude_methods = set()
header = ''
toc = ''
for method in dir(_class):
if not hasattr(_class, method):
continue

if inspect.isclass(_class):
header = class_header
toc = class_toc

class_doc = getattr(_class, method).__doc__

Expand Down Expand Up @@ -304,7 +332,8 @@ def generate_docs():
"PACKAGE": package_name,
"CLASS": class_name,
"EXCLUDE_METHODS": ",".join(exclude_methods),
"HEADER_CONTENT": header
"HEADER_CONTENT": header,
"TABLE_OF_CONTENTS": toc
}
class_template = template.substitute(**substitutions)
class_rst = open(f"api/{qgis_version}/{package_name}/{class_name}.rst", "w")
Expand Down

0 comments on commit 8167ccd

Please sign in to comment.