Skip to content

fix: solvee the header related issue #249

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

Merged
merged 1 commit into from
May 16, 2025
Merged

Conversation

mayurkmmt
Copy link
Collaborator

@mayurkmmt mayurkmmt commented May 16, 2025

Summary by CodeRabbit

  • Chores

    • Removed the automated management of the robots.txt file from the deployment workflow.
  • Refactor

    • Updated documentation header template structure for improved maintainability, without changing visible behavior.
  • Style

    • Simplified the logic for displaying the outdated documentation banner, ensuring it now appears on all non-homepage pages with a direct link to the latest version.

Copy link

coderabbitai bot commented May 16, 2025

Walkthrough

The changes remove a GitHub Actions workflow step that managed the robots.txt file on the gh-pages branch, refactor a documentation header template to use inheritance and block structure, and simplify the logic for displaying an outdated documentation banner by making it unconditional on non-homepages and updating its link to an absolute URL.

Changes

File(s) Change Summary
.github/workflows/gh-page.yml Removed the workflow step handling robots.txt creation, commit, and push to gh-pages.
docs/overrides/partials/header.html Refactored to extend base.html, wrapped script in {% block header %} with {{ super() }}; script unchanged.
docs/overrides/partials/outdated.html Simplified logic: banner now always shows on non-homepages; link updated to absolute latest version URL.

Poem

A hop and a skip, the robots.txt is gone,
Templates now inherit, with blocks to build upon.
Outdated banners wave on every page anew,
While rabbits in the docs burrow straight through!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
docs/overrides/partials/header.html (2)

6-7: Consider externalizing inline scripts for caching
Embedding JavaScript directly in the template limits caching and minification opportunities. Extract this logic into a separate .js file (e.g., _static/version-selector.js) and load it with:

<script defer src="{{ pathto('_static/version-selector.js') }}"></script>

within the header block to improve performance and manageability.


13-15: Robust version detection using URL API
The regex check can pick up latest in query strings or other URL parts. Consider using the URL API to parse and inspect path segments explicitly:

const url = new URL(window.location.href);
const segments = url.pathname.split('/').filter(Boolean);
const isLatestVersion = segments.includes('latest');

This makes the logic clearer and less error-prone.

docs/overrides/partials/outdated.html (1)

5-7: Avoid hard-coded absolute URLs
Linking directly to https://pyretailscience.datasimply.co/latest/ couples the template to a specific domain. Use a templated base URL (e.g., {{ config.site_url }}) or a relative path ({{ pathto('latest/') }}) so the link adapts across environments (staging, production, custom domains).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 95cb540 and eab3c47.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/gh-page.yml (0 hunks)
  • docs/overrides/partials/header.html (1 hunks)
  • docs/overrides/partials/outdated.html (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/gh-page.yml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Pre-Commit
🔇 Additional comments (1)
docs/overrides/partials/header.html (1)

1-5: Proper use of template inheritance
Extending base.html and encapsulating the header content within {% block header %}, while preserving the parent block with {{ super() }}, is a solid approach that enhances maintainability and ensures shared layout isn’t duplicated.

Comment on lines +9 to +20
var versionSelector = document.querySelector('.md-header__topic .md-ellipsis');

if (versionSelector) {
// Get current version from the URL
var currentPath = window.location.pathname;
var isLatestVersion = currentPath.includes('/latest/') ||
(window.location.href.includes('latest') && !window.location.href.match(/\/\d+\.\d+\.\d+\//));

// If this is the latest version or has the latest alias, change the displayed text
if (isLatestVersion) {
var originalText = versionSelector.textContent;
versionSelector.textContent = originalText.replace(/\d+\.\d+\.\d+/, 'latest');
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use modern const/let instead of var
Switch the var declarations (versionSelector, currentPath, isLatestVersion) to const (or let if reassignment is needed) to leverage block scoping and prevent hoisting surprises.

- var versionSelector = document.querySelector('.md-header__topic .md-ellipsis');
+ const versionSelector = document.querySelector('.md-header__topic .md-ellipsis');
- var currentPath = window.location.pathname;
+ const currentPath = window.location.pathname;
- var isLatestVersion = currentPath.includes('/latest/') ||
-                       (window.location.href.includes('latest') && !window.location.href.match(/\/\d+\.\d+\.\d+\//));
+ const isLatestVersion = currentPath.includes('/latest/') ||
+                         (window.location.href.includes('latest') && !window.location.href.match(/\/\d+\.\d+\.\d+\//));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var versionSelector = document.querySelector('.md-header__topic .md-ellipsis');
if (versionSelector) {
// Get current version from the URL
var currentPath = window.location.pathname;
var isLatestVersion = currentPath.includes('/latest/') ||
(window.location.href.includes('latest') && !window.location.href.match(/\/\d+\.\d+\.\d+\//));
// If this is the latest version or has the latest alias, change the displayed text
if (isLatestVersion) {
var originalText = versionSelector.textContent;
versionSelector.textContent = originalText.replace(/\d+\.\d+\.\d+/, 'latest');
const versionSelector = document.querySelector('.md-header__topic .md-ellipsis');
if (versionSelector) {
// Get current version from the URL
const currentPath = window.location.pathname;
const isLatestVersion = currentPath.includes('/latest/') ||
(window.location.href.includes('latest') && !window.location.href.match(/\/\d+\.\d+\.\d+\//));
// If this is the latest version or has the latest alias, change the displayed text
if (isLatestVersion) {
var originalText = versionSelector.textContent;
versionSelector.textContent = originalText.replace(/\d+\.\d+\.\d+/, 'latest');
🤖 Prompt for AI Agents
In docs/overrides/partials/header.html between lines 9 and 20, replace all var
declarations for versionSelector, currentPath, and isLatestVersion with const if
they are not reassigned, or let if reassignment occurs. This change will use
modern block-scoped variable declarations to improve code clarity and prevent
hoisting issues.

Comment on lines 1 to 9
<div class="md-banner md-banner--warning">
{% if config.extra.version and config.extra.version.provider == 'mike' %}
{% if mike and (mike.version.aliases | length == 0 or "latest" not in mike.version.aliases) %}
<div class="md-banner__inner md-typeset">
<strong>You're viewing an older version of the PyRetailScience documentation.</strong>
<a href="{{ '/' | url }}../latest/">
<strong>Click here to go to the latest stable version.</strong>
</a>
</div>
{% endif %}
{% if not page.is_homepage %}
<div class="md-banner__inner md-typeset">
<strong>You're viewing an older version of the PyRetailScience documentation.</strong>
<a href="https://pyretailscience.datasimply.co/latest/">
<strong>Click here to go to the latest stable version.</strong>
</a>
</div>
{% endif %}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Prevent empty banner on the homepage
The <div class="md-banner md-banner--warning"> wrapper is always rendered, but its inner content is conditional on not page.is_homepage, leaving an empty element on the homepage. Move the {% if not page.is_homepage %} to wrap the entire banner block (both opening and closing <div>) to avoid rendering empty containers:

- <div class="md-banner md-banner--warning">
-   {% if not page.is_homepage %}
-   <div class="md-banner__inner md-typeset">
-
-   </div>
-   {% endif %}
- </div>
+ {% if not page.is_homepage %}
+ <div class="md-banner md-banner--warning">
+   <div class="md-banner__inner md-typeset">
+
+   </div>
+ </div>
+ {% endif %}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div class="md-banner md-banner--warning">
{% if config.extra.version and config.extra.version.provider == 'mike' %}
{% if mike and (mike.version.aliases | length == 0 or "latest" not in mike.version.aliases) %}
<div class="md-banner__inner md-typeset">
<strong>You're viewing an older version of the PyRetailScience documentation.</strong>
<a href="{{ '/' | url }}../latest/">
<strong>Click here to go to the latest stable version.</strong>
</a>
</div>
{% endif %}
{% if not page.is_homepage %}
<div class="md-banner__inner md-typeset">
<strong>You're viewing an older version of the PyRetailScience documentation.</strong>
<a href="https://pyretailscience.datasimply.co/latest/">
<strong>Click here to go to the latest stable version.</strong>
</a>
</div>
{% endif %}
{% if not page.is_homepage %}
<div class="md-banner md-banner--warning">
<div class="md-banner__inner md-typeset">
<strong>You're viewing an older version of the PyRetailScience documentation.</strong>
<a href="https://pyretailscience.datasimply.co/latest/">
<strong>Click here to go to the latest stable version.</strong>
</a>
</div>
</div>
{% endif %}
🤖 Prompt for AI Agents
In docs/overrides/partials/outdated.html around lines 1 to 9, the md-banner div
is always rendered but its inner content is conditional, causing an empty banner
on the homepage. Move the {% if not page.is_homepage %} condition to wrap the
entire md-banner div block, including both the opening and closing tags, so the
banner is only rendered when not on the homepage, preventing empty containers.

Copy link

codecov bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mayurkmmt mayurkmmt merged commit 8f7b9af into main May 16, 2025
3 checks passed
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