Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented May 19, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the logic to ensure index pages are properly excluded from the sidebar when matching exclusion rules.
  • Chores

    • Updated configuration to focus on routes under "development/component-quickstart" instead of "install".
    • Added documentation for the patch update.

@JounQin JounQin requested a review from Copilot May 19, 2025 10:12
@JounQin JounQin self-assigned this May 19, 2025
@JounQin JounQin added the bug Something isn't working label May 19, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 19, 2025

⚠️ No Changeset found

Latest commit: 9b618b7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented May 19, 2025

Walkthrough

The update introduces a helper function to centralize route inclusion and exclusion logic for sidebar items, modifies how index pages are filtered, and updates configuration to refine which routes are included. Additionally, a changeset metadata file documents a patch fix for excluding index pages. No public API changes were made.

Changes

File(s) Change Summary
.changeset/thick-panthers-juggle.md Added a changeset file documenting a patch update for @alauda/doom regarding index page exclusion fix.
fixture-docs/doom.config.yml Updated onlyIncludeRoutes to focus on '*/development/component-quickstart/*' instead of '*/install/**'.
src/plugins/auto-sidebar/walk.ts Introduced isExcluded helper; unified and clarified sidebar filtering logic, especially for index items.

Sequence Diagram(s)

sequenceDiagram
    participant Config
    participant Sidebar
    participant isExcluded

    Config->>Sidebar: Provide onlyIncludeRoutes and excludeRoutes
    Sidebar->>isExcluded: Check if sidebar item (including index) should be excluded
    isExcluded-->>Sidebar: Return exclusion result
    Sidebar->>Sidebar: Filter items based on isExcluded
    Sidebar-->>Config: Return filtered sidebar
Loading

Poem

🐇
A hop, a skip, through routes anew,
Sidebar tidied, exclusions true.
Index pages filtered right,
Globs and helpers shining bright.
Patch notes written, configs tuned—
The docs now hop in perfect tune!


📜 Recent 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 7207111 and daed874.

📒 Files selected for processing (3)
  • .changeset/thick-panthers-juggle.md (1 hunks)
  • fixture-docs/doom.config.yml (1 hunks)
  • src/plugins/auto-sidebar/walk.ts (3 hunks)
🔇 Additional comments (5)
src/plugins/auto-sidebar/walk.ts (3)

46-57: Good refactoring with the new isExcluded helper function.

This is a nice refactoring that centralizes the filtering logic for sidebar items based on route inclusion and exclusion patterns. The implementation correctly handles both cases:

  1. When onlyIncludeRoutes is empty, all routes are considered initially included
  2. Otherwise, a route must match at least one pattern in onlyIncludeRoutes to be included
  3. Any route matching a pattern in excludeRoutes will be excluded regardless

This approach eliminates duplicated logic and makes the code more maintainable.


84-88: Good application of the new helper function.

The use of the isExcluded helper function here simplifies the code and makes it more readable compared to the previous inline implementation.


365-369: Critical fix for index page exclusion.

This change is the core fix for the issue with excluding index pages. Previously, the index page was always included in the sidebar if it existed, regardless of exclusion rules. Now, the index page is properly checked against inclusion/exclusion patterns, providing consistent behavior.

The bug is fixed by:

  1. Checking if the index has a file key
  2. Using the isExcluded helper to determine if it should be excluded
  3. Only including the index in the sidebar array if it's not excluded

This ensures that index pages follow the same filtering rules as other pages.

fixture-docs/doom.config.yml (1)

46-46: Configuration updated to narrow included routes.

The onlyIncludeRoutes configuration has been updated to use a more specific pattern, limiting routes to only those matching */development/component-quickstart/*. This change aligns with the sidebar filtering logic update and helps demonstrate that index pages are now correctly excluded.

.changeset/thick-panthers-juggle.md (1)

1-5: Appropriate changeset for patch release.

The changeset correctly documents this as a patch-level fix, which is appropriate for a bug fix that doesn't introduce breaking changes or new features. The description "fix: exclude index pages correctly" clearly communicates the purpose of the change.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors route inclusion/exclusion in the auto-sidebar plugin and updates the sample config.

  • Extract common exclude logic into an isExcluded helper
  • Apply the new helper in processSideMeta and top-level walk to correctly skip index pages
  • Add a new development route to onlyIncludeRoutes in the sample YAML

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/plugins/auto-sidebar/walk.ts Introduce isExcluded, use it for both nested sidebars and index
fixture-docs/doom.config.yml Add '*/development/component-quickstart/*' to onlyIncludeRoutes
Comments suppressed due to low confidence (3)

src/plugins/auto-sidebar/walk.ts:46

  • [nitpick] The helper name isExcluded is ambiguous; consider renaming to shouldExcludeRoute or isRouteExcluded for clarity.
const isExcluded = (

fixture-docs/doom.config.yml:45

  • The double hyphen creates a nested list of lists; onlyIncludeRoutes expects a flat array of strings. Change to - '*/install/**'.
-  - '*/install/**'

src/plugins/auto-sidebar/walk.ts:366

  • Optional chaining with double negation may be parsed incorrectly; wrap the check in parentheses or split into two conditions, e.g. const hasKey = !!(index?._fileKey); const isIndexExcluded = hasKey && isExcluded(...).
!!index?._fileKey &&

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 19, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@alauda/doom@23

commit: daed874

Signed-off-by: JounQin <admin@1stg.me>
@JounQin JounQin merged commit 41a5074 into main May 19, 2025
19 of 20 checks passed
@JounQin JounQin deleted the fix/exclude branch May 19, 2025 10:21
github-actions bot pushed a commit that referenced this pull request May 19, 2025
Comment on lines +365 to +369
const isIndexExcluded =
!!index?._fileKey &&
isExcluded(onlyIncludeRoutes, excludeRoutes, index._fileKey)

const sidebars = index && !isIndexExcluded ? [index, ...others] : others
Copy link
Member Author

@JounQin JounQin May 19, 2025

Choose a reason for hiding this comment

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

Suggested change
const isIndexExcluded =
!!index?._fileKey &&
isExcluded(onlyIncludeRoutes, excludeRoutes, index._fileKey)
const sidebars = index && !isIndexExcluded ? [index, ...others] : others
const sidebars = index?._fileKey &&! isExcluded(onlyIncludeRoutes, excludeRoutes, index._fileKey) ? [index, ...others] : others

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants