Repository navigation
feat: Playwright公式docsをNotebookLM向けに取得・前処理するツールを追加 - #2
Conversation
- playwright-official-docs/ 独立サブディレクトリとCLIを追加 - stable sidebar/MDX取得とTypeScript/Node.js向け前処理を実装 - ページ単位出力とNotebookLM向けbundleを冪等生成 - MDX idとファイル名の不一致をfrontmatter索引で解決 - fixtureベースのユニット/統合テストを追加 Co-authored-by: Cursor <cursoragent@cursor.com>
- MDX取得の二重fetchをキャッシュ索引で解消 - outDirとfixtureDirのリポジトリ内パス検証を追加 - ページ番号の動的ゼロ埋めとTabsの反復展開を実装 - 重複doc idの警告と関連テストを追加 Co-authored-by: Cursor <cursoragent@cursor.com>
- writeAtomicallyでrename失敗時に既存出力をバックアップから復元 - LiteYouTube等の自己終了JSXコンポーネントを前処理で除去 - sidebar doc idの形式検証を追加 Co-authored-by: Cursor <cursoragent@cursor.com>
- writeAtomicallyでpromote成功後のバックアップ削除失敗を成功扱いにし、tmpDir誤削除を防止 - categoryToSlugとbundleFileNameでbundle出力ファイル名を安全化 - fetchでsidebarUrl・download_url・mdxBaseUrlの許可ホスト検証を追加 - 上記挙動をカバーするユニットテストを追加 Co-authored-by: Cursor <cursoragent@cursor.com>
- buildMdxCatalog/loadMdxにrepoRootを渡しrealpath基準でmdx配下に拘束 - ファイル名・stemを^[a-z0-9-]+$で検証しresolveWithinRepoでsymlink経由の逸脱を拒否 - 不安全なfixtureファイル名の除外とassertSafeMdxStemのユニットテストを追加 Co-authored-by: Cursor <cursoragent@cursor.com>
- removeImportsAndComponentLinesがフェンス境界を追跡しMDX importのみ除去 - removedImports統計を実際に削除した行数に修正 - writing-tests fixtureのコード例import保持をユニット/統合テストで検証 Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughPlaywright 公式ドキュメントを NotebookLM / Gemini 向けに取得・前処理・保存する新規ツール Changesplaywright-official-docs エクスポートツール
Sequence Diagram(s)sequenceDiagram
participant CLI as cli.mjs
participant Config as config.mjs
participant Fetch as fetch.mjs
participant Preprocess as preprocess.mjs
participant Bundle as bundle.mjs
participant Export as export.mjs
participant FS as fs-utils.mjs
CLI->>Config: loadDefaultConfig() / validateConfig()
Config-->>CLI: config
CLI->>Fetch: loadSidebar(config, repoRoot)
Fetch-->>CLI: sidebar JSON
CLI->>Fetch: buildMdxCatalog(config, repoRoot)
Fetch-->>CLI: MdxIndex
CLI->>Export: runExport(config, {dryRun, repoRoot})
loop 各ページ
Export->>Fetch: loadMdx(config, id, index, repoRoot)
Fetch-->>Export: {content, stem, rawUrl}
Export->>Preprocess: preprocessMdx(content, page, options)
Preprocess-->>Export: {markdown, stats}
end
Export->>Bundle: buildCategoryBundle / buildProjectIndex
Bundle-->>Export: Markdown
Export->>FS: writeAtomically(outDir, writer)
FS-->>Export: 完了(pages/ notebooklm/ manifest.json)
Export-->>CLI: {pageCount, bundleCount, urlUnchanged}
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f24ca0e995
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| */ | ||
| export function removeJsxComponents(body) { | ||
| return body | ||
| .replace(/<[A-Z][A-Za-z0-9]*\b[^>]*\/>/g, "") |
There was a problem hiding this comment.
Preserve JSX inside fenced code examples
When a docs page contains a fenced React/TSX example with a self-closing component, this global replacement runs after the fence-aware import pass and removes the JSX from the code sample as if it were MDX chrome. For example, component-testing examples such as await mount(<App />) become await mount(), so the generated NotebookLM/page output corrupts runnable code instead of preserving the official docs content. This cleanup needs to track code fences or otherwise avoid applying JSX-component stripping inside fenced blocks.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.gitignore:
- Around line 6-8: Add the pattern `playwright-official-docs/output.bak-*/` to
the .gitignore file alongside the existing
`playwright-official-docs/output.tmp-*/` pattern. Since the fs-utils.mjs file
creates backup directories with `outDir.bak-${process.pid}` and silently
suppresses errors during backup deletion, these backup directories can remain
untracked in the repository. The .bak-* pattern should be excluded from version
control just like the temporary output directories are already being excluded.
In `@playwright-official-docs/src/cli.mjs`:
- Around line 35-40: The current validation for the --fixture-dir option only
checks if the value is falsy, but it doesn't validate that the provided value is
not another option flag. When retrieving the value from argv[fixtureIdx + 1] in
the fixtureDir validation block, add an additional check to ensure the value
does not start with "--" (which would indicate it's another option rather than a
path). If the value starts with "--", throw an error to prevent option flags
from being incorrectly interpreted as path values.
In `@playwright-official-docs/src/config.mjs`:
- Around line 52-82: The validateConfig function only performs a truthy check on
config.fixtureDir at line 52, which allows non-string values (numbers, booleans,
objects) to pass through. This causes a TypeError when non-string values are
passed to path.isAbsolute in the resolveFixtureDir function. Add explicit type
validation to ensure config.fixtureDir is either a string or null, following the
same validation pattern used for other required fields in the validateConfig
function (similar to what is done around line 41), to prevent non-string values
from reaching path.isAbsolute.
In `@playwright-official-docs/src/export.mjs`:
- Around line 33-41: The extractTitle function's regex pattern is matching
title: lines anywhere in the markdown document instead of restricting to the
frontmatter block at the beginning. Modify the function to first extract only
the frontmatter section (the YAML block typically delimited at the start of the
markdown), then apply the title regex pattern only to that extracted frontmatter
section. This prevents false matches on title: strings that may appear in the
document body or code blocks. Ensure the frontmatter extraction handles the
typical delimiters used in markdown files.
In `@playwright-official-docs/src/fetch.mjs`:
- Around line 89-93: The loadSidebar function lacks symlink containment
validation when reading sidebar.json, while the readFixtureMdx function properly
implements this check. Add a call to resolveWithinRepo(file, repoRoot) in the
loadSidebar function before performing fs.readFile on the sidebar.json file
path, ensuring the resolved path is validated to be within the repository root,
similar to how readFixtureMdx handles this to prevent symlink escape attacks.
- Around line 73-80: The fetchText function and the fetch call at Line 151 lack
timeout configuration, which can cause the export process to hang indefinitely
during network issues. Add an AbortSignal with a 15-second timeout to both fetch
calls by including a signal property in the options object passed to fetch. To
avoid duplication across both locations, consider refactoring the fetch logic
into a shared helper function that handles the timeout configuration
consistently.
In `@playwright-official-docs/src/preprocess.mjs`:
- Around line 158-177: The functions removeJsxComponents and replaceImages are
applying global text replacements without checking for code fence boundaries,
which breaks code examples inside markdown code blocks that contain JSX tags or
image syntax. Refactor both functions to implement fence boundary tracking
similar to how removeImportsAndComponentLines handles fences, so that regex
replacements only occur on content outside of code fences (identified by triple
backtick markers), and content within fences is preserved unchanged.
- Around line 105-110: The selectTabContent function and other related functions
directly access properties of the options parameter without providing default
values, causing a TypeError when these functions are called without passing
options. Add a default value (an empty object or an object with appropriate
defaults) to the options parameter in the function signatures for
selectTabContent and the other functions mentioned in the "Also applies to"
section to prevent crashes when options is undefined or not provided.
In `@test/integration/playwright-docs-cli.test.mjs`:
- Around line 84-89: The idempotency test does not verify that the runExport
function calls succeed before comparing file contents. Capture the return value
from both runExport calls (the first call on line 84 and the second call on line
87) and explicitly assert that the exit code equals 0 for both executions. This
ensures the test fails if either export operation fails, rather than passing
simply because leftover files exist and match.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3f4c98ce-ef52-46ce-8068-d7891bc959bc
📒 Files selected for processing (28)
.gitignoreREADME.mdeslint.config.jspackage.jsonplaywright-official-docs/README.mdplaywright-official-docs/bin/export-playwright-docs.mjsplaywright-official-docs/config.default.jsonplaywright-official-docs/src/bundle.mjsplaywright-official-docs/src/cli.mjsplaywright-official-docs/src/config.mjsplaywright-official-docs/src/export.mjsplaywright-official-docs/src/fetch.mjsplaywright-official-docs/src/fs-utils.mjsplaywright-official-docs/src/paths.mjsplaywright-official-docs/src/preprocess.mjsplaywright-official-docs/src/sidebar.mjsplaywright-official-docs/src/url-review.mjstest/fixtures/playwright-docs/mdx/intro.mdxtest/fixtures/playwright-docs/mdx/languages.mdxtest/fixtures/playwright-docs/mdx/writing-tests.mdxtest/fixtures/playwright-docs/sidebar.jsontest/integration/playwright-docs-cli.test.mjstest/unit/playwright-docs-bundle.test.mjstest/unit/playwright-docs-config.test.mjstest/unit/playwright-docs-fetch.test.mjstest/unit/playwright-docs-fs-utils.test.mjstest/unit/playwright-docs-preprocess.test.mjstest/unit/playwright-docs-sidebar.test.mjs
- コードフェンス外のみJSX/画像変換する共通ヘルパを追加 - fixture sidebar読込にcontainment検証とfetch timeoutを追加 - CLI引数・fixtureDir型検証とbak出力ディレクトリのgitignoreを追加 - 関連ユニット/統合テストを追加・更新 Co-authored-by: Cursor <cursoragent@cursor.com>
- CLIランチャーでNode 18未満を検出し、cli.mjs読込前に要件エラーを表示 - package.jsonにengines.node >=18を追加し、実行要件を明示 Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@playwright-official-docs/src/config.mjs`:
- Around line 49-55: The current validation for config.fixtureDir only checks
for non-string types, allowing empty strings to pass through which then silently
fail at the truthy check on Line 60. Update the validation logic in the
fixtureDir check to additionally reject empty strings as invalid input. The
condition should ensure that if fixtureDir is a string, it must be non-empty,
while still allowing null and undefined values. Add a check to throw an error
when fixtureDir is an empty string, making the error message clear that only
null, undefined, or non-empty strings are acceptable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 30205bdc-95fe-4811-8821-f196530624ea
📒 Files selected for processing (13)
.gitignorepackage.jsonplaywright-official-docs/bin/export-playwright-docs.mjsplaywright-official-docs/src/cli.mjsplaywright-official-docs/src/config.mjsplaywright-official-docs/src/export.mjsplaywright-official-docs/src/fetch.mjsplaywright-official-docs/src/preprocess.mjstest/integration/playwright-docs-cli.test.mjstest/unit/playwright-docs-cli.test.mjstest/unit/playwright-docs-config.test.mjstest/unit/playwright-docs-fetch.test.mjstest/unit/playwright-docs-preprocess.test.mjs
- languageTab が typescript のとき ts タブを優先選択するよう照合順を修正 - frontmatter 限定の title 抽出に変更し本文の title: 行の誤マッチを防止 - fixtureDir の空文字・空白のみを検証で明示拒否 - 関連ユニットテストを追加 Co-authored-by: Cursor <cursoragent@cursor.com>
概要
Playwright公式 Node.js ドキュメントを NotebookLM / Gemini 向けに取得・前処理・保存する独立ツール
playwright-official-docs/を追加する。既存の E2E エクスポートツールを補完し、公式 MDX ソースからノイズを除去した Markdown を冪等に生成できる。変更内容
playwright-official-docs/に CLI・設定・取得・前処理・bundle 生成のパイプラインを追加versioned_docs/version-stable/*.mdxから docs ページを取得(API reference は対象外)pages/、notebooklm/(カテゴリ bundle)、PROJECT_INDEX.md、manifest.json、url-review.md等import/Tabs/ JSX コンポーネント除去、languages.mdxの言語絞り込み、API reference フッター削除import行は保持し、MDX 用 import のみ除去npm run export:playwright-docs/export:playwright-docs:checkスクリプトと fixture ベースのユニット/統合テストを追加技術的な詳細
mock-browser-apisなど frontmatteridとファイル名 stem が異なるページは MDX カタログで解決writeAtomicallyで tmp → rename による冪等出力。失敗時はバックアップから復元resolveWithinRepo/assertWithinRepoRootを再利用テスト内容
npm test: 151 pass / 1 skip(symlink テストは Windows 環境で skip)npm run lint: エラーなし関連Issue
Made with Cursor
Summary by CodeRabbit
リリースノート
--check/--fixture-dir)と、カテゴリ別バンドル・補助ドキュメント(一覧/差分レビュー/インデックス/manifest)生成に対応export:playwright-docs/export:playwright-docs:checkを追加し、Node.js 最小要件(>=18)を設定.gitignoreと eslint の対象範囲を更新