From ab4bda8ae25714dfd6249e136a9021d4afedc278 Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 Jan 2025 16:19:36 +1300 Subject: [PATCH] Docs: Fix links for view/edit source --- docs/source/conf.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8c8555b71..0e2f79a56 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,6 +11,29 @@ yosys_ver = "0.48" # select HTML theme html_theme = 'furo-ys' html_css_files = ['custom.css'] +html_theme_options: dict[str] = { + "source_repository": "https://github.com/YosysHQ/yosys/", + "source_branch": "main", + "source_directory": "docs/", +} + +# try to fix the readthedocs detection +html_context: dict[str] = { + "READTHEDOCS": True, + "display_github": True, + "github_user": "YosysHQ", + "github_repo": "yosys", + "slug": "yosys", +} + +# override source_branch if not main +git_slug = os.getenv("READTHEDOCS_VERSION_NAME") +if git_slug not in [None, "latest", "stable"]: + html_theme_options["source_branch"] = git_slug + +# edit only works on branches, not tags +if os.getenv("READTHEDOCS_VERSION_TYPE", "branch") != "branch": + html_theme_options["top_of_page_buttons"] = ["view"] # These folders are copied to the documentation's HTML output html_static_path = ['_static', "_images"]