Skip to content
Snippets Groups Projects
Commit c28d981d authored by dh00601's avatar dh00601
Browse files

fixing docs import functiosn

parent ce8f04bd
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="110"> <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="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="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="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">100%</text>
<text x="1195" y="140" transform="scale(.1)">98%</text> <text x="1195" y="140" transform="scale(.1)">100%</text>
</g> </g>
</svg> </svg>
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <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="15" fill="#010101" fill-opacity=".3">coverage</text>
<text x="31.5" y="14">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="15" fill="#010101" fill-opacity=".3">23%</text>
<text x="80" y="14">12%</text> <text x="80" y="14">23%</text>
</g> </g>
</svg> </svg>
...@@ -17,15 +17,101 @@ list see the documentation: ...@@ -17,15 +17,101 @@ list see the documentation:
import os import os
import sys import sys
import sphinx_rtd_theme
import m2r2 import m2r2
import jinja2
from git import Repo
from binarycpython.utils.functions import ( from binarycpython.utils.functions import (
write_binary_c_parameter_descriptions_to_rst_file, 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 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): def patched_m2r2_setup(app):
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment