summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/_ext/vyos.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/docs/_ext/vyos.py b/docs/_ext/vyos.py
index 667f2777..ff30ef3c 100644
--- a/docs/_ext/vyos.py
+++ b/docs/_ext/vyos.py
@@ -77,6 +77,7 @@ def setup(app):
app.add_directive('cfgcmd', CfgCmdDirective)
app.add_directive('opcmd', OpCmdDirective)
app.add_directive('cmdinclude', CfgInclude)
+ app.add_directive('cmdincludemd', CmdInclude)
app.connect('doctree-resolved', process_cmd_nodes)
app.connect('doctree-read', handle_document_meta_data)
@@ -319,6 +320,47 @@ class CfgInclude(SphinxDirective):
self.state_machine.insert_input(new_include_lines, path)
return []
+class CmdInclude(SphinxDirective):
+ '''
+ 2nd CMDInclude only for Markdown, just the migration process
+ '''
+
+ has_content = False
+ required_arguments = 1
+ optional_arguments = 0
+ option_spec = {
+ 'var0': str,
+ 'var1': str,
+ 'var2': str,
+ 'var3': str,
+ 'var4': str,
+ 'var5': str,
+ 'var6': str,
+ 'var7': str,
+ 'var8': str,
+ 'var9': str
+ }
+
+ def run(self):
+ include_file = self.env.relfn2path(self.arguments[0])
+
+ f = open(include_file[1], "r")
+ file_content = f.readlines()
+ f.close()
+
+ new_include_lines = []
+ for line in file_content:
+ for i in range(10):
+ value = self.options.get(f'var{i}','')
+ if value == '':
+ line = re.sub('\s?{{\s?var' + str(i) + '\s?}}',value,line)
+ else:
+ 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 []
+
class CfgcmdlistDirective(Directive):
has_content = False