diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-02 22:03:28 +0300 |
|---|---|---|
| committer | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-06 16:18:03 +0300 |
| commit | 761c48779951605dbbce5345478c399b5793ae20 (patch) | |
| tree | b0ed1dd73b407c93ed87fa01625bbce68f0149a1 /docs/_ext | |
| parent | 4860ea124619eab6612a7f24db7772ef08fbaec8 (diff) | |
| download | vyos-documentation-761c48779951605dbbce5345478c399b5793ae20.tar.gz vyos-documentation-761c48779951605dbbce5345478c399b5793ae20.zip | |
fix(ext): handle RST fallback in CmdInclude when _renderer absent
`cmdincludemd` is in `myst_fence_as_directive`, so MyST routes
fence blocks through `render_fence → render_restructuredtext →
MockRSTParser`. In that path `self.state` is a plain docutils Body
with no `_renderer`, crashing the build.
Fall back to `nested_parse` when `_renderer` is unavailable so the
directive works in both MyST and RST/MockRSTParser contexts.
🤖 Generated by [robots](https://vyos.io)
Diffstat (limited to 'docs/_ext')
| -rw-r--r-- | docs/_ext/vyos.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/docs/_ext/vyos.py b/docs/_ext/vyos.py index 2f4dede9..527178d1 100644 --- a/docs/_ext/vyos.py +++ b/docs/_ext/vyos.py @@ -364,8 +364,18 @@ class CmdInclude(SphinxDirective): line = re.sub('{{\s?var' + str(i) + '\s?}}',value,line) new_include_lines.append(line) - self.state._renderer.nested_render_text(''.join(new_include_lines), self.lineno) - return [] + if hasattr(self.state, '_renderer'): + self.state._renderer.nested_render_text(''.join(new_include_lines), self.lineno) + return [] + from docutils.statemachine import ViewList + from docutils import nodes + content = ''.join(new_include_lines) + vl = ViewList() + for i, line in enumerate(content.splitlines(keepends=False)): + vl.append(line, include_file[1], i) + node = nodes.Element() + self.state.nested_parse(vl, self.content_offset, node, match_titles=True) + return node.children class CfgcmdlistDirective(Directive): |
