You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 54a9d5b
Browse filesBrowse the repository at this point in the historyBrowse files
feat(scan): read @openshell comments in Ruby, Rust, Java and more; report unscanned languages (#21)
## What and why
Inline `@openshell` comments in Ruby, Rust, Java, Kotlin, C#, PHP and
other languages were silently ignored. They are now read, and files in
languages we cannot read are reported instead of skipped silently.
- Generic `#` and `//` comment lexers, picked by file extension.
Built-in: `rb rake gemspec pl pm r` (hash) and `rs java kt kts cs php
swift scala dart c h cc cpp hpp` (slash).
- `[scan.comment_leaders]` in `openshell-annotate.toml` adds extensions
or switches defaults off (`hash`, `slash`, `none`); a bad value is a
config error.
- `[languages]` default executables for these languages are keyed by
file extension (`rb = "/usr/bin/ruby"`).
- Known source files that are still not scanned (for example `.lua`,
`.ex`, `.hs`, or an extension set to `none`) produce a `note: N .ext
files were not scanned ...` line on stderr. stdout and `--json` are
unchanged.
- No call-site lint for these languages (directives only); documented in
the README. The `.sh` sidecar workaround is documented. A first-class
sidecar file is tracked separately in #20.
Verified on copies of the real candidates: an inline directive in
pocketrb's `web_search.rb` and in anthropic-proxy-rs's `proxy.rs` now
scans and generates.
Tests: three new CLI tests. `TOOLCHAIN=1.94 scripts/ci-local.sh` and
stable clippy pass.
Independent of the other PRs (touches `scan.rs`, `lexer.rs`,
`config.rs`, README); it can merge in any order.
Closes#7
---------
Signed-off-by: Ilan Harel <[email protected]>
Co-authored-by: Ilan Harel <[email protected]>
"{}: no executable known for this egress: add `bin=/real/path` or a `@openshell bin /real/path` line in the file, or set [languages].{} in openshell-annotate.toml (an empty `binaries` list allows nothing)",
178
+
"{}: no executable known for this egress: add `bin=/real/path` or a `@openshell bin /real/path` line in the file, or set [languages].{key} in openshell-annotate.toml (an empty `binaries` list allows nothing)",
175
179
d.loc(),
176
-
lang.config_key()
177
180
));
178
181
}
179
182
Err(format!("{}: cannot determine the executable", d.loc()))
/// One human-readable note per extension that was skipped, for stderr.
40
+
pubfnunscanned_notes(&self) -> Vec<String>{
41
+
self.unscanned
42
+
.iter()
43
+
.map(|(ext, n)| {
44
+
format!(
45
+
"{n} .{ext} file{} not scanned (no comment syntax known); if its comments start with `#` or `//`, set `[scan.comment_leaders] {ext} = \"hash\"` (or \"slash\") in openshell-annotate.toml to read @openshell comments there",
0 commit comments