我刚开始接触 Rust,尝试为我编写的代码生成文档。当我输入“cargo doc”时,看到了一些奇怪的东西。
当我打开
21:53 $ cargo doc
Compiling regex-syntax v0.2.2
Compiling libc v0.2.2
Compiling memchr v0.1.7
Compiling aho-corasick v0.3.4
Compiling regex v0.1.41
Compiling my_project v0.0.1 (path/to/my_project)
当我打开
my_project/target/doc/my_project/index.html
时,我注意到我的文档中包含了所有的依赖项。
我希望用户看到的只有如何使用 我的 代码,而不是这些依赖项的文档。如何实现这一点?
Cargo.lock
[root]
name = "my_project"
version = "0.0.1"
dependencies = [
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "aho-corasick"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "memchr"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
cargo do
是不包括依赖的,而cargo doc --with-deps
则包括依赖。 - yerlilbilgin--no-deps
标志之前已生成了文档,则需要删除/target/doc
目录并重新生成文档,以便清除出现在页面上的依赖项。在我尝试这样做之前,我很困惑为什么这不起作用。 - Keavon