Skip to content

Conversation

myzhan
Copy link
Contributor

@myzhan myzhan commented Jun 30, 2025

我的项目,只有个别目录,需要生成文档,所以不希望传根目录到 input 参数。

把目录添加到 .emmyrc.json 的 library 字段应该也可以,但 input 又是必填的,索性 input 也支持多个值。

@CppCXY CppCXY requested a review from Copilot June 30, 2025 03:10
Copilot

This comment was marked as outdated.

}
None => {
eprintln!("Error: {} is not a valid path.", path.to_str().unwrap());
exit(1);
Copy link
Member

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>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个主要是跟下面那部分代码保持一致的风格,load_workspace 失败,也是打印日志,和直接 exit。

@CppCXY CppCXY requested a review from Copilot June 30, 2025 03:42
Copy link
Contributor

@Copilot Copilot AI left a 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 of PathBuf values.
  • Updated main.rs to normalize each path to an absolute String and pass them into load_workspace.
  • Adjusted load_workspace signature to take Vec<String> instead of Vec<&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 but std::process::exit isn't imported. Either add use std::process::exit; at the top or qualify this call as std::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());
Copy link
Preview

Copilot AI Jun 30, 2025

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.

Suggested change
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);
Copy link
Preview

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're converting PathBufStringPathBuf 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.

Copy link
Contributor Author

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> {
Copy link
Preview

Copilot AI Jun 30, 2025

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.

@CppCXY CppCXY merged commit a28cb61 into EmmyLuaLs:main Jun 30, 2025
15 checks passed
@myzhan
Copy link
Contributor Author

myzhan commented Jun 30, 2025

额。。。好像合并早了,有 AI 的 review 意见还没合并进来。

@CppCXY
Copy link
Member

CppCXY commented Jun 30, 2025

无所谓, 我自己改

@CppCXY
Copy link
Member

CppCXY commented Jun 30, 2025

我已经改完了, 你可以试试

@myzhan
Copy link
Contributor Author

myzhan commented Jun 30, 2025

好的,我逐步将项目的文档迁移到 emmylua 生态,目前的策略是基于上游的 doc_cli 加少量的 mkdocs 定制。有通用的东西我都尽量抽出来,提交到上游吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants