From 1ebde8fd0373ce506a2b6972cb80c7f3f79be29b Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:01:01 +1200 Subject: [PATCH] conf.py: Gate rtds_action Also add a proto warning announcement if it looks like a PR preview (since it won't have any generated content). --- docs/source/conf.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 97560adcbcc..6037c81a0b7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -41,20 +41,30 @@ pygments_style = 'colorful' highlight_language = 'none' -extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex', 'rtds_action'] - -# The name of your GitHub repository -rtds_action_github_repo = "KrystalDelusion/yosys" - -# The path where the artifact should be extracted -# Note: this is relative to the conf.py file! -rtds_action_path = "." - -# The "prefix" used in the `upload-artifact` step of the action -rtds_action_artifact_prefix = "cmd-ref-" - -# A GitHub personal access token is required, more info below -rtds_action_github_token = os.environ["GITHUB_TOKEN"] +extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex'] + +if os.getenv("READTHEDOCS"): + # Use rtds_action if we are building on read the docs and have a github token env var + if os.getenv["GITHUB_TOKEN"]: + extensions += ['rtds_action'] + + # The name of your GitHub repository + rtds_action_github_repo = "KrystalDelusion/yosys" + + # The path where the artifact should be extracted + # Note: this is relative to the conf.py file! + rtds_action_path = "." + + # The "prefix" used in the `upload-artifact` step of the action + rtds_action_artifact_prefix = "cmd-ref-" + + # A GitHub personal access token is required for full RTD builds + rtds_action_github_token = os.environ["GITHUB_TOKEN"] + else: + # We're on read the docs but have no github token, this is probably a PR preview build + html_theme_options["announcement"] = "Oh no! This looks like a ReadTheDocs build, possibly for a PR preview, that's missing some generated content!" + html_theme_options["light_css_variables"]["color-announcement-background"] = "var(--color-admonition-title-background--caution)" + html_theme_options["light_css_variables"]["color-announcement-text"] = "var(--color-content-foreground)" # Ensure that autosectionlabel will produce unique names autosectionlabel_prefix_document = True