mirror of
https://github.com/vyos/vyos-documentation.git
synced 2025-10-26 08:41:46 +01:00
sphinx: implement latex layout
This commit is contained in:
parent
fa0a2ec10c
commit
d2159df647
@ -19,16 +19,22 @@ def setup(app):
|
|||||||
app.add_node(
|
app.add_node(
|
||||||
inlinecmd,
|
inlinecmd,
|
||||||
html=(inlinecmd.visit_span, inlinecmd.depart_span),
|
html=(inlinecmd.visit_span, inlinecmd.depart_span),
|
||||||
latex=(inlinecmd.tex, inlinecmd.tex),
|
latex=(inlinecmd.visit_tex, inlinecmd.depart_tex),
|
||||||
text=(inlinecmd.visit_span, inlinecmd.depart_span)
|
text=(inlinecmd.visit_span, inlinecmd.depart_span)
|
||||||
)
|
)
|
||||||
|
|
||||||
app.add_node(
|
app.add_node(
|
||||||
CmdDiv,
|
CmdDiv,
|
||||||
html=(CmdDiv.visit_div, CmdDiv.depart_div),
|
html=(CmdDiv.visit_div, CmdDiv.depart_div),
|
||||||
latex=(CmdDiv.tex, CmdDiv.tex),
|
latex=(CmdDiv.visit_tex, CmdDiv.depart_tex),
|
||||||
text=(CmdDiv.visit_div, CmdDiv.depart_div)
|
text=(CmdDiv.visit_div, CmdDiv.depart_div)
|
||||||
)
|
)
|
||||||
|
app.add_node(
|
||||||
|
CmdBody,
|
||||||
|
html=(CmdBody.visit_div, CmdBody.depart_div),
|
||||||
|
latex=(CmdBody.visit_tex, CmdBody.depart_tex),
|
||||||
|
text=(CmdBody.visit_div, CmdBody.depart_div)
|
||||||
|
)
|
||||||
app.add_node(
|
app.add_node(
|
||||||
CmdHeader,
|
CmdHeader,
|
||||||
html=(CmdHeader.visit_div, CmdHeader.depart_div),
|
html=(CmdHeader.visit_div, CmdHeader.depart_div),
|
||||||
@ -88,6 +94,38 @@ class CmdDiv(nodes.General, nodes.Element):
|
|||||||
def tex(self, node=None):
|
def tex(self, node=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def visit_tex(self, node=None):
|
||||||
|
self.body.append('\n\n\\begin{changemargin}{0cm}{0cm}\n')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def depart_tex(self, node=None):
|
||||||
|
self.body.append('\n\\end{changemargin}\n\n')
|
||||||
|
|
||||||
|
class CmdBody(nodes.General, nodes.Element):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def visit_div(self, node):
|
||||||
|
self.body.append(self.starttag(node, 'div'))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def depart_div(self, node=None):
|
||||||
|
self.body.append('</div>\n')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def visit_tex(self, node=None):
|
||||||
|
self.body.append('\n\n\\begin{changemargin}{0.5cm}{0.5cm}\n')
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def depart_tex(self, node=None):
|
||||||
|
self.body.append('\n\\end{changemargin}\n\n')
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tex(self, node=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class inlinecmd(nodes.inline):
|
class inlinecmd(nodes.inline):
|
||||||
|
|
||||||
@ -100,14 +138,14 @@ class inlinecmd(nodes.inline):
|
|||||||
self.body.append('</span>\n')
|
self.body.append('</span>\n')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tex(self, node=None):
|
def visit_tex(self, node=None):
|
||||||
print('=====================')
|
self.body.append(r'\sphinxbfcode{\sphinxupquote{')
|
||||||
#print(json.dumps(dir(self)))
|
#self.literal_whitespace += 1
|
||||||
print('---------------------')
|
|
||||||
print((self.visit_inline))
|
@staticmethod
|
||||||
exit()
|
def depart_tex(self, node=None):
|
||||||
#self.body.append('\\chapter')
|
self.body.append(r'}}')
|
||||||
pass
|
#self.literal_whitespace -= 1
|
||||||
|
|
||||||
|
|
||||||
class CfgcmdlistDirective(Directive):
|
class CfgcmdlistDirective(Directive):
|
||||||
@ -185,7 +223,7 @@ class CmdDirective(SphinxDirective):
|
|||||||
self.env.vyos_cfgcmd.append(append_list)
|
self.env.vyos_cfgcmd.append(append_list)
|
||||||
|
|
||||||
if has_body:
|
if has_body:
|
||||||
body_element = CmdDiv(content_text)
|
body_element = CmdBody(content_text)
|
||||||
self.state.nested_parse(
|
self.state.nested_parse(
|
||||||
content_list,
|
content_list,
|
||||||
self.content_offset,
|
self.content_offset,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user