Skip to content

Commit 847f814

Browse files
committed
🎨 Prepend NodeBlockFunction to the name of NodeBlockFunctions
1 parent 39ad79b commit 847f814

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

docs/_sources/autodoc_nodeblock.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,32 @@
55

66

77
class NBFMixin(Documenter):
8-
def format_name(self) -> str:
9-
"""Prepend "NodeBlockFunction" to the name"""
10-
return f'NodeBlockFunction: {super().format_name()}'
8+
def add_directive_header(self, sig: str) -> None:
9+
"""Prepend "NodeBlockFunction" to the name & add the directive
10+
header and options to the generated content."""
11+
domain = getattr(self, 'domain', 'py')
12+
directive = getattr(self, 'directivetype', self.objtype)
13+
name = self.format_name()
14+
sourcename = self.get_sourcename()
15+
16+
# Prepend NodeBlockFunction pseudoheader
17+
self.add_line(f'*NodeBlockFunction*: **{self.object.name}**',
18+
sourcename)
19+
self.add_line('', sourcename)
20+
# one signature per line, indented by column
21+
prefix = f'.. {domain}:{directive}:: '
22+
for i, sig_line in enumerate(sig.split("\n")):
23+
self.add_line(f'{prefix}{name}{sig_line}',
24+
sourcename)
25+
if i == 0:
26+
prefix = " " * len(prefix)
27+
28+
if self.options.no_index or self.options.noindex:
29+
self.add_line(' :no-index:', sourcename)
30+
if self.objpath:
31+
# Be explicit about the module, this is necessary since .. class::
32+
# etc. don't support a prepended module name
33+
self.add_line(' :module: %s' % self.modname, sourcename)
1134

1235

1336
class NodeBlockFunctionDocumenter(NBFMixin, FunctionDocumenter):

docs/_sources/conf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,5 @@ def initialize_factory() -> None:
650650

651651
def setup(app) -> None:
652652
"""Extend Sphinx"""
653-
# Node Block Function customizations
654-
# app.setup_extension('sphinx.directives')
655-
# app.add_autodocumenter(DocumentNodeBlockFunction)
656653
# modify docstrings before parsing RST
657654
app.connect('autodoc-process-docstring', autodoc_process_docstring)

0 commit comments

Comments
 (0)