Skip to content

Commit

Permalink
Merge pull request #271 from samjwu/latest-branch
Browse files Browse the repository at this point in the history
Version number for latest branch
  • Loading branch information
samjwu authored Jun 27, 2023
2 parents cc2d1bd + a7755ce commit a8248ba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/rocm_docs/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ def _get_context(
}


def _update_banner_config(
def _update_theme_configs(
app: Sphinx, current_project: str, branch: str, url: str
) -> None:
"""Update configurations for use in theme.py"""
schema_file_loc = "data/projects.schema.json"
schema_file = importlib_resources.files("rocm_docs") / schema_file_loc
with open(schema_file) as file:
Expand All @@ -306,16 +307,21 @@ def _update_banner_config(

latest_version = "5.5.1"
latest_version_string = f"docs-{latest_version}"
release_candidate = "5.6"
release_candidate_string = f"docs-{release_candidate}"
announcement_info = ""

if branch == latest_version_string:
if branch in [latest_version_string, "latest"]:
announcement_info = "This is the latest version of ROCm documentation."
elif branch.startswith("docs-"):
elif branch.startswith(release_candidate_string):
# turn off Python black for this line to prevent conflict with other Python linters
# fmt: off
announcement_info = "This page contains changes for a test release of ROCm. Read the <a href='https://rocm.docs.amd.com/en/latest/'>latest Linux release of ROCm documentation</a> for your production environments."
# fmt: on
elif branch.startswith("docs-"):
# fmt: off
announcement_info = "This is an old version of ROCm documentation. Read the <a href='https://rocm.docs.amd.com/en/latest/'>latest ROCm release documentation</a> to stay informed of all our developments."
# fmt: on

elif branch == development_branch:
# fmt: off
announcement_info = "This page contains proposed changes for a future release of ROCm. Read the <a href='https://rocm.docs.amd.com/en/latest/'>latest Linux release of ROCm documentation</a> for your production environments."
Expand Down Expand Up @@ -359,7 +365,7 @@ def _update_config(app: Sphinx, _: Config) -> None:
# Store the context to be referenced later
app.config.projects_context = context # type: ignore[attr-defined]

_update_banner_config(
_update_theme_configs(
app, current_project_name, context["branch"], context["url"]
)

Expand Down
14 changes: 8 additions & 6 deletions src/rocm_docs/rocm_docs_theme/sections/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@
<img src="{{ pathto('_static/images/amd-header-logo.svg',1) }}" alt="AMD Logo" title="AMD Logo" width="90" class="d-inline-block align-text-top hover-opacity"/>
</a>
<div class="vr vr mx-40 my-25"></div>
{% macro top_level_header(branch) -%}
{% macro top_level_header(branch, latest_version, release_candidate_version) -%}
{% if branch in ["develop", "master", "main", "amd-master", "amd-staging"] %}
<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="{{ projects['rocm'] }}">ROCm&#8482; Platform <i>Release Candidate 5.6</i></a>
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform Future Release</a>
{% elif release_candidate_version in branch %}
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform Release Candidate {{ release_candidate_version }}</a>
{% elif branch == "latest" %}
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform {{ latest_version }}</a>
{% else %}
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform <i>{{ branch }}</i></a>
<a class="klavika-font hover-opacity" href="{{ projects['rocm'] }}">ROCm&#8482; Platform {{ branch }}</a>
{% endif %}
{%- endmacro -%}
{{ top_level_header(theme_repository_branch | replace("docs-", "")) }}
{{ top_level_header(theme_repository_branch | replace("docs-", ""), theme_header_latest_version, theme_header_release_candidate) }}
</div>
<div class="icon-nav text-center d-flex ms-auto">
<!-- TODO: Search icon up here maybe? -->
Expand Down
3 changes: 3 additions & 0 deletions src/rocm_docs/rocm_docs_theme/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ show_navbar_depth = 1
show_toc_level = 1

link_main_doc = True

header_latest_version = 5.5.1
header_release_candidate = 5.6

0 comments on commit a8248ba

Please sign in to comment.