Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release version number to navbar #1083

Closed
wants to merge 16 commits into from

Conversation

jasonviviano
Copy link
Contributor

@jasonviviano jasonviviano commented Mar 13, 2024

Thank you for helping make the Radius documentation better!

Please follow this checklist before submitting:

  • Read the contribution guide
  • Commands include options for Linux, MacOS, and Windows within codetabs
  • New file and folder names are globally unique
  • Page references use shortcodes instead of markdown or URL links
  • Images use HTML style and have alternative text
  • Places where multiple code/command options are given have codetabs

In addition, please fill out the following to help reviewers understand this pull request:

Description

Currently we display latest as the version label to users when accessing the navigation bar:

Screenshot 2024-03-13 at 11 34 24 AM

This PR changes that to an actual version number so users are also more aware of the Radius release and exactly what version of docs they are accessing.

Screenshot 2024-03-13 at 11 34 11 AM

Issue reference

#556

Testing

I ran a shell script locally on a copy of the config.toml file the only lines changed are the chart_version param and version param

For a more specific call out the line:

awk -v REPLACEMENT="${VERSION_STRING_REPLACEMENT}" '{gsub(/^[ \t]*version = "(latest|v.*)"/, REPLACEMENT); print}' docs/config.toml > docs/config.toml.tmp

Looks for a line that contains version = "latest" or version = "v..." while accepting white spaces or tabs but not params such as tag_version which would be caught without the strict expression

The shell script modifications i made:

VERSION_NUMBER='0.33.3'

# VERSION is the version number prefixed by 'v' (e.g. v0.1.0)
VERSION="v${VERSION_NUMBER}"

# CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1)
CHANNEL="$(echo $VERSION_NUMBER | cut -d '.' -f 1,2)"

# CHANNEL_VERSION is the version with the 'v' prefix (e.g. v0.1)
CHANNEL_VERSION="v${CHANNEL}"

echo "Version number: ${VERSION_NUMBER}"
echo "Version: ${VERSION}"
echo "Channel: ${CHANNEL}"
echo "Channel version: ${CHANNEL_VERSION}"

# In docs/config.toml, change baseURL to https://docs.radapp.io/ instead of https://edge.docs.radapp.io/
awk '{gsub(/baseURL = \"https:\/\/edge\.docs\.radapp.io\/\"/,"baseURL = \"https:\/\/docs.radapp.io\/\""); print}' config.toml > config.toml.tmp
mv config.toml.tmp config.toml

# In docs/config.toml, change version to VERSION instead of edge
VERSION_STRING_REPLACEMENT="version = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${VERSION_STRING_REPLACEMENT}" '{gsub(/version = \"edge\"/, REPLACEMENT); print}' config.toml > config.toml.tmp
mv config.toml.tmp config.toml

# In docs/config.toml, change version to VERSION instead of latest or older version
VERSION_STRING_REPLACEMENT="version = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${VERSION_STRING_REPLACEMENT}" '{gsub(/^[ \t]*version = "(latest|v.*)"/, REPLACEMENT); print}' config.toml > config.toml.tmp
mv config.toml.tmp config.toml

# In docs/config.toml, change github_branch to CHANNEL_VERSION instead of edge
GITHUB_BRANCH_STRING_REPLACEMENT="github_branch = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${GITHUB_BRANCH_STRING_REPLACEMENT}" '{gsub(/github_branch = \"edge\"/, REPLACEMENT); print}' config.toml > config.toml.tmp
mv config.toml.tmp config.toml

# In docs/config.toml, change chart_version (Helm chart) to VERSION_NUMBER
CHART_VERSION_STRING_REPLACEMENT="chart_version = \"${VERSION_NUMBER}\""
awk -v REPLACEMENT="${CHART_VERSION_STRING_REPLACEMENT}" '{gsub(/chart_version = \"[^\n]+\"/, REPLACEMENT); print}' config.toml > config.toml.tmp
mv config.toml.tmp config.toml

The config.toml file result

baseURL = "https://docs.radapp.io/"
languageCode = "en-us"
title = "Radius Docs"
theme =  "docsy"

disableFastRender = true

# Ignore sample code
ignoreFiles = ["/code/*"]

# Google Analytics
[services.googleAnalytics]
id = "G-9JR8B6TPF9"

enableGitInfo = true

# Mounts
[module]
  [[module.mounts]]
    source = "content"
    target = "content"
  [[module.mounts]]
    source = "shared-content"
    target = "content"
  [[module.mounts]]
    source = "static"
    target = "static"
  [[module.mounts]]
    source = "layouts"
    target = "layouts"
  [[module.mounts]]
    source = "data"
    target = "data"
  [[module.mounts]]
    source = "assets"
    target = "assets"
  [[module.mounts]]
    source = "archetypes"
    target = "archetypes"

# Taxonomies
[taxonomies]
category = "categories"
tag = "tags"

# Top Nav Bar
[[menu.main]]
    name = "Home"
    weight = 10
    url = "https://radapp.io"
    pre = "<i class='fas fa-home'></i>"
[[menu.main]]
    name = "Blog"
    weight = 20
    url = "https://blog.radapp.io"
    pre = "<i class='fas fa-blog'></i>"
[[menu.main]]
    name = "GitHub"
    weight = 40
    url = "https://github.com/radius-project"
    pre = "<i class='fab fa-github'></i>"
[[menu.main]]
    name = "Discord"
    weight = 90
    url = "https://aka.ms/Radius/Discord"
    pre = "<i class='fab fa-discord'></i>"

[params]
copyright = "Radius"
version = "v0.33"
tag_version = "latest"
chart_version = "0.33.3"

# Algolia Search
algolia_docsearch = true

# GitHub Information
github_repo = "https://github.com/radius-project/docs"
github_subdir = "docs"
github_branch = "v0.31"
github_project_repo = "https://github.com/radius-project/radius"

# Versioning
version_menu = "Releases"
[[params.versions]]
  version = "edge (preview)"
  url = "https://edge.docs.radapp.io"

[[params.versions]]
version = "v0.33"
  url = "https://docs.radapp.io"

# Markdown Engine - Allow inline html
[markup]
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true

# UI Customization
[params.ui]
sidebar_menu_compact = true
sidebar_search_disable = true
sidebar_menu_foldable = true
sidebar_menu_truncate = 500
ul_show = 1
navbar_logo = true

[params.ui.feedback]
enable = true
yes = '<b>Glad to hear it!</b> Please feel free to <a href="https://github.com/radius-project/radius">star our repo</a> and join our <a href="https://aka.ms/radius/discord">Discord server</a> to stay up to date with the project.'
no = '<b>Sorry to hear that.</b> If you would like to also contribute a suggestion visit <a href="https://github.com/radius-project/docs/issues/new/choose"> and tell us how we can improve</a>.'

docs/config.toml Show resolved Hide resolved
@AaronCrawfis AaronCrawfis added the do-not-merge Do not merge this PR label Mar 13, 2024
@jasonviviano jasonviviano marked this pull request as draft March 13, 2024 18:27
@AaronCrawfis
Copy link
Contributor

Could you update this PR to also update the config.toml file with the current release, as if it were run previously?

Signed-off-by: jasonviviano <[email protected]>
Signed-off-by: jasonviviano <[email protected]>
@@ -53,6 +53,11 @@ VERSION_STRING_REPLACEMENT="version = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${VERSION_STRING_REPLACEMENT}" '{gsub(/version = \"edge\"/, REPLACEMENT); print}' docs/config.toml > docs/config.toml.tmp
mv docs/config.toml.tmp docs/config.toml

# In docs/config.toml, change version to CHANNEL_VERSION instead of latest or older version
DOC_VERSION_STRING_REPLACEMENT="version = \"${CHANNEL_VERSION}\""
awk -v REPLACEMENT="${DOC_VERSION_STRING_REPLACEMENT}" '{gsub(/^[ \t]*version = "(latest|v.*)"/, REPLACEMENT); print}' docs/config.toml > docs/config.toml.tmp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing this it looks like the indentation is off:
image

Copy link
Contributor Author

@jasonviviano jasonviviano Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the indentation is a stylistic choice here it doesn't affect the outcome, if you run the hugo server command the indentation has no effect on the variable value as it's just a text file. And looking at alternatives I can add an indentation to the awk command but that will end up indentation the other version variable above. So, it's just a stylistic choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the toml schema for more details: https://github.com/toml-lang/toml?tab=readme-ov-file#example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey i fixed it by changing the command!

Here's an explanation of the new one:
In this sed command:

-i.bak edits the file in place and creates a backup with the .bak extension.
-E enables extended regular expressions, which allow for more complex patterns.
The pattern ^( *)[ \t]version = "(latest|v.)" is used to match lines with version = "latest" or version = "v..."
^( )[ \t] captures leading spaces (or tabs) before version = and stores them in \1.
\1 in the replacement part puts the captured indentation back, ensuring the replacement line has the same leading whitespace as the original.
${DOC_VERSION_STRING_REPLACEMENT} is inserted after the captured whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a line after this to delete the tmp file created to pick up the whitespaces

Signed-off-by: jasonviviano <[email protected]>
Signed-off-by: jasonviviano <[email protected]>
@AaronCrawfis
Copy link
Contributor

Will the .bak file be cleaned up? Or will it be checked into the repo?

Signed-off-by: jasonviviano <[email protected]>
docs/config.toml Outdated Show resolved Hide resolved
docs/config.toml Outdated Show resolved Hide resolved
@jasonviviano
Copy link
Contributor Author

Will the .bak file be cleaned up? Or will it be checked into the repo?

Added a line to clean it up!

@AaronCrawfis
Copy link
Contributor

Thanks for taking a look at this and attempting a fix! I recommend we work with the engineering team and @sylvainsf on tackling this, as we're adding workarounds on top of workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge Do not merge this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants