-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add editRepoBaseUrl config and -R, --edit-repo cli flag support
#9
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
Conversation
🦋 Changeset detectedLatest commit: d2ffe6a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
WalkthroughThe changes introduce support for an Changes
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)
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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,
commit: |
There was a problem hiding this 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 renamingTRUSY_VALUEStoTRUTHY_VALUESThere appears to be a typo in the constant name. The conventional spelling would be
TRUTHY_VALUESrather thanTRUSY_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
📒 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 formattingThe refactoring of
FALSY_VALUESinto a multi-line format improves readability, and the addition ofnullandundefinedas explicit falsy values is a good enhancement.
17-25: LGTM! Consistent update to JS_STR_FALSY_VALUESAdding
nullandundefinedto this set ensures consistency with theFALSY_VALUESset above.doom.config.yml (1)
22-22: LGTM! Well-formed configuration additionThe new
editRepoBaseUrlconfiguration 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 workflowAdding the
-Rflag 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 environmentsThe
editRepoBaseUrlconfiguration 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 documentationThe 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 helperThe
defaultGitHubUrlhelper function correctly normalizes GitHub repository URLs by:
- Preserving URLs already starting with HTTP/HTTPS protocols
- Adding
https://github.com/prefix for repository paths- Properly handling leading slashes and any redundant
github.comprefixThis is a clean implementation that handles all common URL formatting variations.
docs/start.mdx (1)
99-99: Documentation matches implementation of new CLI flagThe 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
defaultGitHubUrlhelper function.docs/usage/configuration.md (1)
206-210: Clear documentation for the new configuration optionThe section provides concise documentation for the
editRepoBaseUrlconfiguration option, explaining:
- The correct YAML syntax for the configuration
- That the GitHub URL prefix can be omitted
- 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
whencondition 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.
…port close IDP-1166
There was a problem hiding this 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
📒 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_CONFIGStype has been properly updated to include theeditLinkproperty 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
editRepoparameter 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:
- Extracts the URL from config
- Handles boolean and string values from CLI
- Normalizes URLs using the helper function
- 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
editRepoparameter is properly passed fromloadConfigtogetCommonConfig.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.
close IDP-1166
Summary by CodeRabbit
New Features
editRepoBaseUrlconfiguration option, allowing users to specify a base URL for editing documentation in their repository.-R, --edit-repo [boolean|url]to enable or override the edit repository feature.Documentation
editRepoBaseUrloption and CLI flag.Chores