diff --git a/docs/conf.py b/docs/conf.py index f0fb5d1..f17d607 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,20 +15,42 @@ "jupyter_sphinx", ] +# Determine the git version to use +import subprocess + +def run_command(*args: str) -> str: + return subprocess.check_output(args).decode().strip() + +git_version = run_command("git", "rev-parse", "--abbrev-ref", "HEAD") +if git_version == "HEAD": + git_version = run_command("git", "describe", "--exact-match", "--tags") + +# Construct GitHub links +git_base_url = "https://github.com/PainterQubits/datalogs" +git_view_link = ( + f"{git_base_url}/blob/{git_version}/docs/{{filename}}?plain=1" +) +git_repo_link = f"https://github.com/PainterQubits/datalogs/tree/{git_version}" + # HTML output options html_theme = "furo" html_static_path = ["_static"] -html_context = { - "display_github": True, - "github_user": "PainterQubits", - "github_repo": "datalogs", - "github_version": "main/docs/", +html_theme_options = { + "source_view_link": git_view_link, + # From https://pradyunsg.me/furo/customisation/footer/#using-embedded-svgs + "footer_icons": [ + { + "name": "GitHub", + "url": git_repo_link, + "html": """ + + + + """, + "class": "", + }, + ], } -# html_theme_options = { -# "source_repository": "https://github.com/PainterQubits/datalogs", -# "source_branch": "main", -# "source_directory": "docs", -# } # MyST options myst_heading_anchors = 3