当我运行命令时,它似乎没有为我的项目库生成文档。我正在使用最新版本的Rust,如此帖子所回答的:如何在通过Cargo生成文档时包含私有模块?
这是我的目录结构:
这段代码可以编译并成功运行,但我不确定为什么文档未能正确生成。这是我运行时生成的文档截图:
。我无法在任何地方找到
- services/
- mod.rs
- my_service.rs
- lib.rs
- main.rs
main.rs
中只包含启动程序的 "main" 函数:
use test_doc::Core;
fn main() {
Core::start();
}
lib.rs
包含实际的逻辑:
mod services;
/// Core process
pub struct Core;
impl Core {
pub fn start() -> ! {
loop {
// do stuff here
}
}
}
接下来,my_service.rs
包含了一些更多的逻辑:
/// My service should do stuff
pub struct MyService;
impl MyService {
/// This function actually does stuff
pub fn do_stuff(&self) -> &'static str {
"doing stuff"
}
}
mod.rs
在my_service
文件夹内仅用作入口点:
pub mod my_service;
这段代码可以编译并成功运行,但我不确定为什么文档未能正确生成。这是我运行时生成的文档截图:
![enter image description here](https://istack.dev59.com/IfQsi.webp)
MyService
的文档...... (点击“Structs”链接只会跳转到主页面上的锚点)。
main.rs
和lib.rs
两个文件。那么它是一个库还是一个二进制文件?或者两者都是? - l3utterflycargo doc --lib --open
命令来生成库的文档,但它仍然无法正常工作。 - l3utterflycargo doc --lib --open --document-private-items
,生成文档并打开私有项的文档。 - Shepmaster