|
5 | 5 |
|
6 | 6 |
|
7 | 7 | 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) |
11 | 34 |
|
12 | 35 |
|
13 | 36 | class NodeBlockFunctionDocumenter(NBFMixin, FunctionDocumenter): |
|
0 commit comments