From 9ec8a5ae40505849b70c288205f824334f20985b Mon Sep 17 00:00:00 2001 From: mengfansheng Date: Sat, 15 Jun 2024 11:22:23 +0800 Subject: [PATCH] Chinese part command-line-arguments.md --- src/command-line-arguments.md | 95 ++++++++++++++++------------------- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/src/command-line-arguments.md b/src/command-line-arguments.md index b9ba0fb..dd2060e 100644 --- a/src/command-line-arguments.md +++ b/src/command-line-arguments.md @@ -17,15 +17,14 @@ $ rustdoc --help ## `-V`/`--version`: version information -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc -V $ rustdoc --version ``` -This will show `rustdoc`'s version, which will look something -like this: +这将显示 `rustdoc` 的版本,如下所示: ```text rustdoc 1.17.0 (56124baa9 2017-04-24) @@ -33,16 +32,16 @@ rustdoc 1.17.0 (56124baa9 2017-04-24) ## `-v`/`--verbose`: more verbose output -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc -v src/lib.rs $ rustdoc --verbose src/lib.rs ``` -This enables "verbose mode", which means that more information will be written -to standard out. What is written depends on the other flags you've passed in. -For example, with `--version`: +这将启用 "冗长模式",即会将更多信息写入标准输出。 +写入的内容取决于你传入的其它标志。 +例如,使用 `--version`: ```text $ rustdoc --verbose --version @@ -57,38 +56,36 @@ LLVM version: 3.9 ## `-o`/`--out-dir`: output directory path -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs -o target/doc $ rustdoc src/lib.rs --out-dir target/doc ``` -By default, `rustdoc`'s output appears in a directory named `doc` in -the current working directory. With this flag, it will place all output -into the directory you specify. +默认情况下,`rustdoc` 的输出会出现在当前工作目录下名为 `doc` 的目录中。 +使用此标记后,它将把所有输出到你指定的目录。 ## `--crate-name`: controlling the name of the crate -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --crate-name mycrate ``` -By default, `rustdoc` assumes that the name of your crate is the same name -as the `.rs` file. `--crate-name` lets you override this assumption with -whatever name you choose. +默认情况下,"rustdoc"会假定你的 crate 名称与".rs "文件相同。 +您可以使用 `--crate-name` 来覆盖这一假设。 ## `--document-private-items`: Show items that are not public -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --document-private-items ``` -By default, `rustdoc` only documents items that are publicly reachable. +默认情况下,`rustdoc` 只记录可公开访问的项目。 ```rust pub fn public() {} // this item is public and will be documented @@ -101,47 +98,44 @@ mod private { // this item is private and will not be documented ## `-L`/`--library-path`: where to look for dependencies -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs -L target/debug/deps $ rustdoc src/lib.rs --library-path target/debug/deps ``` -If your crate has dependencies, `rustdoc` needs to know where to find them. -Passing `--library-path` gives `rustdoc` a list of places to look for these -dependencies. +如果你的 crate 有依赖库,`rustdoc` 需要知道在哪里可以找到它们。 +传递 `--library-path` 会给 `rustdoc` 提供一个查找这些依赖项的列表。 -This flag takes any number of directories as its argument, and will use all of -them when searching. +这个标志可以接受任意数量的目录作为参数,并在搜索时使用所有的目录。 ## `--cfg`: passing configuration flags -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --cfg feature="foo" ``` -This flag accepts the same values as `rustc --cfg`, and uses it to configure -compilation. The example above uses `feature`, but any of the `cfg` values -are acceptable. +该flag接受与 `rustc --cfg` 相同的值,并用它来配置编译。 +上面的例子使用了 `feature`,但任何 `cfg` 值都可以接受。 ## `--extern`: specify a dependency's location -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --extern lazy-static=/path/to/lazy-static ``` -Similar to `--library-path`, `--extern` is about specifying the location -of a dependency. `--library-path` provides directories to search in, `--extern` -instead lets you specify exactly which dependency is located where. +与"--library-path "类似,"--extern "是关于指定的位置。 +library-path "提供了搜索目录,而"--extern则可以让你精 +确地指定依赖项的位置。 ## `-C`/`--codegen`: pass codegen options to rustc -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs -C target_feature=+avx @@ -154,54 +148,51 @@ $ rustdoc --test README.md -C target_feature=+avx $ rustdoc --test README.md --codegen target_feature=+avx ``` -When rustdoc generates documentation, looks for documentation tests, or executes documentation -tests, it needs to compile some rust code, at least part-way. This flag allows you to tell rustdoc -to provide some extra codegen options to rustc when it runs these compilations. Most of the time, -these options won't affect a regular documentation run, but if something depends on target features -to be enabled, or documentation tests need to use some additional options, this flag allows you to -affect that. +当 rustdoc 生成文档、查找文档测试或执行文档测试时,它需要编译一些 rust 代码,至少是部分编译。 +测试时,需要编译一些 rust 代码,至少是部分编译。这个flag允许你告诉 rustdoc +在运行这些编译时向 rustc 提供一些额外的 codegen 选项。 +大多数情况下这些选项不会影响正常的文档运行,但如果某些内容依赖于目标特性 +或者文档测试需要使用一些额外的选项,这个flag允许你影响。 -The arguments to this flag are the same as those for the `-C` flag on rustc. Run `rustc -C help` to -get the full list. +该标志的参数与 rustc 的 `-C` 标志相同。运行 `rustc -C help` 以 +获得完整的列表。 ## `--test`: run code examples as tests -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --test ``` -This flag will run your code examples as tests. For more, see [the chapter -on documentation tests](documentation-tests.md). +该flag将把你的代码示例作为测试运行。更多信息,请参阅(document-tests.md)。 -See also `--test-args`. +另请参阅 `--test-args`。 ## `--test-args`: pass options to test runner -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --test --test-args ignored ``` -This flag will pass options to the test runner when running documentation tests. -For more, see [the chapter on documentation tests](documentation-tests.md). +运行文档测试时,该flag将向测试运行器传递选项。 +更多信息,请参阅(document-tests.md)。 -See also `--test`. +另请参阅 `--test`。 ## `--target`: generate documentation for the specified target triple -Using this flag looks like this: +使用该flag的方式如下: ```bash $ rustdoc src/lib.rs --target x86_64-pc-windows-gnu ``` -Similar to the `--target` flag for `rustc`, this generates documentation -for a target triple that's different than your host triple. +与 `rustc` 的 `--target` 标志类似,它会为与主机三元组不同的目标三元组生成文档。 -All of the usual caveats of cross-compiling code apply. +交叉编译代码的所有常见注意事项均适用。 ## `--default-theme`: set the default theme