Skip to content
Snippets Groups Projects
Commit b6b12204 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[docgen][code_to_md] pull out exclude rule from cppRules

parent f5492008
No related branches found
No related tags found
2 merge requests!1915Feature/modify python examples docgen,!1914[examples] Implement Python-only doc generator using pyparsing
......@@ -38,9 +38,6 @@ def cppRules():
headerGuard = Suppress(Literal("#ifndef") + Optional(restOfLine) + LineEnd() + Literal("#define") + Optional(restOfLine))
endHeaderGuard = Suppress(Literal("#endif") + Optional(restOfLine))
# exclude stuff between [[exclude]] and [[/exclude]]
exclude = parseTaggedContent("exclude", action=replaceWith(""))
# make a code block (possibly containing comments) between [[codeblock]] and [[/codeblock]]
action = createMarkdownCode("cpp")
codeblock = parseTaggedContent("codeblock", action=action)
......@@ -51,9 +48,14 @@ def cppRules():
code.setParseAction(action)
docTransforms = codeblock | doc | code
return [header, headerGuard, endHeaderGuard, exclude, docTransforms]
return [header, headerGuard, endHeaderGuard, docTransforms]
def transformCode(code, rules):
# exclude stuff between [[exclude]] and [[/exclude]]
exclude = parseTaggedContent("exclude", action=replaceWith(""))
code = exclude.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