Add outline CLI command#2738
Conversation
📝 WalkthroughWalkthroughThis PR implements the Changessg outline end-to-end implementation
Sequence Diagram(s)sequenceDiagram
participant User
participant run_outline
participant load_outline_rules
participant OutlineExtractors
participant OutlineTextOptions
participant OutlineEmitter
participant stream_paths
User->>run_outline: sg outline [--outline-rules F] [--no-default-outline-rules] [paths]
run_outline->>load_outline_rules: include_default=!flag, extra paths
load_outline_rules-->>run_outline: Vec<SerializableOutlineRule>
run_outline->>OutlineExtractors: new(rules)
run_outline->>OutlineTextOptions: try_from_arg(arg)
run_outline->>OutlineEmitter: new(stdout, json_style, options)
alt stdin
run_outline->>stream_paths: extract_stdin(arg, extractors, options)
stream_paths-->>OutlineEmitter: emit(OutlineFile)
else file/dir paths
run_outline->>stream_paths: stream_paths(arg, extractors, options, emit)
stream_paths-->>OutlineEmitter: emit(OutlineFile) per file
end
run_outline->>OutlineEmitter: finish()
OutlineEmitter-->>User: text / JSON output
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
7763829 to
2a96e6f
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2738 +/- ##
==========================================
- Coverage 86.93% 85.85% -1.09%
==========================================
Files 121 125 +4
Lines 21010 21945 +935
==========================================
+ Hits 18266 18841 +575
- Misses 2744 3104 +360 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@crates/cli/src/outline/extract.rs`:
- Around line 140-170: Replace the unbounded mpsc::channel() call on line 140
with a bounded channel by using mpsc::channel(capacity) instead, where capacity
is an appropriate limit for the maximum number of OutlineFile items that should
be queued. This will apply backpressure to the producer thread when the queue
reaches capacity, preventing memory spikes when parallel walks generate files
faster than the sequential processing loop can consume them. The rest of the
producer and consumer logic using tx.send() and rx.recv() will automatically
handle the bounded behavior.
In `@crates/outline/src/default_rule.rs`:
- Around line 7-726: Add new pattern-based rules to the DEFAULT_OUTLINE_RULES
constant to handle async functions that are currently missing from extraction.
Create rules for async function variants (pub async fn, async fn) that mirror
the existing synchronous function rules such as rust-function-public,
rust-function, rust-function-public-return, rust-function-return,
rust-function-public-generic, rust-function-generic, and their variants with
return types and where clauses. Each async rule should have a unique id prefixed
with rust-async- and patterns that include the async keyword before fn, for
example pub async fn $NAME($$$ARGS) { $$$BODY } and async fn $NAME($$$ARGS) {
$$$BODY }, along with corresponding variants for generic parameters, return
types, and where clauses to match the coverage provided by existing non-async
rules.
🪄 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: CHILL
Plan: Pro
Run ID: f4084b29-85b2-467a-b9d8-e1e21417e6c1
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
crates/cli/Cargo.tomlcrates/cli/src/lib.rscrates/cli/src/outline.rscrates/cli/src/outline/extract.rscrates/cli/src/outline/options.rscrates/cli/src/outline/output.rscrates/cli/src/outline/output/tests.rscrates/outline/src/default_rule.rscrates/outline/src/lib.rs
|
this is still awful, but it's okay to merge now and iterate later |
Summary
Test
Summary by CodeRabbit
Release Notes
New Features
outlinecommand is now fully functional with extraction from files and stdin.--outline-rulesoption to load custom outline rule files.--no-default-outline-rulesflag to skip bundled default rules.Tests