Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
73cead2d
Commit
73cead2d
authored
4 years ago
by
Dennis Gläser
Browse files
Options
Downloads
Patches
Plain Diff
[docgen][code_to_md] remove Literal() statements where possible
parent
b6b12204
No related branches found
No related tags found
2 merge requests
!1915
Feature/modify python examples docgen
,
!1914
[examples] Implement Python-only doc generator using pyparsing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/convert_code_to_doc.py
+7
-7
7 additions, 7 deletions
examples/convert_code_to_doc.py
with
7 additions
and
7 deletions
examples/convert_code_to_doc.py
+
7
−
7
View file @
73cead2d
...
@@ -14,8 +14,8 @@ def parseTaggedContent(keyname, action, open="[[", close="]]", endTag="/"):
...
@@ -14,8 +14,8 @@ def parseTaggedContent(keyname, action, open="[[", close="]]", endTag="/"):
"""
"""
Match content between [[keyname]] and [[/keyname]] and apply the action on it
Match content between [[keyname]] and [[/keyname]] and apply the action on it
"""
"""
start
=
LineStart
()
+
ZeroOrMore
(
"
"
)
+
Literal
(
"
//
"
)
+
ZeroOrMore
(
"
"
)
+
Literal
(
open
+
str
(
keyname
)
+
close
)
start
=
LineStart
()
+
ZeroOrMore
(
"
"
)
+
"
//
"
+
ZeroOrMore
(
"
"
)
+
Literal
(
open
+
str
(
keyname
)
+
close
)
end
=
LineStart
()
+
ZeroOrMore
(
"
"
)
+
Literal
(
"
//
"
)
+
ZeroOrMore
(
"
"
)
+
Literal
(
open
+
endTag
+
str
(
keyname
)
+
close
)
end
=
LineStart
()
+
ZeroOrMore
(
"
"
)
+
"
//
"
+
ZeroOrMore
(
"
"
)
+
Literal
(
open
+
endTag
+
str
(
keyname
)
+
close
)
return
start
.
suppress
()
+
SkipTo
(
end
).
setParseAction
(
action
)
+
end
.
suppress
()
return
start
.
suppress
()
+
SkipTo
(
end
).
setParseAction
(
action
)
+
end
.
suppress
()
def
createMarkdownCode
(
markDownToken
):
def
createMarkdownCode
(
markDownToken
):
...
@@ -34,17 +34,17 @@ def cppRules():
...
@@ -34,17 +34,17 @@ def cppRules():
"""
"""
Define a list of rules to apply for cpp source code
Define a list of rules to apply for cpp source code
"""
"""
header
=
Suppress
(
Combine
(
Literal
(
"
// -*-
"
)
+
SkipTo
(
Literal
(
"
*******/
"
)
+
LineEnd
())
+
Literal
(
"
*******/
"
))
)
header
=
Suppress
(
Combine
(
"
// -*-
"
+
SkipTo
(
"
*******/
"
+
LineEnd
())
+
"
*******/
"
))
headerGuard
=
Suppress
(
Literal
(
"
#ifndef
"
)
+
Optional
(
restOfLine
)
+
LineEnd
()
+
Literal
(
"
#define
"
)
+
Optional
(
restOfLine
))
headerGuard
=
Suppress
(
"
#ifndef
"
+
Optional
(
restOfLine
)
+
LineEnd
()
+
"
#define
"
+
Optional
(
restOfLine
))
endHeaderGuard
=
Suppress
(
Literal
(
"
#endif
"
)
+
Optional
(
restOfLine
))
endHeaderGuard
=
Suppress
(
"
#endif
"
+
Optional
(
restOfLine
))
# make a code block (possibly containing comments) between [[codeblock]] and [[/codeblock]]
# make a code block (possibly containing comments) between [[codeblock]] and [[/codeblock]]
action
=
createMarkdownCode
(
"
cpp
"
)
action
=
createMarkdownCode
(
"
cpp
"
)
codeblock
=
parseTaggedContent
(
"
codeblock
"
,
action
=
action
)
codeblock
=
parseTaggedContent
(
"
codeblock
"
,
action
=
action
)
# treat doc and code line
# treat doc and code line
doc
=
LineStart
()
+
Suppress
(
ZeroOrMore
(
"
"
)
+
Literal
(
"
//
"
)
+
ZeroOrMore
(
"
"
))
+
Optional
(
restOfLine
)
doc
=
LineStart
()
+
Suppress
(
ZeroOrMore
(
"
"
)
+
"
//
"
+
ZeroOrMore
(
"
"
))
+
Optional
(
restOfLine
)
code
=
LineStart
()
+
~
(
ZeroOrMore
(
"
"
)
+
Literal
(
"
//
"
)
)
+
(
SkipTo
(
doc
)
|
SkipTo
(
StringEnd
()))
code
=
LineStart
()
+
~
(
ZeroOrMore
(
"
"
)
+
"
//
"
)
+
(
SkipTo
(
doc
)
|
SkipTo
(
StringEnd
()))
code
.
setParseAction
(
action
)
code
.
setParseAction
(
action
)
docTransforms
=
codeblock
|
doc
|
code
docTransforms
=
codeblock
|
doc
|
code
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment