confluencebuilder
confluencebuilder copied to clipboard
An official way to add extra Confluence nodes
Right now it looks like you can add extra nodes without modifying the extension, but it depends on private methods of the translator.
Example for the panel macro:
from docutils import nodes
from sphinxcontrib.confluencebuilder.storage.translator import (
ConfluenceStorageFormatTranslator,
)
def setup(app: Sphinx):
app.add_node(
confluence_panel,
confluence=(visit_confluence_panel, depart_confluence_panel),
)
class confluence_panel(nodes.General, nodes.Element):
pass
def visit_confluence_panel(
self: ConfluenceStorageFormatTranslator, node: confluence_panel
):
self.body.append(self._start_ac_macro(node, "panel"))
if "title" in node:
self.body.append(self._build_ac_param(node, "title", node["title"]))
self.body.append(self._start_ac_rich_text_body_macro(node))
self.context.append(
self._end_ac_rich_text_body_macro(node) + self._end_ac_macro(node)
)
def depart_confluence_panel(
self: ConfluenceStorageFormatTranslator, node: confluence_panel
):
self.body.append(self.context.pop())
Is there a better way to do this?