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
cf60e1d3
Commit
cf60e1d3
authored
5 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[examples] Add Python script generating the example docs
parent
bad64107
No related branches found
No related tags found
1 merge request
!1888
Feature/examples automate readme
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/generate_example_docs.py
+38
-0
38 additions, 0 deletions
examples/generate_example_docs.py
with
38 additions
and
0 deletions
examples/generate_example_docs.py
0 → 100755
+
38
−
0
View file @
cf60e1d3
#!/usr/bin/env python3
import
os
import
argparse
import
subprocess
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
-d
"
,
"
--directory
"
,
help
=
"
The folder to look for examples
"
,
default
=
"
.
"
)
parser
.
add_argument
(
"
-m
"
,
"
--markdowngenerator
"
,
help
=
"
The markdown generator script taking a list of files
"
,
default
=
"
../bin/doc/cpp_to_md.sh
"
)
args
=
vars
(
parser
.
parse_args
())
def
convertToMarkdownAndMerge
(
dir
,
includeList
):
script
=
os
.
path
.
join
(
os
.
path
.
abspath
(
args
[
"
markdowngenerator
"
]))
with
open
(
os
.
path
.
join
(
dir
,
"
README.md
"
),
"
w
"
)
as
readme
:
for
include
in
includeList
:
if
os
.
path
.
splitext
(
include
)[
1
]
==
"
.md
"
:
with
open
(
include
,
"
r
"
)
as
markdown
:
readme
.
write
(
markdown
.
read
())
else
:
readme
.
write
(
"
\n\n
## The file `{}`
\n\n
"
.
format
(
os
.
path
.
split
(
include
)[
1
]))
markdown
=
subprocess
.
check_output
([
"
bash
"
,
script
,
include
],
encoding
=
"
utf-8
"
)
readme
.
write
(
markdown
+
"
\n
"
)
def
generateReadme
(
dir
):
includeList
=
None
try
:
configname
=
os
.
path
.
join
(
dir
,
"
.doc_config
"
)
with
open
(
configname
,
'
r
'
)
as
config
:
includeList
=
[
os
.
path
.
join
(
dir
,
include
)
for
include
in
config
.
read
().
splitlines
()]
except
FileNotFoundError
:
print
(
"
Error: The example directory {} does not contain a .doc_config file! Could not generate README.md!
"
.
format
(
dir
))
raise
if
includeList
is
not
None
:
convertToMarkdownAndMerge
(
dir
,
includeList
)
for
path
in
os
.
listdir
(
args
[
"
directory
"
]):
abspath
=
os
.
path
.
join
(
os
.
path
.
abspath
(
args
[
"
directory
"
]),
path
)
if
os
.
path
.
isdir
(
abspath
):
generateReadme
(
abspath
)
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