From bad64107b5743c3190e00f44d700e56324a7b594 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Tue, 17 Mar 2020 00:02:39 +0100 Subject: [PATCH 1/3] [examples] Add config files listing the doc snippets --- examples/1ptracer/.doc_config | 7 +++++++ examples/2pinfiltration/.doc_config | 5 +++++ examples/shallowwaterfriction/.doc_config | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 examples/1ptracer/.doc_config create mode 100644 examples/2pinfiltration/.doc_config create mode 100644 examples/shallowwaterfriction/.doc_config diff --git a/examples/1ptracer/.doc_config b/examples/1ptracer/.doc_config new file mode 100644 index 0000000000..fd0ffdb7e1 --- /dev/null +++ b/examples/1ptracer/.doc_config @@ -0,0 +1,7 @@ +doc/intro.md +spatialparams_1p.hh +problem_1p.hh +spatialparams_tracer.hh +problem_tracer.hh +main.cc +doc/results.md diff --git a/examples/2pinfiltration/.doc_config b/examples/2pinfiltration/.doc_config new file mode 100644 index 0000000000..fd1032cf16 --- /dev/null +++ b/examples/2pinfiltration/.doc_config @@ -0,0 +1,5 @@ +doc/intro.md +spatialparams.hh +problem.hh +main.cc +doc/results.md diff --git a/examples/shallowwaterfriction/.doc_config b/examples/shallowwaterfriction/.doc_config new file mode 100644 index 0000000000..fd1032cf16 --- /dev/null +++ b/examples/shallowwaterfriction/.doc_config @@ -0,0 +1,5 @@ +doc/intro.md +spatialparams.hh +problem.hh +main.cc +doc/results.md -- GitLab From cf60e1d3be2db6ad6cb9a76c6fc58b614c327fd7 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Tue, 17 Mar 2020 00:03:19 +0100 Subject: [PATCH 2/3] [examples] Add Python script generating the example docs --- examples/generate_example_docs.py | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 examples/generate_example_docs.py diff --git a/examples/generate_example_docs.py b/examples/generate_example_docs.py new file mode 100755 index 0000000000..61e2bd414c --- /dev/null +++ b/examples/generate_example_docs.py @@ -0,0 +1,38 @@ +#!/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) -- GitLab From 4c48d6f0ce09f9e650b5d18ddfb00a43fa0ba080 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Tue, 17 Mar 2020 00:03:46 +0100 Subject: [PATCH 3/3] [examples] Update readme --- examples/2pinfiltration/README.md | 3 ++- examples/shallowwaterfriction/README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/2pinfiltration/README.md b/examples/2pinfiltration/README.md index 86cd1a14e0..d068fbcda1 100644 --- a/examples/2pinfiltration/README.md +++ b/examples/2pinfiltration/README.md @@ -571,6 +571,7 @@ The file dumuxmessage.hh contains the class defining the start and end message o we include the linear solver to be used to solve the linear system ```cpp #include +#include ``` we include the nonlinear Newton's method ```cpp @@ -785,7 +786,7 @@ we set the assembler with the time loop because we have an instationary problem ``` we set the linear solver ```cpp - using LinearSolver = AMGBackend; + using LinearSolver = AMGBiCGSTABBackend>; auto linearSolver = std::make_shared(leafGridView, gridGeometry->dofMapper()); ``` additionally we set the non-linear solver. diff --git a/examples/shallowwaterfriction/README.md b/examples/shallowwaterfriction/README.md index a211d33553..6d4c51c877 100644 --- a/examples/shallowwaterfriction/README.md +++ b/examples/shallowwaterfriction/README.md @@ -613,6 +613,7 @@ The gridmanager constructs a grid from the information in the input or grid file We include the linear solver to be used to solve the linear system ```cpp #include +#include ``` We include the nonlinear newtons method ```cpp @@ -721,7 +722,7 @@ we set the assembler with the time loop because we have an instationary problem. ``` We set the linear solver. ```cpp - using LinearSolver = Dumux::AMGBackend; + using LinearSolver = AMGBiCGSTABBackend>; auto linearSolver = std::make_shared(leafGridView, gridGeometry->dofMapper()); ``` Additionaly, we set the non-linear solver. -- GitLab