Skip to content
Snippets Groups Projects
Commit 39b4420f authored by Timo Koch's avatar Timo Koch
Browse files

[examples][docgen] Make it simpler to create toggled content with '[[details]] content'

parent 6454b7d5
No related branches found
No related tags found
1 merge request!1899Feature/improve tracer example
......@@ -65,6 +65,16 @@ def transformCode(code, rules, codeFileName):
wrapContent = parseTaggedContent("content", action=wrapContentIntoDetails)
code = wrapContent.transformString(code)
# Transform "[[details]] content" and "[[/details]]" to HTML
transformDetailsBegin = LineStart() + Suppress(ZeroOrMore(" ") + "//" + ZeroOrMore(" ") + "[[details]]" + ZeroOrMore(" ")) + Optional(restOfLine)
def detailBeginHTML(token):
return "// <details><summary> Click to show " + token[0] + "</summary>\n"
transformDetailsBegin.setParseAction(detailBeginHTML)
code = transformDetailsBegin.transformString(code)
transformDetailsEnd = LineStart() + Suppress(ZeroOrMore(" ") + "//" + ZeroOrMore(" ") + "[[/details]]") + Optional(restOfLine)
transformDetailsEnd.setParseAction(replaceWith("// </details>\n"))
code = transformDetailsEnd.transformString(code)
for transform in rules:
code = transform.transformString(code)
return code
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment