mirror of
https://github.com/vyos/vyos-documentation.git
synced 2025-10-26 08:41:46 +01:00
Sphinx: prepare tex layout
This commit is contained in:
parent
e983a8dabc
commit
faf67e43df
@ -11,19 +11,28 @@ def setup(app):
|
|||||||
'https://phabricator.vyos.net/', ''
|
'https://phabricator.vyos.net/', ''
|
||||||
)
|
)
|
||||||
app.add_role('vytask', vytask_role)
|
app.add_role('vytask', vytask_role)
|
||||||
|
app.add_role('cfgcmd', cmd_role)
|
||||||
|
app.add_role('opcmd', cmd_role)
|
||||||
|
|
||||||
print(app.config.vyos_phabricator_url)
|
print(app.config.vyos_phabricator_url)
|
||||||
|
|
||||||
|
app.add_node(
|
||||||
|
inlinecmd,
|
||||||
|
html=(inlinecmd.visit_span, inlinecmd.depart_span),
|
||||||
|
latex=(inlinecmd.tex, inlinecmd.tex),
|
||||||
|
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.visit_div, CmdDiv.depart_div),
|
latex=(CmdDiv.tex, CmdDiv.tex),
|
||||||
text=(CmdDiv.visit_div, CmdDiv.depart_div)
|
text=(CmdDiv.visit_div, CmdDiv.depart_div)
|
||||||
)
|
)
|
||||||
app.add_node(
|
app.add_node(
|
||||||
CmdHeader,
|
CmdHeader,
|
||||||
html=(CmdHeader.visit_div, CmdHeader.depart_div),
|
html=(CmdHeader.visit_div, CmdHeader.depart_div),
|
||||||
latex=(CmdHeader.visit_div, CmdHeader.depart_div),
|
latex=(CmdHeader.tex, CmdHeader.tex),
|
||||||
text=(CmdHeader.visit_div, CmdHeader.depart_div)
|
text=(CmdHeader.visit_div, CmdHeader.depart_div)
|
||||||
)
|
)
|
||||||
app.add_node(CfgcmdList)
|
app.add_node(CfgcmdList)
|
||||||
@ -44,6 +53,7 @@ class CfgcmdList(nodes.General, nodes.Element):
|
|||||||
class OpcmdList(nodes.General, nodes.Element):
|
class OpcmdList(nodes.General, nodes.Element):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
class CmdHeader(nodes.General, nodes.Element):
|
class CmdHeader(nodes.General, nodes.Element):
|
||||||
|
|
||||||
@ -53,7 +63,15 @@ class CmdHeader(nodes.General, nodes.Element):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def depart_div(self, node=None):
|
def depart_div(self, node=None):
|
||||||
self.body.append('</div>\n')
|
# self.body.append('</div>\n')
|
||||||
|
self.body.append('<a class="cmdlink" href="#%s" ' %
|
||||||
|
node.children[0]['refid'] +
|
||||||
|
'title="%s"></a></div>' % (
|
||||||
|
'Permalink to this Command'))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tex(self, node=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CmdDiv(nodes.General, nodes.Element):
|
class CmdDiv(nodes.General, nodes.Element):
|
||||||
@ -66,6 +84,31 @@ class CmdDiv(nodes.General, nodes.Element):
|
|||||||
def depart_div(self, node=None):
|
def depart_div(self, node=None):
|
||||||
self.body.append('</div>\n')
|
self.body.append('</div>\n')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tex(self, node=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class inlinecmd(nodes.inline):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def visit_span(self, node):
|
||||||
|
self.body.append(self.starttag(node, 'span'))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def depart_span(self, node=None):
|
||||||
|
self.body.append('</span>\n')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tex(self, node=None):
|
||||||
|
print('=====================')
|
||||||
|
#print(json.dumps(dir(self)))
|
||||||
|
print('---------------------')
|
||||||
|
print((self.visit_inline))
|
||||||
|
exit()
|
||||||
|
#self.body.append('\\chapter')
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CfgcmdlistDirective(Directive):
|
class CfgcmdlistDirective(Directive):
|
||||||
|
|
||||||
@ -114,7 +157,7 @@ class CmdDirective(SphinxDirective):
|
|||||||
title_nodes, messages = self.state.inline_text(title_text,
|
title_nodes, messages = self.state.inline_text(title_text,
|
||||||
self.lineno)
|
self.lineno)
|
||||||
|
|
||||||
title = nodes.inline(title_text, '', *title_nodes)
|
title = inlinecmd(title_text, '', *title_nodes)
|
||||||
target['classes'] += []
|
target['classes'] += []
|
||||||
title['classes'] += [cfgmode]
|
title['classes'] += [cfgmode]
|
||||||
heading_element.append(target)
|
heading_element.append(target)
|
||||||
@ -202,3 +245,8 @@ def vytask_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|||||||
node = nodes.reference(
|
node = nodes.reference(
|
||||||
rawtext, utils.unescape(str(text)), refuri=ref, **options)
|
rawtext, utils.unescape(str(text)), refuri=ref, **options)
|
||||||
return [node], []
|
return [node], []
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
|
node = nodes.literal(text, text)
|
||||||
|
return [node], []
|
||||||
|
|||||||
18
docs/_static/css/custom.css
vendored
18
docs/_static/css/custom.css
vendored
@ -12,7 +12,7 @@ span.cfgcmd {
|
|||||||
|
|
||||||
.opcmd-heading,
|
.opcmd-heading,
|
||||||
.cfgcmd-heading {
|
.cfgcmd-heading {
|
||||||
display: block;
|
display: inline-block;
|
||||||
margin: 6px 0;
|
margin: 6px 0;
|
||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
@ -32,8 +32,24 @@ span.cfgcmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.cfgcmd-heading .cmdlink:after,
|
||||||
|
.opcmd-heading .cmdlink:after {
|
||||||
|
content: "";
|
||||||
|
font-family: FontAwesome
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.cfgcmd-heading:not(:hover) .cmdlink,
|
||||||
|
.opcmd-heading:not(:hover) .cmdlink {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
a.cmdlink {
|
a.cmdlink {
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wy-nav-content {
|
.wy-nav-content {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user