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
29756f64
Commit
29756f64
authored
4 years ago
by
Timo Koch
Committed by
Dennis Gläser
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[examples] Add uniform fold mechanism for source code to generator
parent
f5af3746
No related branches found
No related tags found
1 merge request
!1933
[examples] Move properties to their own header
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/convert_code_to_doc.py
+10
-1
10 additions, 1 deletion
examples/convert_code_to_doc.py
examples/generate_example_docs.py
+2
-1
2 additions, 1 deletion
examples/generate_example_docs.py
with
12 additions
and
2 deletions
examples/convert_code_to_doc.py
+
10
−
1
View file @
29756f64
...
...
@@ -50,12 +50,21 @@ def cppRules():
return
[
suppressHeader
,
suppressHeaderGuard
,
suppressEndHeaderGuard
,
docTransforms
]
def
transformCode
(
code
,
rules
):
def
transformCode
(
code
,
rules
,
codeFileName
):
# exclude stuff between [[exclude]] and [[/exclude]]
exclude
=
parseTaggedContent
(
"
exclude
"
,
action
=
replaceWith
(
""
))
code
=
exclude
.
transformString
(
code
)
# Enable toggling content between [[content]] and [[/content]]
def
wrapContentIntoDetails
(
token
):
beginDetails
=
"
//
\n
// <details open>
\n
"
summmary
=
"
// <summary><b>Click to hide/show the file documentation</b> (or inspect the [source code]({}))</summary>
\n
//
\n
"
.
format
(
codeFileName
)
endDetails
=
"
\n
//
\n
// </details>
\n
"
return
beginDetails
+
summmary
+
token
[
0
]
+
endDetails
wrapContent
=
parseTaggedContent
(
"
content
"
,
action
=
wrapContentIntoDetails
)
code
=
wrapContent
.
transformString
(
code
)
for
transform
in
rules
:
code
=
transform
.
transformString
(
code
)
return
code
This diff is collapsed.
Click to expand it.
examples/generate_example_docs.py
+
2
−
1
View file @
29756f64
...
...
@@ -27,7 +27,8 @@ def convertToMarkdownAndMerge(dir, config):
targetFile
.
write
(
markdown
.
read
())
elif
fileExtension
==
"
.hh
"
or
fileExtension
==
"
.cc
"
:
with
open
(
os
.
path
.
join
(
dir
,
source
),
"
r
"
)
as
cppCode
:
targetFile
.
write
(
"
\n\n
"
+
transformCode
(
cppCode
.
read
(),
cppRules
())
+
"
\n
"
)
sourceRelPath
=
os
.
path
.
relpath
(
os
.
path
.
abspath
(
os
.
path
.
join
(
dir
,
source
)),
os
.
path
.
split
(
os
.
path
.
abspath
(
targetPath
))[
0
])
targetFile
.
write
(
"
\n\n
"
+
transformCode
(
cppCode
.
read
(),
cppRules
(),
sourceRelPath
)
+
"
\n
"
)
else
:
raise
IOError
(
"
Unsupported or unknown file extension *{}
"
.
format
(
fileExtension
))
...
...
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