From f7b4fdfabe200877dc54213b620f83d25969092f Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 05:27:06 +0000 Subject: [PATCH 1/8] Show git dir --- doc/htmldoc/conf.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index 5ec1ebde38..99950e5ed9 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -195,7 +195,7 @@ } -def config_inited_handler(app, config): +def config_inited_handler(app, config): models_rst_dir = os.path.abspath("models") ExtractUserDocs( listoffiles=relative_glob("models/*.h", "nestkernel/*.h", basedir=repo_root_dir), @@ -288,10 +288,7 @@ def add_button_to_examples(app, env, docnames): def toc_customizer(app, docname, source): - if docname == "models/models-toc": - models_toc = json.load(open("models/toc-tree.json")) - html_context = {"nest_models": models_toc} - models_source = source[0] + if docname == "models/models-toc":/steffengraber/nest-simulator rendered = app.builder.templates.render_string(models_source, html_context) source[0] = rendered @@ -390,10 +387,11 @@ def patch_documentation(patch_url): 3. retrieve the patch """ - print("Preparing patch...") try: - git_dir = repo_root_dir / ".git" + git_dir = f"{repo_root_dir} /.git" + print(f" Git dir: {git_dir}") + git_hash = subprocess.check_output( f"GIT_DIR='{git_dir}' git rev-parse HEAD", shell=True, @@ -404,7 +402,11 @@ def patch_documentation(patch_url): print(f" retrieving {patch_url}") urlretrieve(patch_url, patch_file) print(f" applying {patch_file}") - result = subprocess.check_output('patch -p3', stdin=open(patch_file, 'r'), stderr=subprocess.STDOUT, shell=True) + result = subprocess.check_output('patch -p3', + stdin=open(patch_file, 'r'), + stderr=subprocess.STDOUT, + shell=True + ) print(f"Patch result: {result}") except Exception as exc: print(f"Error while applying patch: {exc}") From 942b9538c3d43db3ce16c4928f60bf1e58055896 Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 05:34:21 +0000 Subject: [PATCH 2/8] Fix error --- doc/htmldoc/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index 99950e5ed9..03e5ab6b58 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -288,7 +288,10 @@ def add_button_to_examples(app, env, docnames): def toc_customizer(app, docname, source): - if docname == "models/models-toc":/steffengraber/nest-simulator + if docname == "models/models-toc": + models_toc = json.load(open("models/toc-tree.json")) + html_context = {"nest_models": models_toc} + models_source = source[0] rendered = app.builder.templates.render_string(models_source, html_context) source[0] = rendered From 275484694eb57682e2616d77e5290a670e0e8761 Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 05:45:17 +0000 Subject: [PATCH 3/8] Fix git dir --- doc/htmldoc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index 03e5ab6b58..99ac4642d9 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -392,7 +392,7 @@ def patch_documentation(patch_url): """ print("Preparing patch...") try: - git_dir = f"{repo_root_dir} /.git" + git_dir = f"{repo_root_dir}/.git" print(f" Git dir: {git_dir}") git_hash = subprocess.check_output( From d3dc0c711857bfe899d3e47ea60596544e3f61b5 Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 05:51:25 +0000 Subject: [PATCH 4/8] Testing text patch with option --binary --- doc/htmldoc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index 99ac4642d9..6122128c84 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -405,7 +405,7 @@ def patch_documentation(patch_url): print(f" retrieving {patch_url}") urlretrieve(patch_url, patch_file) print(f" applying {patch_file}") - result = subprocess.check_output('patch -p3', + result = subprocess.check_output('patch -p3 --binary', stdin=open(patch_file, 'r'), stderr=subprocess.STDOUT, shell=True From 4a8054097ca093cefa34bc6176d5adce355f92b0 Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 06:33:52 +0000 Subject: [PATCH 5/8] Use 'git apply' instead of `patch --binary` --- doc/htmldoc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index 6122128c84..4f4e7e6db9 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -405,7 +405,7 @@ def patch_documentation(patch_url): print(f" retrieving {patch_url}") urlretrieve(patch_url, patch_file) print(f" applying {patch_file}") - result = subprocess.check_output('patch -p3 --binary', + result = subprocess.check_output('git apply', stdin=open(patch_file, 'r'), stderr=subprocess.STDOUT, shell=True From 65420f6705c6794295cccfcd675e85cd5a2fdca1 Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 07:41:55 +0000 Subject: [PATCH 6/8] Remove test output --- doc/htmldoc/conf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index 4f4e7e6db9..e1b493307b 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -393,8 +393,6 @@ def patch_documentation(patch_url): print("Preparing patch...") try: git_dir = f"{repo_root_dir}/.git" - print(f" Git dir: {git_dir}") - git_hash = subprocess.check_output( f"GIT_DIR='{git_dir}' git rev-parse HEAD", shell=True, From bbe7193f9c51a9b1d406aae422af377b6eb71049 Mon Sep 17 00:00:00 2001 From: Steffen Graber Date: Tue, 13 Jun 2023 07:57:40 +0000 Subject: [PATCH 7/8] Fix trailing whitespace --- doc/htmldoc/conf.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index e1b493307b..7f3b777edb 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -195,7 +195,7 @@ } -def config_inited_handler(app, config): +def config_inited_handler(app, config): models_rst_dir = os.path.abspath("models") ExtractUserDocs( listoffiles=relative_glob("models/*.h", "nestkernel/*.h", basedir=repo_root_dir), @@ -403,11 +403,10 @@ def patch_documentation(patch_url): print(f" retrieving {patch_url}") urlretrieve(patch_url, patch_file) print(f" applying {patch_file}") - result = subprocess.check_output('git apply', - stdin=open(patch_file, 'r'), - stderr=subprocess.STDOUT, - shell=True - ) + result = subprocess.check_output('git apply', + stdin=open(patch_file, 'r'), + stderr=subprocess.STDOUT, + shell=True) print(f"Patch result: {result}") except Exception as exc: print(f"Error while applying patch: {exc}") From f30bafe679628297cedf1c4464be328795878e5f Mon Sep 17 00:00:00 2001 From: Dennis Terhorst Date: Fri, 30 Jun 2023 17:37:37 +0200 Subject: [PATCH 8/8] Improve external call and blacken code --- doc/htmldoc/conf.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/htmldoc/conf.py b/doc/htmldoc/conf.py index cf161d8fd6..f50436244f 100644 --- a/doc/htmldoc/conf.py +++ b/doc/htmldoc/conf.py @@ -397,10 +397,7 @@ def patch_documentation(patch_url): print(f" retrieving {patch_url}") urlretrieve(patch_url, patch_file) print(f" applying {patch_file}") - result = subprocess.check_output('git apply', - stdin=open(patch_file, 'r'), - stderr=subprocess.STDOUT, - shell=True) + result = subprocess.check_output(f"git apply '{patch_file}'", stderr=subprocess.STDOUT, shell=True) print(f"Patch result: {result}") except Exception as exc: print(f"Error while applying patch: {exc}")