Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented May 12, 2025

close IDP-1166

Summary by CodeRabbit

  • New Features

    • Added support for an editRepoBaseUrl configuration option, allowing users to specify a base URL for editing documentation in their repository.
    • Introduced a new CLI flag -R, --edit-repo [boolean|url] to enable or override the edit repository feature.
    • Documentation and configuration files updated to describe and support the new edit link functionality.
  • Documentation

    • Added sections explaining the new editRepoBaseUrl option and CLI flag.
    • Provided localized edit link text for multiple languages.
  • Chores

    • Updated workflow to accommodate new CLI flag during documentation build.

@JounQin JounQin requested a review from Copilot May 12, 2025 10:48
@JounQin JounQin self-assigned this May 12, 2025
@JounQin JounQin added the enhancement New feature or request label May 12, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 12, 2025

🦋 Changeset detected

Latest commit: d2ffe6a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@alauda/doom Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link

coderabbitai bot commented May 12, 2025

Walkthrough

The changes introduce support for an editRepoBaseUrl configuration option and a new CLI flag -R, --edit-repo, enabling users to specify or override the base URL for editing documentation in a repository. Documentation, configuration files, CLI logic, and type definitions are updated to accommodate this feature, including localized edit link support.

Changes

Files/Group Change Summary
.github/workflows/gh-pages.yml Updated the documentation build command to include the -R flag (yarn docs:build -d -R).
docs/start.mdx, docs/usage/configuration.md Added documentation for the new -R, --edit-repo CLI option and the editRepoBaseUrl configuration, including a new section on editing documentation in the repository.
doom.config.yml, fixture-docs/doom.config.yml Added the editRepoBaseUrl key to specify the repository path for editing documentation.
src/cli/helpers.ts Added and exported defaultGitHubUrl function to normalize repository URLs.
src/cli/index.ts Introduced the `-R, --edit-repo [boolean
src/cli/load-config.ts Extended configuration loading to support the editRepo option, localized edit link text, and error handling for missing URLs.
src/cli/new.ts Modified conditional logic to remove non-null assertion in a check for falsy values.
src/shared/constants.ts Expanded FALSY_VALUES to include null and undefined, introduced TRUTHY_VALUES, and updated JS_STR_FALSY_VALUES.
src/types.ts Updated GlobalCliOptions and UserConfig interfaces to support editRepo and editRepoBaseUrl.
.changeset/silent-moles-yell.md Added a patch note describing the new feature for editing repository base URLs via config and CLI.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ConfigLoader
    participant DocsBuilder

    User->>CLI: Run command with -R/--edit-repo [value]
    CLI->>ConfigLoader: Load config (passes editRepo option)
    ConfigLoader->>ConfigLoader: Normalize editRepoBaseUrl (if enabled)
    ConfigLoader->>CLI: Return config with editRepo info
    CLI->>DocsBuilder: Build docs with editRepoBaseUrl (if provided)
    DocsBuilder->>User: Documentation with "Edit on GitHub" links (if enabled)
Loading

Poem

In the warren of code, a new path appears,
With -R and a URL, editing draws near.
Now “Edit on GitHub” hops into view,
Configs and docs all shiny and new.
A bunny’s delight, this feature’s release—
Edit links enabled, documentation with ease!
🐇✨

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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 adds configuration support for editing repository pages by introducing a new config value (editRepoBaseUrl) and a CLI flag (-R, --edit-repo) that allows users to enable or override the default GitHub URL for editing. Key changes include:

  • Extending the configuration types (and schema in shared modules) to include editRepo and editRepoBaseUrl.
  • Adding a CLI flag to process the editRepo parameter and update workflows accordingly.
  • Updating documentation and YAML configuration samples to reflect the new feature.

Reviewed Changes

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

Show a summary per file
File Description
src/types.ts Updated types to support the new editRepo and editRepoBaseUrl keys.
src/shared/constants.ts Modified FALSY_VALUES and added TRUSY_VALUES with expanded values.
src/cli/new.ts Removed non-null assertion for a more robust check.
src/cli/load-config.ts Extended config parsing to handle editRepo and compute editRepoBaseUrl.
src/cli/index.ts Added support for the new CLI flag (-R, --edit-repo).
src/cli/helpers.ts Implemented helper (defaultGitHubUrl) for processing the base URL.
fixture-docs/doom.config.yml & doom.config.yml Updated sample configs with the new editRepoBaseUrl option.
docs/usage/configuration.md & docs/start.mdx Added documentation for the new editRepo feature.
.github/workflows/gh-pages.yml Updated workflow command to pass the new CLI flag.
Comments suppressed due to low confidence (1)

src/cli/load-config.ts:189

  • [nitpick] The object spread order for editLink may cause unintended property overwrites if the default and locale-specific configurations have overlapping keys. Verify and document the intended precedence of these properties.
editLink: editRepoEnabled && editRepoBaseUrl ? { docRepoBaseUrl: editRepoBaseUrl, ...KNOWN_LOCALE_CONFIGS.en!.editLink, ...KNOWN_LOCALE_CONFIGS[name]?.editLink, } : undefined,

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 12, 2025

Open in StackBlitz

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

commit: d2ffe6a

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: 0

♻️ Duplicate comments (1)
src/cli/index.ts (1)

98-104: Consider refining the transform callback for clarity.

The transform callback returns different types based on the input which may lead to less predictable behavior.

-  (value: string) =>
-    FALSY_VALUES.has(value) ? false : TRUSY_VALUES.has(value) || value,
+  (value: string) => {
+    if (FALSY_VALUES.has(value)) {
+      return false;
+    } else if (TRUSY_VALUES.has(value)) {
+      return true;
+    }
+    return value;
+  },
🧹 Nitpick comments (2)
src/shared/constants.ts (1)

15-15: Consider renaming TRUSY_VALUES to TRUTHY_VALUES

There appears to be a typo in the constant name. The conventional spelling would be TRUTHY_VALUES rather than TRUSY_VALUES.

-export const TRUSY_VALUES = new Set(['1', 'true', 'yes', 'on', 'y', 't'])
+export const TRUTHY_VALUES = new Set(['1', 'true', 'yes', 'on', 'y', 't'])
src/cli/load-config.ts (1)

27-27: Resolve the module import warning.

There's an ESLint warning about not being able to resolve the 'yoctocolors' module.

#!/bin/bash
# Check if yoctocolors is properly installed
npm list yoctocolors
# Check for potential typos in package name
npm search yocto
🧰 Tools
🪛 ESLint

[error] 27-27: Unable to resolve path to module 'yoctocolors'.

(import-x/no-unresolved)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ec6573 and 14a00bf.

📒 Files selected for processing (12)
  • .changeset/rude-ties-explain.md (1 hunks)
  • .github/workflows/gh-pages.yml (1 hunks)
  • docs/start.mdx (1 hunks)
  • docs/usage/configuration.md (1 hunks)
  • doom.config.yml (1 hunks)
  • fixture-docs/doom.config.yml (1 hunks)
  • src/cli/helpers.ts (1 hunks)
  • src/cli/index.ts (2 hunks)
  • src/cli/load-config.ts (12 hunks)
  • src/cli/new.ts (1 hunks)
  • src/shared/constants.ts (1 hunks)
  • src/types.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/cli/new.ts (1)
src/shared/constants.ts (1)
  • JS_STR_FALSY_VALUES (17-25)
src/cli/index.ts (1)
src/shared/constants.ts (2)
  • FALSY_VALUES (3-13)
  • TRUSY_VALUES (15-15)
🪛 ESLint
src/cli/load-config.ts

[error] 27-27: Unable to resolve path to module 'yoctocolors'.

(import-x/no-unresolved)

🔇 Additional comments (18)
src/shared/constants.ts (2)

3-13: LGTM! Improved clarity with multi-line formatting

The refactoring of FALSY_VALUES into a multi-line format improves readability, and the addition of null and undefined as explicit falsy values is a good enhancement.


17-25: LGTM! Consistent update to JS_STR_FALSY_VALUES

Adding null and undefined to this set ensures consistency with the FALSY_VALUES set above.

doom.config.yml (1)

22-22: LGTM! Well-formed configuration addition

The new editRepoBaseUrl configuration looks good and aligns with the feature described in the PR objectives. The value correctly points to the docs directory in the repository.

.github/workflows/gh-pages.yml (1)

40-40: LGTM! Proper integration with GitHub Pages workflow

Adding the -R flag to enable the edit repository feature during documentation builds is appropriate. This ensures the feature is active in the deployed GitHub Pages site.

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

48-48: LGTM! Consistent configuration across environments

The editRepoBaseUrl configuration is correctly set for the fixture docs, pointing to the appropriate directory path. This maintains consistency with the main configuration file.

.changeset/rude-ties-explain.md (1)

1-6: LGTM - Proper changeset for feature documentation

The changeset correctly documents the new feature as a patch update, with a clear and concise description of the added functionality.

src/cli/helpers.ts (1)

47-50: Well-implemented GitHub URL normalization helper

The defaultGitHubUrl helper function correctly normalizes GitHub repository URLs by:

  1. Preserving URLs already starting with HTTP/HTTPS protocols
  2. Adding https://github.com/ prefix for repository paths
  3. Properly handling leading slashes and any redundant github.com prefix

This is a clean implementation that handles all common URL formatting variations.

docs/start.mdx (1)

99-99: Documentation matches implementation of new CLI flag

The CLI flag documentation clearly explains the purpose, format options (boolean or URL), default value, and relationship to the configuration option. It also notes that the GitHub URL prefix can be omitted, which aligns with the defaultGitHubUrl helper function.

docs/usage/configuration.md (1)

206-210: Clear documentation for the new configuration option

The section provides concise documentation for the editRepoBaseUrl configuration option, explaining:

  1. The correct YAML syntax for the configuration
  2. That the GitHub URL prefix can be omitted
  3. That the feature is only activated when the CLI flag is enabled

This aligns well with the implementation and CLI documentation.

src/cli/new.ts (1)

224-224: Improved handling of falsy values.

The change removes a non-null assertion and now properly handles null and undefined values in the when condition check, making the code more robust.

src/cli/index.ts (1)

16-16: Good addition of falsy/truthy value sets.

Importing these sets provides consistent boolean-like string handling across the codebase.

src/types.ts (2)

31-32: Proper typing for new CLI options.

The types correctly support the new CLI options, including the enhanced redirect options and the new editRepo parameter.


53-53: Good addition of editRepoBaseUrl configuration property.

The new property aligns with the PR objective to support repository editing capabilities.

src/cli/load-config.ts (5)

62-65: Clear type definitions for edit link functionality.

The updated type correctly includes the editLink property with localization support.


69-71: Well-defined localized edit link texts.

Good addition of localized edit link texts for all supported languages, providing a consistent user experience.

Also applies to: 81-83, 94-96


145-161: Robust handling of edit repository configuration.

The implementation correctly processes both boolean flags and URL strings, normalizes GitHub URLs, and provides clear error messaging when the flag is enabled without a URL.


188-196: Conditionally adding edit links to locales.

Good implementation that only adds edit links when the feature is enabled and a valid repository URL is provided.


238-245: Correctly handling fallback Chinese locale.

The implementation properly handles the special case of the fallback Chinese locale when edit links are enabled.

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14a00bf and d2ffe6a.

📒 Files selected for processing (12)
  • .changeset/silent-moles-yell.md (1 hunks)
  • .github/workflows/gh-pages.yml (1 hunks)
  • docs/start.mdx (1 hunks)
  • docs/usage/configuration.md (1 hunks)
  • doom.config.yml (1 hunks)
  • fixture-docs/doom.config.yml (1 hunks)
  • src/cli/helpers.ts (1 hunks)
  • src/cli/index.ts (2 hunks)
  • src/cli/load-config.ts (12 hunks)
  • src/cli/new.ts (1 hunks)
  • src/shared/constants.ts (1 hunks)
  • src/types.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • doom.config.yml
🚧 Files skipped from review as they are similar to previous changes (9)
  • fixture-docs/doom.config.yml
  • src/cli/helpers.ts
  • docs/start.mdx
  • src/cli/new.ts
  • src/cli/index.ts
  • .github/workflows/gh-pages.yml
  • docs/usage/configuration.md
  • src/types.ts
  • src/shared/constants.ts
🧰 Additional context used
🪛 ESLint
src/cli/load-config.ts

[error] 27-27: Unable to resolve path to module 'yoctocolors'.

(import-x/no-unresolved)

🔇 Additional comments (9)
src/cli/load-config.ts (8)

57-57: LGTM!

Good practice to import the helper function for GitHub URL normalization.


61-66: Type definition correctly extended to support the editLink feature.

The KNOWN_LOCALE_CONFIGS type has been properly updated to include the editLink property with a text field.


69-71: LGTM! Well-structured localized edit links.

The edit link text has been properly localized for all supported languages (English, Chinese, and Russian).

Also applies to: 81-83, 94-96


115-115: Function parameter properly typed and documented.

The editRepo parameter is correctly added to the function signature with appropriate typing.

Also applies to: 131-132


145-161: LGTM! Well-implemented edit repository URL handling.

The logic correctly:

  1. Extracts the URL from config
  2. Handles boolean and string values from CLI
  3. Normalizes URLs using the helper function
  4. Provides a helpful error message when the flag is enabled but no URL is provided

188-196: LGTM! Conditionally adds edit links to locale configurations.

The edit link is correctly added to locale configurations only when the feature is enabled and a valid URL is provided.


205-205: LGTM! Properly handles Chinese locale fallback.

The code correctly destructures the Chinese locale configuration and conditionally includes the edit link in the fallback case.

Also applies to: 238-245


342-342: LGTM! Parameter correctly propagated through the config loading flow.

The editRepo parameter is properly passed from loadConfig to getCommonConfig.

Also applies to: 421-422

.changeset/silent-moles-yell.md (1)

1-6: LGTM! Clear and concise changeset message.

The changeset correctly indicates this is a patch release and clearly describes the feature being added.

@JounQin JounQin merged commit 0de1845 into main May 12, 2025
16 checks passed
@JounQin JounQin deleted the feat/edit branch May 12, 2025 11:12
github-actions bot pushed a commit that referenced this pull request May 12, 2025
@coderabbitai coderabbitai bot mentioned this pull request May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants