Skip to content

Commit

Permalink
Merge pull request #248 from StreamHPC/projects_in_templates
Browse files Browse the repository at this point in the history
feat(projects): expose project urls to html templates
  • Loading branch information
saadrahim authored Jun 20, 2023
2 parents 324fb58 + cc8001a commit 9da8618
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/rocm_docs/data/projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ projects:
roctracer: https://rocm.docs.amd.com/projects/roctracer/en/${version}
rocm-docs-core: https://rocm.docs.amd.com/projects/rocm-docs-core/en/${version}
rocm-validation-suite: https://rocm.docs.amd.com/projects/ROCmValidationSuite/en/${version}
rocm: https://rocm.docs.amd.com/en/develop/
rocm: https://rocm.docs.amd.com/en/${version}
rocprim: https://rocm.docs.amd.com/projects/rocPRIM/en/${version}
rocrand: https://rocm.docs.amd.com/projects/rocRAND/en/${version}
rocsolver: https://rocm.docs.amd.com/projects/rocSOLVER/en/${version}
Expand Down
14 changes: 12 additions & 2 deletions src/rocm_docs/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,20 @@ def _update_config(app: Sphinx, _: Config) -> None:
if not config_provided_by_user(app, "external_toc_path"):
app.config.external_toc_path = "./.sphinx/_toc.yml" # type: ignore[attr-defined]

context = _get_context(Path(app.srcdir), mapping)
formatting.format_toc(
Path(app.srcdir, app.config.external_toc_template_path),
Path(app.srcdir, app.config.external_toc_path),
_get_context(Path(app.srcdir), mapping),
context,
)
# Store the context to be referenced later
app.config.projects_context = context # type: ignore[attr-defined]


def _setup_projects_context(
app: Sphinx, _: str, __: str, context: Dict[str, Any], ___: Any
) -> None:
context["projects"] = app.config.projects_context["projects"]


def setup(app: Sphinx) -> Dict[str, Any]:
Expand Down Expand Up @@ -342,6 +351,7 @@ def external_toc_template_default(config: Config) -> str:

# This needs to happen before external-tocs's config-inited (priority=900)
app.connect("config-inited", _update_config)
app.connect("html-page-context", _setup_projects_context)
return {"parallel_read_safe": True, "parallel_write_safe": True}


Expand Down Expand Up @@ -369,7 +379,7 @@ def debug_projects() -> None:
formatting.format_toc(
toc_in,
toc_out,
_get_context(Path(), mapping),
context,
)


Expand Down
13 changes: 3 additions & 10 deletions src/rocm_docs/rocm_docs_theme/components/left-side-menu.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{% macro navbar_item(branch) -%}
{% if branch in ["develop", "amd-master", "amd-staging", "master"] %}
<a class="navbar-brand logo" href="https://rocm.docs.amd.com/en/develop">
{% else %}
<a class="navbar-brand logo" href="https://rocm.docs.amd.com/en/latest">
{% endif %}
<p>ROCm Documentation Home</p>
</a>
{%- endmacro -%}
{{ navbar_item(theme_repository_branch) }}
<a class="navbar-brand logo" href="{{ projects['rocm'] }}">
<p>ROCm Documentation Home</p>
</a>
2 changes: 1 addition & 1 deletion src/rocm_docs/rocm_docs_theme/sections/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="col-12 text-center">
<ul>
<li><a href="https://www.amd.com/en/corporate/copyright" target="_blank">Terms and Conditions</a></li>
<li><a href="https://rocm.docs.amd.com/en/latest/release/licensing.html">ROCm Licenses and Disclaimers</a></li>
<li><a href="{{ projects['rocm'] }}/release/licensing.html">ROCm Licenses and Disclaimers</a></li>
<li><a href="https://www.amd.com/en/corporate/privacy" target="_blank">Privacy</a></li>
<li><a href="https://www.amd.com/en/corporate/trademarks" target="_blank">Trademarks</a></li>
<li><a href="https://www.amd.com/system/files/documents/statement-human-trafficking-forced-labor.pdf" target="_blank">Statement on Forced Labor</a></li>
Expand Down
6 changes: 3 additions & 3 deletions src/rocm_docs/rocm_docs_theme/sections/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<div class="vr vr mx-40 my-25"></div>
{% macro top_level_header(branch) -%}
{% if branch in ["develop", "master", "main", "amd-master", "amd-staging"] %}
<a class="klavika-font hover-opacity" href="https://rocm.docs.amd.com/en/latest/">ROCm&#8482; Platform <i>Future Release</i></a>
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform <i>Future Release</i></a>
{% elif "5.6." in branch %}
<a class="klavika-font hover-opacity" href="https://rocm.docs.amd.com/en/latest/">ROCm&#8482; Platform <i>Release Candidate 5.6</i></a>
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform <i>Release Candidate 5.6</i></a>
{% else %}
<a class="klavika-font hover-opacity" href="https://rocm.docs.amd.com/en/latest/">ROCm&#8482; Platform <i>{{ branch }}</i></a>
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform <i>{{ branch }}</i></a>
{% endif %}
{%- endmacro -%}
{{ top_level_header(theme_repository_branch | replace("docs/", "")) }}
Expand Down

0 comments on commit 9da8618

Please sign in to comment.