diff --git a/docs/source/badges/docstring_coverage.svg b/docs/source/badges/docstring_coverage.svg index bb83422617c573dda55319b7fadb4a026c5677b7..ede19575876030e5398abf5f389986501bd6db62 100644 --- a/docs/source/badges/docstring_coverage.svg +++ b/docs/source/badges/docstring_coverage.svg @@ -14,7 +14,7 @@ <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="110"> <text x="505" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="890">docstr-coverage</text> <text x="505" y="140" transform="scale(.1)" textLength="890">docstr-coverage</text> - <text x="1195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">98%</text> - <text x="1195" y="140" transform="scale(.1)">98%</text> + <text x="1195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">100%</text> + <text x="1195" y="140" transform="scale(.1)">100%</text> </g> </svg> \ No newline at end of file diff --git a/docs/source/badges/test_coverage.svg b/docs/source/badges/test_coverage.svg index 9e1a50b1a208346126d0e2fb0ac82ca52d3af2c2..bc3407c38eb421a1b578d6d7c04aed07dbd6ab83 100644 --- a/docs/source/badges/test_coverage.svg +++ b/docs/source/badges/test_coverage.svg @@ -15,7 +15,7 @@ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> <text x="31.5" y="14">coverage</text> - <text x="80" y="15" fill="#010101" fill-opacity=".3">12%</text> - <text x="80" y="14">12%</text> + <text x="80" y="15" fill="#010101" fill-opacity=".3">23%</text> + <text x="80" y="14">23%</text> </g> </svg> diff --git a/docs/source/conf.py b/docs/source/conf.py index 0e890a20a516f2e51b3893f3c3866b0b4270b09e..9f57831e8339993c318f7519645dfeb6a6ca4d31 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,15 +17,101 @@ list see the documentation: import os import sys -import sphinx_rtd_theme import m2r2 +import jinja2 + +from git import Repo from binarycpython.utils.functions import ( write_binary_c_parameter_descriptions_to_rst_file, + call_binary_c_config ) -# from binarycpython.utils.grid import write_grid_options_to_rst_file + from binarycpython.utils.grid import Population -from functions import write_custom_footer + +def generate_browser_url(ssh_url, branch=None): + """ + Function to generate the browser url for a git repo + """ + + base = ssh_url.split("@")[-1].replace(".git", "").replace(":", "/").strip() + + if not branch: + return "https://{}".format(base) + else: + return "https://{}/-/tree/{}".format(base, branch) + + +def write_custom_footer(): + """ + Function to write the custom footer to the template file + """ + + TARGET_DIR = "./_templates" + + output_text = """ +{{% extends '!footer.html' %}} + +{{%- block extrafooter %}} +<br><br> +Generated on binarycpython git branch: {binarycpython_git_branch} git revision {binarycpython_git_revision} url: <a href="{binarycpython_git_url}">git url</a>. +<br><br> +Using binary_c with bit branch {binary_c_git_branch}: git revision: {binary_c_git_revision} url: <a href="{binary_c_git_url}">git url</a>. + +{{% endblock %}} +""" + + binary_c_git_branch = call_binary_c_config("git_branch").strip() + binary_c_git_revision = call_binary_c_config("git_revision").strip() + binary_c_git_url = generate_browser_url( + call_binary_c_config("git_url").strip(), binary_c_git_branch + ) + + # for binarycpython git + base_dir = os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + ) + local_repo = Repo(path=base_dir) + + binarycpython_git_branch = local_repo.active_branch.name + binarycpython_git_revision = local_repo.active_branch.commit + binarycpython_git_url = generate_browser_url( + local_repo.remotes.origin.url, binarycpython_git_branch + ) + + formatted_text = output_text.format( + binarycpython_git_branch=binarycpython_git_branch, + binarycpython_git_revision=binarycpython_git_revision, + binarycpython_git_url=binarycpython_git_url, + binary_c_git_branch=binary_c_git_branch, + binary_c_git_revision=binary_c_git_revision, + binary_c_git_url=binary_c_git_url, + ).strip() + + # Write to file + with open("_templates/footer.html", "w") as outfile_filehandle: + outfile_filehandle.write(formatted_text) + + + + + + + + + + + + + + + + + + + + + # def patched_m2r2_setup(app): diff --git a/docs/source/functions.py b/docs/source/functions.py index ca960dbdf465e0b77d861a47751cb0588a4e8454..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/docs/source/functions.py +++ b/docs/source/functions.py @@ -1,71 +0,0 @@ -import os -import jinja2 -import m2r2 - -from binarycpython.utils.functions import call_binary_c_config - -from git import Repo - - -def generate_browser_url(ssh_url, branch=None): - """ - Function to generate the browser url for a git repo - """ - - base = ssh_url.split("@")[-1].replace(".git", "").replace(":", "/").strip() - - if not branch: - return "https://{}".format(base) - else: - return "https://{}/-/tree/{}".format(base, branch) - - -def write_custom_footer(): - """ - Function to write the custom footer to the template file - """ - - TARGET_DIR = "./_templates" - - output_text = """ -{{% extends '!footer.html' %}} - -{{%- block extrafooter %}} -<br><br> -Generated on binarycpython git branch: {binarycpython_git_branch} git revision {binarycpython_git_revision} url: <a href="{binarycpython_git_url}">git url</a>. -<br><br> -Using binary_c with bit branch {binary_c_git_branch}: git revision: {binary_c_git_revision} url: <a href="{binary_c_git_url}">git url</a>. - -{{% endblock %}} -""" - - binary_c_git_branch = call_binary_c_config("git_branch").strip() - binary_c_git_revision = call_binary_c_config("git_revision").strip() - binary_c_git_url = generate_browser_url( - call_binary_c_config("git_url").strip(), binary_c_git_branch - ) - - # for binarycpython git - base_dir = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - ) - local_repo = Repo(path=base_dir) - - binarycpython_git_branch = local_repo.active_branch.name - binarycpython_git_revision = local_repo.active_branch.commit - binarycpython_git_url = generate_browser_url( - local_repo.remotes.origin.url, binarycpython_git_branch - ) - - formatted_text = output_text.format( - binarycpython_git_branch=binarycpython_git_branch, - binarycpython_git_revision=binarycpython_git_revision, - binarycpython_git_url=binarycpython_git_url, - binary_c_git_branch=binary_c_git_branch, - binary_c_git_revision=binary_c_git_revision, - binary_c_git_url=binary_c_git_url, - ).strip() - - # Write to file - with open("_templates/footer.html", "w") as outfile_filehandle: - outfile_filehandle.write(formatted_text)