-
Notifications
You must be signed in to change notification settings - Fork 45
emmylua_doc_cli: 支持多个input #561
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
} | ||
None => { | ||
eprintln!("Error: {} is not a valid path.", path.to_str().unwrap()); | ||
exit(1); |
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.
可以直接return Err, 可以把main的返回值改为Result<(), Error>
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.
这个主要是跟下面那部分代码保持一致的风格,load_workspace 失败,也是打印日志,和直接 exit。
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
Adds support for specifying multiple input directories for the documentation CLI instead of a single root.
- Changed the
--input
flag to accept a list ofPathBuf
values. - Updated
main.rs
to normalize each path to an absoluteString
and pass them intoload_workspace
. - Adjusted
load_workspace
signature to takeVec<String>
instead ofVec<&str>
.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
crates/emmylua_doc_cli/src/cmd_args.rs | Changed input from a single PathBuf to Vec<PathBuf> with num_args=1.. |
crates/emmylua_doc_cli/src/main.rs | Iterates over each input path, resolves to absolute, collects into Vec<String> , then calls load_workspace |
crates/emmylua_doc_cli/src/init.rs | Updated load_workspace signature to accept Vec<String> instead of Vec<&str> |
Comments suppressed due to low confidence (2)
crates/emmylua_doc_cli/src/main.rs:17
- This loop now handles both relative and absolute paths—consider adding unit tests for each scenario (valid UTF-8 vs. non-UTF-8, relative vs. absolute) to verify correct behavior and error handling.
for path in &input {
crates/emmylua_doc_cli/src/main.rs:25
exit(1)
is used butstd::process::exit
isn't imported. Either adduse std::process::exit;
at the top or qualify this call asstd::process::exit(1)
to prevent build errors.
exit(1);
files.push(p.to_string()); | ||
} | ||
None => { | ||
eprintln!("Error: {} is not a valid path.", path.to_str().unwrap()); |
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.
Calling path.to_str().unwrap()
here can panic if the path isn't valid UTF-8. Consider using path.display()
or handling the None
case without unwrap()
to avoid runtime crashes.
eprintln!("Error: {} is not a valid path.", path.to_str().unwrap()); | |
eprintln!("Error: {} is not a valid path.", path.display()); |
Copilot uses AI. Check for mistakes.
} | ||
|
||
let analysis = init::load_workspace(vec![input.to_str().unwrap()]); | ||
let analysis = init::load_workspace(files); |
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.
You're converting PathBuf
→ String
→ PathBuf
again inside load_workspace
. Consider changing that API to accept Vec<PathBuf>
directly to simplify conversions and improve type safety.
Copilot uses AI. Check for mistakes.
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.
这里不确定要不要改,感觉 AI 说的有道理。
|
||
#[allow(unused)] | ||
pub fn load_workspace(workspace_folders: Vec<&str>) -> Option<EmmyLuaAnalysis> { | ||
pub fn load_workspace(workspace_folders: Vec<String>) -> Option<EmmyLuaAnalysis> { |
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.
Since you're immediately mapping these String
values back into PathBuf
, it would be clearer and more efficient to accept Vec<PathBuf>
here instead of Vec<String>
.
Copilot uses AI. Check for mistakes.
额。。。好像合并早了,有 AI 的 review 意见还没合并进来。 |
无所谓, 我自己改 |
我已经改完了, 你可以试试 |
好的,我逐步将项目的文档迁移到 emmylua 生态,目前的策略是基于上游的 doc_cli 加少量的 mkdocs 定制。有通用的东西我都尽量抽出来,提交到上游吧。 |
我的项目,只有个别目录,需要生成文档,所以不希望传根目录到 input 参数。
把目录添加到 .emmyrc.json 的 library 字段应该也可以,但 input 又是必填的,索性 input 也支持多个值。