Skip to content

feat: update gendocs to handle old version#2610

Merged
chmouel merged 1 commit intotektoncd:mainfrom
chmouel:feat-update-gendocs-to-handle-old-version
Mar 26, 2026
Merged

feat: update gendocs to handle old version#2610
chmouel merged 1 commit intotektoncd:mainfrom
chmouel:feat-update-gendocs-to-handle-old-version

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Mar 26, 2026

Implemented a versions.html page to list all available documentation
versions and added a static version selector link to replace the
deprecated dynamic dropdown. Incorporated legacy support for older Hugo
APIs and fixed broken image paths in configuration files to ensure
consistency across documentation releases.

see it live here https://docs.pipelinesascode.com/versions.html

📝 Description of the Change

🔗 Linked GitHub Issue

Fixes #

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Claude noreply@anthropic.com

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Implemented a `versions.html` page to list all available documentation
versions and added a static version selector link to replace the
deprecated dynamic dropdown. Incorporated legacy support for older Hugo
APIs and fixed broken image paths in configuration files to ensure
consistency across documentation releases.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the documentation generation process by modernizing how different versions are presented and maintained. It introduces a centralized page for version selection, improves compatibility with older Hugo versions, and ensures that image assets are correctly referenced across all generated documentation, leading to a more robust and user-friendly documentation experience.

Highlights

  • Documentation Versioning: Implemented a dedicated versions.html page to list all available documentation versions, replacing the previous dynamic dropdown selector with a static link.
  • Legacy Hugo API Support: Added a mechanism to patch deprecated Hugo API calls (resources.ToCSS, .Sites.First, .Site.IsMultiLingual) in generated HTML files, ensuring older documentation versions build correctly.
  • Image Path Consistency: Fixed broken image paths in configuration files and content for older documentation releases to ensure consistency.
  • Version Retention Policy: Introduced a keeplast variable to limit the number of major documentation versions kept, managing storage and relevance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@chmouel chmouel merged commit 7e6df69 into tektoncd:main Mar 26, 2026
1 of 2 checks passed
@chmouel chmouel deleted the feat-update-gendocs-to-handle-old-version branch March 26, 2026 08:30
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly enhances the documentation generation script (gendocs.sh) by introducing version management capabilities. It now limits the number of major versions kept, adds functions to replace the dynamic version selector with a static link to a new versions.html page, and addresses deprecated Hugo API calls for older branches. A new versions.html page is dynamically generated to list all available documentation versions, and the root index.html redirects to the latest version. Review comments suggest improving the maintainability of the generated versions.html by externalizing the HTML/CSS content from the shell script, making the keeplast variable a named constant, and using CSS classes instead of inline styles for better maintainability.

Comment on lines +93 to +230
cat <<EOF >${versiondir}/versions.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Pipelines as Code - All Versions</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
:root {
--bg: #0d1117;
--surface: #161b22;
--border: #30363d;
--text: #e6edf3;
--text-muted: #8b949e;
--accent: #58a6ff;
--green: #3fb950;
--green-bg: rgba(63,185,80,0.15);
--yellow: #d29922;
--yellow-bg: rgba(210,153,34,0.15);
}
@media (prefers-color-scheme: light) {
:root {
--bg: #f6f8fa;
--surface: #ffffff;
--border: #d0d7de;
--text: #1f2328;
--text-muted: #656d76;
--accent: #0969da;
--green: #1a7f37;
--green-bg: rgba(26,127,55,0.1);
--yellow: #9a6700;
--yellow-bg: rgba(154,103,0,0.1);
}
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
justify-content: center;
padding: 60px 20px;
}
.container { max-width: 520px; width: 100%; }
.header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 32px;
}
.logo {
width: 40px; height: 40px;
background: var(--accent);
border-radius: 10px;
display: flex; align-items: center; justify-content: center;
flex-shrink: 0;
}
.logo svg { width: 22px; height: 22px; fill: white; }
h1 { font-size: 22px; font-weight: 600; }
h1 span { display: block; font-size: 13px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
.version-list { display: flex; flex-direction: column; gap: 8px; }
.version-item {
display: flex; align-items: center; justify-content: space-between;
padding: 14px 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
text-decoration: none;
color: var(--text);
transition: border-color 0.15s, box-shadow 0.15s;
}
.version-item:hover {
border-color: var(--accent);
box-shadow: 0 0 0 1px var(--accent);
}
.version-name { font-weight: 500; font-size: 15px; }
.badge {
font-size: 11px; font-weight: 600;
padding: 3px 8px; border-radius: 20px;
text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-latest { background: var(--green-bg); color: var(--green); }
.badge-dev { background: var(--yellow-bg); color: var(--yellow); }
.arrow {
color: var(--text-muted);
transition: transform 0.15s;
flex-shrink: 0; margin-left: 8px;
}
.version-item:hover .arrow { transform: translateX(3px); color: var(--accent); }
.version-left { display: flex; align-items: center; gap: 10px; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<div class="logo">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M13.983 11.078h2.119a.186.186 0 0 0 .186-.186V9.006a.186.186 0 0 0-.186-.186h-2.119a.186.186 0 0 0-.187.186v1.886c0 .103.084.186.187.186m-2.954-5.43h2.118a.186.186 0 0 0 .187-.186V3.574a.186.186 0 0 0-.187-.186h-2.118a.186.186 0 0 0-.187.186v1.888c0 .103.083.186.187.186m0 5.43h2.118a.186.186 0 0 0 .187-.186V9.006a.186.186 0 0 0-.187-.186h-2.118a.186.186 0 0 0-.187.186v1.886c0 .103.083.186.187.186m-2.965 0h2.118a.186.186 0 0 0 .187-.186V9.006a.186.186 0 0 0-.187-.186H8.064a.186.186 0 0 0-.187.186v1.886c0 .103.084.186.187.186"/>
</svg>
</div>
<h1>Pipelines as Code<span>Documentation Versions</span></h1>
</div>
<div class="version-list">
<a href="/${latest}/" class="version-item">
<div class="version-left">
<span class="version-name">${latest}</span>
<span class="badge badge-latest">latest</span>
</div>
<svg class="arrow" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 3l5 5-5 5"/></svg>
</a>
<a href="/nightly/" class="version-item">
<div class="version-left">
<span class="version-name">nightly</span>
<span class="badge badge-dev">development</span>
</div>
<svg class="arrow" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 3l5 5-5 5"/></svg>
</a>
EOF

for v in ${output}; do
[[ "${v}" == "${latest}" ]] && continue
cat <<ITEM >>${versiondir}/versions.html
<a href="/${v}/" class="version-item">
<div class="version-left">
<span class="version-name">${v}</span>
</div>
<svg class="arrow" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 3l5 5-5 5"/></svg>
</a>
ITEM
done

cat <<EOF >>${versiondir}/versions.html
</div>
</div>
</body>
</html>
EOF
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Embedding a large block of HTML and CSS directly within a shell script using cat <<EOF makes the script very long and difficult to read, maintain, and debug. Any changes to the HTML structure or CSS styling require editing a multi-line string within a shell script, which is error-prone and lacks proper syntax highlighting or tooling support.

Consider moving this HTML/CSS content into a separate template file (e.g., versions.html.tmpl) and using a templating engine or a simpler sed command to inject dynamic values like ${latest} and loop through versions. This would significantly improve the maintainability and readability of the gendocs.sh script.

# Copyright 2024 Chmouel Boudjnah <chmouel@chmouel.com>
set -eufo pipefail
dir=/var/www/docs
keeplast=10
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The value 10 is a magic number. It would be more maintainable to define this as a named constant at the top of the script, or make it configurable via an environment variable, to improve readability and make its purpose clear.

Suggested change
keeplast=10
KEEPLAST_VERSIONS=10

Comment on lines +40 to +42
find "${target_dir}" -name '*.html' -type f -exec perl -0777 -i -pe '
s{<select[^>]*handleVersion[^>]*>.*?</select>.*?<script[^>]*>.*?handleVersion.*?</script>}
{<a href="/versions.html" style="text-decoration:none;padding:4px 10px;border:1px solid \x23ccc;border-radius:4px;display:inline-block">Other Versions</a>}gs;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using inline styles (style="text-decoration:none;padding:4px 10px;border:1px solid \x23ccc;border-radius:4px;display:inline-block") within the generated HTML is generally discouraged. It mixes presentation with structure, making the HTML harder to maintain and less flexible. Consider defining a CSS class for this styling and applying the class to the <a> tag instead.

Suggested change
find "${target_dir}" -name '*.html' -type f -exec perl -0777 -i -pe '
s{<select[^>]*handleVersion[^>]*>.*?</select>.*?<script[^>]*>.*?handleVersion.*?</script>}
{<a href="/versions.html" style="text-decoration:none;padding:4px 10px;border:1px solid \x23ccc;border-radius:4px;display:inline-block">Other Versions</a>}gs;
{<a href="/versions.html" class="version-selector-link">Other Versions</a>}gs;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant