-
Notifications
You must be signed in to change notification settings - Fork 2
feat: support export single entry as PDF #100
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: e858007 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 |
WalkthroughThis update introduces support for exporting individual documentation entries as PDF files, configurable via new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant ConfigLoader
participant PDFGenerator
participant FileSystem
User->>CLI: Run export command
CLI->>ConfigLoader: Load config (with export entries)
ConfigLoader->>CLI: Return config with expanded export entries
CLI->>PDFGenerator: For each export entry, generate PDF
PDFGenerator->>FileSystem: Read entry files
PDFGenerator->>FileSystem: Write generated PDFs
CLI->>FileSystem: Cleanup temp directory
CLI->>User: Output exported PDF paths
Suggested labels
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/cli/load-config.tsOops! Something went wrong! :( ESLint: 9.30.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/eslint.js' imported from /eslint.config.js src/cli/export-pdf-core/generatePdf.tsOops! Something went wrong! :( ESLint: 9.30.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/eslint.js' imported from /eslint.config.js src/runtime/translation.tsOops! Something went wrong! :( ESLint: 9.30.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/eslint.js' imported from /eslint.config.js
✨ Finishing Touches
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. 🪧 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 support for exporting a single entry as a PDF by introducing a new ExportItem interface and integrating export configuration into multiple parts of the codebase, including CLI commands, theme layout, and documentation.
- Adds ExportItem type and export property to user configuration
- Updates the theme layout and sidebar logic to utilize the new export settings
- Enhances CLI and PDF generation logic to support custom PDF export functionality
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Added ExportItem type and updated configuration interfaces |
| src/theme.tsx | Modified sidebar resolution using virtual.export and layout logic |
| src/runtime/translation.ts | Added new translation keys for PDF export |
| src/plugins/global/index.ts | Integrated export property to global plugin options |
| src/global/VersionsNav/index.tsx | Adjusted PDF link composition for version navigation |
| src/cli/load-config.ts | Normalized export entries using globSync |
| src/cli/export.ts | Updated export command with new exportEntries and custom PDF naming |
| src/cli/export-pdf-core/utils/mergePDF.ts | Refactored path joining and error handling in PDF merging |
| src/cli/export-pdf-core/generatePdf.ts | Added cleanupTempDir and outline mapping options in PDF generation |
| fixture-docs/doom.config.yml | Added sample configuration entries for PDF export |
| docs/zh/usage/configuration.md, etc. | Updated documentation to cover the new PDF export configuration |
Comments suppressed due to low confidence (2)
src/cli/load-config.ts:354
- The 'entry' property of ExportItem is defined as a string or string[], however globSync is called with item.entry directly. Consider normalizing the value (e.g. converting an array to a comma-separated string or mapping over each string) to ensure correct glob matching.
export: config.export?.map((item) => ({
src/theme.tsx:29
- [nitpick] Consider renaming 'getClosestSidebar_' to a more descriptive identifier, such as 'findMatchingSidebar', to improve readability and clarify its purpose.
const getClosestSidebar_ = (
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/theme.tsx (1)
59-68: Add null check before iterating over virtual.export.The non-null assertion on
virtual.export!could cause runtime errors if the export configuration is undefined.const getClosestSidebar = (sidebarItems: DoomSidebar[], pathname: string) => { - for (const item of virtual.export!) { + if (!virtual.export) { + return + } + for (const item of virtual.export) { const found = getClosestSidebar_( sidebarItems, pathname, item.entry as string[], ) if (found) { return { sidebar: found, exportItem: item, } } } }
🧹 Nitpick comments (2)
.changeset/spicy-glasses-own.md (1)
5-5: Consider minor grammar improvement.The description is clear, but could be slightly improved for better grammar.
Consider this minor revision:
-feat: support export single entry as PDF +feat: support exporting single entry as PDFdocs/en/start.mdx (1)
178-178: Fix grammatical issue with "otherwise".The word "otherwise" is an adverb and shouldn't be used as a conjunction. Consider rephrasing for better grammar.
-- The `-g, --glob` parameter is required and can specify the directories or paths of files to translate, supporting `glob` syntax. Note that the parameter value must be quoted, otherwise it may be parsed unexpectedly by the command line. Examples: +- The `-g, --glob` parameter is required and can specify the directories or paths of files to translate, supporting `glob` syntax. Note that the parameter value must be quoted; otherwise, it may be parsed unexpectedly by the command line. Examples:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
.changeset/spicy-glasses-own.md(1 hunks)docs/en/start.mdx(9 hunks)docs/en/usage/configuration.md(10 hunks)docs/zh/start.mdx(1 hunks)docs/zh/usage/configuration.md(1 hunks)fixture-docs/doom.config.yml(1 hunks)src/cli/export-pdf-core/generatePdf.ts(4 hunks)src/cli/export-pdf-core/utils/mergePDF.ts(3 hunks)src/cli/export.ts(4 hunks)src/cli/load-config.ts(3 hunks)src/global/VersionsNav/index.tsx(2 hunks)src/plugins/global/index.ts(3 hunks)src/runtime/translation.ts(3 hunks)src/theme.tsx(1 hunks)src/types.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: JounQin has mentioned multiple times that the alauda/doom project uses yarn v4, and there are no ESLint import resolution errors for @rspress/core subpath imports.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
.changeset/spicy-glasses-own.md (1)
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
src/plugins/global/index.ts (4)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In @rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from '@rspress/core/theme'` are valid even if ESLint shows resolution errors.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: JounQin has mentioned multiple times that the alauda/doom project uses yarn v4, and there are no ESLint import resolution errors for @rspress/core subpath imports.
src/global/VersionsNav/index.tsx (3)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In @rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from '@rspress/core/theme'` are valid even if ESLint shows resolution errors.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
docs/zh/usage/configuration.md (1)
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
fixture-docs/doom.config.yml (1)
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
docs/en/start.mdx (6)
Learnt from: JounQin
PR: alauda/doom#75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:22:30.004Z
Learning: In the @alauda/doom project, the team prefers throwing descriptive errors for invalid configuration rather than using optional chaining or graceful fallbacks. This fail-fast approach helps catch configuration issues early during development.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: JounQin has mentioned multiple times that the alauda/doom project uses yarn v4, and there are no ESLint import resolution errors for @rspress/core subpath imports.
Learnt from: JounQin
PR: alauda/doom#34
File: src/theme.tsx:4-17
Timestamp: 2025-05-29T10:21:32.682Z
Learning: In the @alauda/doom project, environment variables like ALGOLIA_APP_ID, ALGOLIA_API_KEY, and ALGOLIA_INDEX_NAME are injected at build time, making non-null assertions safe when used after truthiness checks.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
src/cli/load-config.ts (3)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
Learnt from: JounQin
PR: alauda/doom#9
File: src/cli/load-config.ts:27-27
Timestamp: 2025-05-12T11:11:41.048Z
Learning: The yoctocolors package is used in the codebase for colored terminal output, with the cyan function imported in src/cli/load-config.ts.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In @rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from '@rspress/core/theme'` are valid even if ESLint shows resolution errors.
src/cli/export-pdf-core/utils/mergePDF.ts (1)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
src/types.ts (2)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In @rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from '@rspress/core/theme'` are valid even if ESLint shows resolution errors.
src/cli/export.ts (2)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
Learnt from: JounQin
PR: alauda/doom#9
File: src/cli/load-config.ts:27-27
Timestamp: 2025-05-12T11:11:41.048Z
Learning: The yoctocolors package is used in the codebase for colored terminal output, with the cyan function imported in src/cli/load-config.ts.
docs/en/usage/configuration.md (5)
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:22:30.004Z
Learning: In the @alauda/doom project, the team prefers throwing descriptive errors for invalid configuration rather than using optional chaining or graceful fallbacks. This fail-fast approach helps catch configuration issues early during development.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.
Learnt from: JounQin
PR: alauda/doom#34
File: src/theme.tsx:4-17
Timestamp: 2025-05-29T10:21:32.682Z
Learning: In the @alauda/doom project, environment variables like ALGOLIA_APP_ID, ALGOLIA_API_KEY, and ALGOLIA_INDEX_NAME are injected at build time, making non-null assertions safe when used after truthiness checks.
src/theme.tsx (3)
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In @rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from '@rspress/core/theme'` are valid even if ESLint shows resolution errors.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
🧬 Code Graph Analysis (2)
src/global/VersionsNav/index.tsx (1)
src/shared/helpers.ts (1)
getPdfName(7-8)
src/cli/export-pdf-core/generatePdf.ts (6)
src/cli/export-pdf-core/utils/mergePDF.ts (1)
PDFOutline(28-28)src/cli/export-pdf-core/utils/getUrlLink.ts (1)
getUrlLink(1-7)src/cli/html-export-pdf/utils/cliProgress.ts (1)
createProgress(8-90)src/cli/html-export-pdf/core/printer.ts (1)
Printer(43-326)src/cli/html-export-pdf/utils/isValidUrl.ts (1)
isValidUrl(1-3)src/cli/html-export-pdf/utils/fs.ts (1)
writeFileSafe(8-23)
🪛 LanguageTool
.changeset/spicy-glasses-own.md
[uncategorized] ~5-~5: This verb may not be in the correct form. Consider using a different form for this context.
Context: ...@alauda/doom": minor --- feat: support export single entry as PDF
(AI_EN_LECTOR_REPLACEMENT_VERB_FORM)
docs/en/start.mdx
[uncategorized] ~153-~153: A punctuation mark might be missing here.
Context: ...eview. ### Using Scaffolding Templates {#new} Run yarn new to generate projects, ...
(AI_EN_LECTOR_MISSING_PUNCTUATION)
[typographical] ~178-~178: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: .... Note that the parameter value must be quoted, otherwise it may be parsed unexpectedly by the co...
(THUS_SENTENCE)
docs/en/usage/configuration.md
[uncategorized] ~23-~23: Loose punctuation mark.
Context: ...# Basic Configuration {#basic} - lang: Default documentation language. To acco...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~24-~24: Loose punctuation mark.
Context: ... set to null or undefined. - title: Documentation title, displayed on the b...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~25-~25: Loose punctuation mark.
Context: ..., displayed on the browser tab. - logo: Logo at the top left of the documentati...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~26-~26: Loose punctuation mark.
Context: ...lt into the doom package. - logoText: Documentation title displayed next to t...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~27-~27: Loose punctuation mark.
Context: ...xt to the logo at the top left. - icon: Documentation favicon, defaults to the ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~28-~28: Loose punctuation mark.
Context: ...defaults to the same as logo. - base: Base path of the documentation, used wh...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~29-~29: Loose punctuation mark.
Context: ...oduct-docs. Defaults to /. - outDir`: Output directory for build artifacts. D...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...e ``` ### frontmatterMode - `ignore`: Ignore the frontmatter of the reference...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...urrent document's frontmatter. - merge: Merge the frontmatter of the referenced...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ride the current document's. - replace: Replace the current document's frontmat...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build and Lint with Node.js 18 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 24 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
🔇 Additional comments (18)
src/runtime/translation.ts (1)
19-19: LGTM! Translation key added consistently across all languages.The new
view_docs_as_pdftranslation key has been properly added to all three supported languages with appropriate translations that accurately convey the intended meaning.Also applies to: 42-42, 63-63
src/types.ts (2)
52-57: Well-designed interface for export configuration.The
ExportIteminterface provides a clean and flexible API with appropriate optional properties and support for both single and multiple entries.
76-76: Export configuration properly integrated into UserConfig.The addition of the optional
exportproperty follows the existing pattern and maintains backward compatibility.docs/zh/start.mdx (1)
240-240: Documentation reference properly added.The link to the export configuration documentation provides users with easy access to detailed configuration options for the new PDF export feature.
src/global/VersionsNav/index.tsx (2)
6-6: Good import optimizations.Adding
withBaseimport and convertingNavItemto a type import are both good practices that improve code clarity and potentially bundle size.Also applies to: 8-8
61-62: Improved PDF link construction with proper base URL handling.Using
withBase()instead of manual string concatenation ensures proper base URL handling and follows RSPress framework conventions. The dependency array update is also correct sincewithBasehandles the base URL internally.src/plugins/global/index.ts (1)
7-7: LGTM! Clean integration of export configuration into the global virtual module.The changes correctly extend the virtual module system to expose export configuration data to the runtime environment, following established patterns in the codebase.
Also applies to: 22-22, 70-70
fixture-docs/doom.config.yml (1)
9-13: Good example configuration for the new export feature.The export entries provide clear examples of how to configure named PDF exports using glob patterns, which will be useful for testing and demonstrating the feature.
docs/zh/usage/configuration.md (1)
237-246: Excellent documentation for the new export feature.The documentation clearly explains the export configuration with a practical example, making it easy for users to understand and implement the feature.
src/cli/export-pdf-core/utils/mergePDF.ts (3)
186-189: Improved error handling approach.Throwing an
Errorinstead of writing to stderr and callingprocess.exitis a better approach for composability and testability.
2-2: Clean import refactoring.The path import consolidation and removal of unused imports improves code readability.
Also applies to: 196-196, 212-212
177-177: Approve path resolution changeThe switch to
path.resolve(outDir)is safe—relative paths still resolve againstprocess.cwd(), and absolute paths are now correctly respected (unlike the previouspath.join(process.cwd(), outDir)behavior). No breaking changes detected.All other refactorings (error handling, import cleanup) look good. LGTM.
src/cli/load-config.ts (3)
31-31: Appropriate dependency for glob pattern expansion.The
tinyglobbyimport provides the necessary functionality to expand glob patterns in export configurations.
354-357: Correct implementation of glob pattern expansion.The export configuration processing correctly expands glob patterns to file lists using the local base path as the working directory, which aligns with the documented behavior.
484-484: Ensures processed export configuration is included in final config.The explicit assignment ensures that the glob-expanded export entries are properly included in the merged configuration.
src/cli/export-pdf-core/generatePdf.ts (1)
29-31: Well-designed extension for multi-PDF export support.The changes elegantly support both single and multiple PDF exports:
- Optional
allOutlinesparameter enables outline reuse across exports- Conditional
cleanupTempDirallows deferring cleanup when exporting multiple PDFs- Return type includes outlines for consistency across exports
The implementation correctly handles both code paths with appropriate conditional logic.
Also applies to: 49-50, 84-147, 159-163
src/cli/export.ts (1)
27-43: Excellent implementation of single entry PDF export.The refactoring effectively supports the new export feature:
collectPagesextraction improves code organizationfindEntryFactoryprovides robust recursive search for sidebar entriesexportEntriesproperly handles missing entries with clear warnings- PDF outline sharing between exports ensures consistent bookmarks
- Deferred temp directory cleanup allows multiple export operations
The error handling and user feedback are well implemented.
Also applies to: 141-184, 191-200
docs/en/usage/configuration.md (1)
238-246: Clear documentation for the new export feature.The export configuration section effectively documents the new single entry PDF export capability with:
- Clear explanation of the feature
- Well-structured YAML example
- Proper description of configuration options
acca9fa to
e858007
Compare
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/theme.tsx (1)
77-77: Address potential runtime safety issue with non-null assertion.Using a non-null assertion (
virtual.export!) can be risky ifvirtual.exportis ever undefined.Consider adding an explicit nullish check before iterating:
- for (const item of virtual.export!) { + if (virtual.export) { + for (const item of virtual.export) {
🧹 Nitpick comments (1)
.changeset/spicy-glasses-own.md (1)
5-5: Fix grammatical error in the changeset description.The phrase "support export single entry" is grammatically incorrect.
Apply this diff to fix the grammar:
-feat: support export single entry as PDF +feat: support exporting single entry as PDF
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
.changeset/spicy-glasses-own.md(1 hunks)docs/en/start.mdx(9 hunks)docs/en/usage/configuration.md(10 hunks)docs/zh/start.mdx(1 hunks)docs/zh/usage/configuration.md(1 hunks)fixture-docs/doom.config.yml(1 hunks)src/cli/export-pdf-core/generatePdf.ts(4 hunks)src/cli/export-pdf-core/utils/mergePDF.ts(3 hunks)src/cli/export.ts(4 hunks)src/cli/load-config.ts(3 hunks)src/global/VersionsNav/index.tsx(2 hunks)src/plugins/global/index.ts(3 hunks)src/runtime/translation.ts(3 hunks)src/theme.tsx(1 hunks)src/types.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
- docs/zh/start.mdx
- src/runtime/translation.ts
- docs/zh/usage/configuration.md
- src/global/VersionsNav/index.tsx
- src/cli/load-config.ts
- src/plugins/global/index.ts
- src/types.ts
- fixture-docs/doom.config.yml
- src/cli/export-pdf-core/utils/mergePDF.ts
- src/cli/export-pdf-core/generatePdf.ts
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: JounQin has mentioned multiple times that the alauda/doom project uses yarn v4, and there are no ESLint import resolution errors for @rspress/core subpath imports.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
src/theme.tsx (3)
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In @rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from '@rspress/core/theme'` are valid even if ESLint shows resolution errors.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
src/cli/export.ts (2)
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In @rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from '@rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.
Learnt from: JounQin
PR: alauda/doom#9
File: src/cli/load-config.ts:27-27
Timestamp: 2025-05-12T11:11:41.048Z
Learning: The yoctocolors package is used in the codebase for colored terminal output, with the cyan function imported in src/cli/load-config.ts.
.changeset/spicy-glasses-own.md (1)
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
docs/en/start.mdx (6)
Learnt from: JounQin
PR: alauda/doom#75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:22:30.004Z
Learning: In the @alauda/doom project, the team prefers throwing descriptive errors for invalid configuration rather than using optional chaining or graceful fallbacks. This fail-fast approach helps catch configuration issues early during development.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: JounQin has mentioned multiple times that the alauda/doom project uses yarn v4, and there are no ESLint import resolution errors for @rspress/core subpath imports.
Learnt from: JounQin
PR: alauda/doom#34
File: src/theme.tsx:4-17
Timestamp: 2025-05-29T10:21:32.682Z
Learning: In the @alauda/doom project, environment variables like ALGOLIA_APP_ID, ALGOLIA_API_KEY, and ALGOLIA_INDEX_NAME are injected at build time, making non-null assertions safe when used after truthiness checks.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
docs/en/usage/configuration.md (5)
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:23:34.965Z
Learning: In the @alauda/doom project, JounQin prefers concise error handling over verbose validation. While they prefer throwing on invalid configuration rather than graceful fallbacks, they don't want overly detailed validation with multiple explicit checks and error messages.
Learnt from: JounQin
PR: alauda/doom#34
File: src/cli/load-config.ts:290-0
Timestamp: 2025-05-29T10:22:30.004Z
Learning: In the @alauda/doom project, the team prefers throwing descriptive errors for invalid configuration rather than using optional chaining or graceful fallbacks. This fail-fast approach helps catch configuration issues early during development.
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `@rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.
Learnt from: JounQin
PR: alauda/doom#34
File: src/theme.tsx:4-17
Timestamp: 2025-05-29T10:21:32.682Z
Learning: In the @alauda/doom project, environment variables like ALGOLIA_APP_ID, ALGOLIA_API_KEY, and ALGOLIA_INDEX_NAME are injected at build time, making non-null assertions safe when used after truthiness checks.
🧬 Code Graph Analysis (1)
src/theme.tsx (4)
src/runtime/components/_X.tsx (1)
X(3-3)src/plugins/auto-sidebar/walk.ts (3)
DoomSidebarGroup(35-38)DoomSidebarItem(25-27)DoomSidebar(29-33)src/types.ts (1)
ExportItem(52-57)src/runtime/hooks/useTranslation.ts (2)
useLang(7-7)useTranslation(9-16)
🪛 LanguageTool
.changeset/spicy-glasses-own.md
[uncategorized] ~5-~5: This verb may not be in the correct form. Consider using a different form for this context.
Context: ...@alauda/doom": minor --- feat: support export single entry as PDF
(AI_EN_LECTOR_REPLACEMENT_VERB_FORM)
docs/en/start.mdx
[uncategorized] ~153-~153: A punctuation mark might be missing here.
Context: ...eview. ### Using Scaffolding Templates {#new} Run yarn new to generate projects, ...
(AI_EN_LECTOR_MISSING_PUNCTUATION)
[typographical] ~178-~178: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: .... Note that the parameter value must be quoted, otherwise it may be parsed unexpectedly by the co...
(THUS_SENTENCE)
docs/en/usage/configuration.md
[uncategorized] ~23-~23: Loose punctuation mark.
Context: ...# Basic Configuration {#basic} - lang: Default documentation language. To acco...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~24-~24: Loose punctuation mark.
Context: ... set to null or undefined. - title: Documentation title, displayed on the b...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~25-~25: Loose punctuation mark.
Context: ..., displayed on the browser tab. - logo: Logo at the top left of the documentati...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~26-~26: Loose punctuation mark.
Context: ...lt into the doom package. - logoText: Documentation title displayed next to t...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~27-~27: Loose punctuation mark.
Context: ...xt to the logo at the top left. - icon: Documentation favicon, defaults to the ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~28-~28: Loose punctuation mark.
Context: ...defaults to the same as logo. - base: Base path of the documentation, used wh...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~29-~29: Loose punctuation mark.
Context: ...oduct-docs. Defaults to /. - outDir`: Output directory for build artifacts. D...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...e ``` ### frontmatterMode - `ignore`: Ignore the frontmatter of the reference...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...urrent document's frontmatter. - merge: Merge the frontmatter of the referenced...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ride the current document's. - replace: Replace the current document's frontmat...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 24 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 18 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 18 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 24 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
🔇 Additional comments (4)
docs/en/start.mdx (1)
15-287: LGTM! Excellent documentation improvements.The editorial changes significantly improve clarity and consistency throughout the documentation. The references to the new export configuration feature align well with the PR objectives.
src/cli/export.ts (1)
27-204: Excellent refactoring for multi-entry PDF export support.The implementation effectively separates concerns with well-designed helper functions:
collectPagesfor page collection with configurable base pathsfindEntryFactoryfor recursive sidebar entry lookupexportEntriesfor coordinated multi-export processingThe error handling with warnings for missing entries and proper cleanup of temporary directories shows good attention to detail.
docs/en/usage/configuration.md (1)
238-247: Comprehensive documentation for the new export feature.The export configuration section provides clear examples and proper context for users. The documentation aligns well with the implementation and follows the established documentation patterns.
src/theme.tsx (1)
30-143: Well-designed theme integration for PDF export functionality.The implementation elegantly handles:
- Recursive sidebar traversal with proper depth tracking
- Locale-aware sidebar matching
- Dynamic PDF link generation based on export configuration
- Clean separation of concerns between matching logic and UI rendering
The
MatchedSidebarinterface and related functions provide a solid foundation for contextual PDF links.
close IDP-1215
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Refactor
Style
Tests