diff --git a/docs/source/conf.py b/docs/source/conf.py index 23efe2b43..4719dc89e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -41,13 +41,21 @@ html_static_path = ['_static', "_images"] pygments_style = 'colorful' highlight_language = 'none' -extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex', 'rtds_action'] +extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex'] -# rtds_action -rtds_action_github_repo = "YosysHQ/yosys" -rtds_action_path = "." -rtds_action_artifact_prefix = "cmd-ref-" -rtds_action_github_token = os.environ["GITHUB_TOKEN"] +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'] + rtds_action_github_repo = "YosysHQ/yosys" + rtds_action_path = "." + rtds_action_artifact_prefix = "cmd-ref-" + 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"] = 'Missing content? Check PR preview limitations.' + 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