From 867d8e294ef562b2957911d113406ae9a34852e1 Mon Sep 17 00:00:00 2001 From: Sam Wu <22262939+samjwu@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:37:28 -0600 Subject: [PATCH] Set environment variables for RTD builds (#113) * Format conf.py with black and isort * Set env vars for RTD builds * Define html_context * Use rocm-stg for canonical url --- docs/conf.py | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index d66ff3bc2..fadd426c8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,9 +4,10 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -import shutil -import jinja2 import os +import shutil + +import jinja2 # Environment to process Jinja templates. jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(".")) @@ -18,10 +19,10 @@ templates = [] # For example: 'install.md.jinja' becomes 'install.md'. for template in templates: rendered = jinja_env.get_template(template).render() - with open(os.path.splitext(template)[0], 'w') as file: + with open(os.path.splitext(template)[0], "w") as file: file.write(rendered) -shutil.copy2('../RELEASE.md','./about/release-notes.md') +shutil.copy2("../RELEASE.md", "./about/release-notes.md") latex_engine = "xelatex" latex_elements = { @@ -44,24 +45,15 @@ all_article_info_author = "" # pages with specific settings article_pages = [ - { - "file":"about/release-notes", - "os":["linux", "windows"], - "date":"2024-06-04" - }, - { - "file":"about/changelog", - "os":["linux", "windows"], - "date":"2024-06-04" - }, - - {"file":"how-to/deep-learning-rocm", "os":["linux"]}, - {"file":"how-to/gpu-enabled-mpi", "os":["linux"]}, - {"file":"how-to/system-debugging", "os":["linux"]}, - {"file":"how-to/tuning-guides", "os":["linux", "windows"]}, + {"file": "about/release-notes", "os": ["linux", "windows"], "date": "2024-06-04"}, + {"file": "about/changelog", "os": ["linux", "windows"], "date": "2024-06-04"}, + {"file": "how-to/deep-learning-rocm", "os": ["linux"]}, + {"file": "how-to/gpu-enabled-mpi", "os": ["linux"]}, + {"file": "how-to/system-debugging", "os": ["linux"]}, + {"file": "how-to/tuning-guides", "os": ["linux", "windows"]}, ] -exclude_patterns = ['temp'] +exclude_patterns = ["temp"] external_toc_path = "./sphinx/_toc.yml" @@ -69,6 +61,11 @@ extensions = ["rocm_docs", "sphinx_reredirects"] external_projects_current_project = "rocm" +html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "https://rocm-stg.amd.com") +html_context = {} +if os.environ.get("READTHEDOCS", "") == "True": + html_context["READTHEDOCS"] = True + html_theme = "rocm_docs_theme" html_theme_options = {"flavor": "rocm-docs-home"} @@ -77,10 +74,6 @@ html_css_files = ["rocm_custom.css"] html_title = "ROCm Documentation" -html_theme_options = { - "link_main_doc": False -} +html_theme_options = {"link_main_doc": False} -redirects = { - "reference/openmp/openmp": "../../about/compatibility/openmp.html" -} +redirects = {"reference/openmp/openmp": "../../about/compatibility/openmp.html"}