Conversation
Migrate the excerpter package from dart-lang/labs to dart-lang/tools. Core Package & Setup: - Ported all core libraries, executable entry points, and tests to `pkgs/excerpter`. - Adapted constraints to target Dart SDK `^3.9.0` and replaced the site-specific `analysis_defaults` with `package:dart_flutter_team_lints`. - Structured a clean library programmatic usage example in `example/main.dart`. - Exposed code ownership in `.github/CODEOWNERS`. - Set up GitHub Actions CI workflow in `.github/workflows/excerpter.yaml`. - Set up labeler patterns in `.github/labeler.yml`. - Registered the `excerpter` package in the root `README.md`. Core Bug Fix & Enhancements: - Fixed a `RangeError` crash inside the code block parser loop in `inject.dart` when dealing with unclosed blocks at the end of a file. - Implemented native tracking of static code blocks to ignore illustrative `<?code-excerpt` snippets inside fenced Markdown regions, avoiding visual backslash prefix workarounds. - Formatted all files to adhere strictly to the 80-column limit. Testing & Robustness: - Added dedicated unit tests for exceptional extractor parser failures in `test/extractor_test.dart` and `test/injection_test.dart`. - Migrated temporary directory setups to use `package:test_descriptor` for platform-agnostic, isolated sandbox tests. - Added an automated validation test in `test/cli_test.dart` to guarantee the `README.md` options table stays in perfect sync with the CLI `ArgParser` definition. - Achieved 87.6% core statement coverage (including 100% coverage on `extract.dart` and `update.dart`).
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthLicense Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with
Breaking changes
|
| Package | Change | Current Version | New Version | Needed Version | Looking good? |
|---|---|---|---|---|---|
| excerpter | Breaking | 0.0.0 | 0.0.0 | 0.0.0 Report was not created for package:excerpter 0.1.0-wip (dir=/home/runner/work/tools/tools/current_repo/pkgs/excerpter). Error: Error: Exception: Package not available (could not find package excerpter at https://pub.dev). |
This check can be disabled by tagging the PR with skip-breaking-check.
Coverage ⚠️
| File | Coverage |
|---|---|
| pkgs/excerpter/bin/excerpter.dart | 💔 Not covered |
| pkgs/excerpter/example/main.dart | 💔 Not covered |
| pkgs/excerpter/lib/excerpter.dart | 💔 Not covered |
| pkgs/excerpter/lib/src/extract.dart | 💚 98 % |
| pkgs/excerpter/lib/src/inject.dart | 💚 75 % |
| pkgs/excerpter/lib/src/transform.dart | 💚 98 % |
| pkgs/excerpter/lib/src/update.dart | 💚 100 % |
| pkgs/excerpter/test_data/example/dartdoc.dart | 💔 Not covered |
| pkgs/excerpter/test_data/example/plaster.dart | 💔 Not covered |
| pkgs/excerpter/test_data/example/simple_main.dart | 💔 Not covered |
| pkgs/excerpter/test_data/example/simple_region.dart | 💔 Not covered |
| pkgs/excerpter/test_data/example/transforms.dart | 💔 Not covered |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
API leaks ✔️
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
| Package | Leaked API symbol | Leaking sources |
|---|
This check can be disabled by tagging the PR with skip-leaking-check.
Unused Dependencies ✔️
| Package | Status |
|---|---|
| excerpter | ✔️ All dependencies utilized correctly. |
For details on how to fix these, see dependency_validator.
This check can be disabled by tagging the PR with skip-unused-dependencies-check.
Changelog Entry ✔️
| Package | Changed Files |
|---|
Changes to files need to be accounted for in their respective changelogs.
This check can be disabled by tagging the PR with skip-changelog-check.
There was a problem hiding this comment.
Code Review
This pull request introduces the excerpter package, a tool for synchronizing code excerpts in Markdown files with source code regions. It includes a CLI, a programmatic API, and various text transformations. Feedback focuses on improving the robustness of the instruction parser (specifically handling escaped quotes and delimiters), ensuring consistency between the documentation and regex for region names, and optimizing performance by pre-compiling regexes and sharing the extraction cache across multiple files.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the excerpter package to the monorepo, a tool designed to synchronize code excerpts in Markdown files with regions defined in source code. The reviewer identified several areas for improvement, including a potential RangeError in inject.dart when handling short lines and a bug in the shared indentation logic that fails when excerpts contain empty lines. Additionally, the feedback suggests using the path package for more robust file extension detection and updating the README.md to reflect the package's new repository location and bug tracker links.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new package, excerpter, designed to update code excerpts in Markdown documentation from source files. The changes include the package structure, CLI implementation, and necessary configuration files. The review identified a discrepancy between the SDK version in the PR description and the pubspec.yaml, suggested simplifying argument parsing and error handling in the CLI, and pointed out an unnecessary await in pkgs/markdown/tool/update_shared.dart that conflicts with the unnecessary_await_in_return lint rule.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the excerpter package, a tool for synchronizing code excerpts in Markdown documentation with source files. It includes a CLI, extraction and injection logic, and various text transformations. Review feedback identifies a potential path traversal vulnerability in path joining, suggests normalizing paths in the region cache to prevent redundant processing, and recommends replacing a magic number with a named constant.
|
|
||
| To include lines within a code region, | ||
| add a Dart line comment before the first line in the region with | ||
| `#docregion <name>` where `<name>` is your desired name for the region. |
There was a problem hiding this comment.
@kevmoo please look at dart-lang/dartdoc#4144
Can talk to others and see if we can agree on something.
IMO, it's preferable if this is as simple as possible.
If we want to have substitution, what is the motivation? And are we sure the benefits outweigh the costs of duplicating a few examples.
I can see how a reference using skip=5 could be hard to maintain, how will I when editing the code file that contains the doc-region know that it's referenced somewhere with skip=5 and that this has to be meaningful.
I guess you'll be able to see it in the PR diff (if you read all the diff, but not if you skim it). But for something like {$example path/to/example/code.dart#myregion} a skip=5 option would be dangerous, because when editing path/to/example/code.dart I can see #region myregion but I can't really know that one place the region is used with skip-5 and in another it's not. And with dartdoc API doc changes won't be visible in the PR.
The same concern applies with substituions, etc. this is my main concern: too many features makes updating code examples dangerous, because it hard to know how the docregion is being referenced (and what substitutions it is subject to).
There was a problem hiding this comment.
@parlough do you have some context on all the options here?
Do we need them? and is it really wise to have so many options.
Migrate the excerpter package from dart-lang/labs to dart-lang/tools.
Core Package & Setup:
pkgs/excerpter.^3.12.0and replaced the site-specificanalysis_defaultswithpackage:dart_flutter_team_lints.example/main.dart..github/CODEOWNERS..github/workflows/excerpter.yaml..github/labeler.yml.excerpterpackage in the rootREADME.md.