Skip to content

Commit 16284bd

Browse files
committed
Remove property prefix annotation from properties so that they appear as attributes in docs
1 parent ee4835d commit 16284bd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/conf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import sys
88
import os
99
import sphinx.ext.autodoc
10+
import sphinx.transforms
11+
import docutils.nodes
1012

1113
# --- Pre-processing Tasks
1214

@@ -267,10 +269,23 @@ def add_directive_header(self, sig: str) -> None:
267269
strings.pop()
268270
return r
269271

272+
class Transform(sphinx.transforms.SphinxTransform):
273+
default_priority = 800
274+
def apply(self):
275+
self.document.walk(Visitor(self.document))
276+
class Visitor(docutils.nodes.SparseNodeVisitor):
277+
def visit_desc_annotation(self, node):
278+
# Remove `property` prefix from properties so they look the same as
279+
# attributes
280+
if 'property' in node.astext():
281+
node.parent.remove(node)
282+
283+
270284
def setup(app):
271285
app.add_css_file("css/custom.css")
272286
app.add_autodocumenter(ClassDocumenter)
273287
app.connect('source-read', source_read)
274288
app.connect('build-finished', post_process)
275289
app.connect("autodoc-process-docstring", warn_undocumented_members)
276290
app.connect('autodoc-process-bases', on_autodoc_process_bases)
291+
app.add_transform(Transform)

0 commit comments

Comments
 (0)