<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>rustdoc 手册 on 编程那些事儿</title><link>https://before80.github.io/prgms/Rust/rustdoc/</link><description>Recent content in rustdoc 手册 on 编程那些事儿</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Tue, 11 Aug 2026 23:57:44 +0800</lastBuildDate><atom:link href="https://before80.github.io/prgms/Rust/rustdoc/index.xml" rel="self" type="application/rss+xml"/><item><title>01-rustdoc 是什么？</title><link>https://before80.github.io/prgms/Rust/rustdoc/01-what-is-rustdoc/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/01-what-is-rustdoc/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="what-is-rustdoc"&gt;rustdoc 是什么？&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html"&gt;https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;标准 Rust 发行版自带一个名为 &lt;code&gt;rustdoc&lt;/code&gt; 的工具。它的工作是为 Rust 项目生成文档。从根本上说，rustdoc 接收一个 crate 根或一个 Markdown 文件作为参数，并产出 HTML、CSS 和 JavaScript。&lt;/p&gt;</description></item><item><title>02-命令行参数</title><link>https://before80.github.io/prgms/Rust/rustdoc/02-command-line-arguments/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/02-command-line-arguments/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="command-line-arguments"&gt;命令行参数&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/command-line-arguments.html"&gt;https://doc.rust-lang.org/rustdoc/command-line-arguments.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;以下是你可以传给 &lt;code&gt;rustdoc&lt;/code&gt; 的参数列表：&lt;/p&gt;
&lt;h2 id="h---help-help"&gt;&lt;code&gt;-h&lt;/code&gt;/&lt;code&gt;--help&lt;/code&gt;：帮助&lt;/h2&gt;
&lt;p&gt;使用该标志如下：&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#58626f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#58626f"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ rustdoc -h
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ rustdoc --help
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;这会显示 &lt;code&gt;rustdoc&lt;/code&gt; 的内置帮助，其中主要是可能的命令行标志列表。&lt;/p&gt;</description></item><item><title>05-rustdoc 专用 lint</title><link>https://before80.github.io/prgms/Rust/rustdoc/05-rustdoc-specific-lints/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/05-rustdoc-specific-lints/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="lints"&gt;rustdoc 专用 lint&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/lints.html"&gt;https://doc.rust-lang.org/rustdoc/lints.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;code&gt;rustdoc&lt;/code&gt; 提供了一些 lint，帮助你编写和测试文档。你可以像使用其他 lint 一样使用它们：&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#58626f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#58626f"&gt;2
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#58626f"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-rust" data-lang="rust"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8a93a5;font-style:italic"&gt;#![allow(rustdoc::broken_intra_doc_links)]&lt;/span&gt; &lt;span style="color:#8a93a5;font-style:italic"&gt;// 允许该 lint，不会报告任何诊断
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8a93a5;font-style:italic"&gt;#![warn(rustdoc::broken_intra_doc_links)]&lt;/span&gt; &lt;span style="color:#8a93a5;font-style:italic"&gt;// 若存在损坏的文档内链接则警告
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8a93a5;font-style:italic"&gt;#![deny(rustdoc::broken_intra_doc_links)]&lt;/span&gt; &lt;span style="color:#8a93a5;font-style:italic"&gt;// 若存在损坏的文档内链接则报错
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;注意，除了 &lt;code&gt;missing_docs&lt;/code&gt; 之外，这些 lint 仅在运行 &lt;code&gt;rustdoc&lt;/code&gt; 时可用，在 &lt;code&gt;rustc&lt;/code&gt; 中不可用。&lt;/p&gt;</description></item><item><title>06-抓取示例</title><link>https://before80.github.io/prgms/Rust/rustdoc/06-scraped-examples/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/06-scraped-examples/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="scraped-examples"&gt;抓取示例&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/scraped-examples.html"&gt;https://doc.rust-lang.org/rustdoc/scraped-examples.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Rustdoc 有一项不稳定特性：可以自动从 Cargo workspace 的 &lt;code&gt;examples/&lt;/code&gt; 目录中抓取被文档化项的用法示例。这些示例会包含在该项目生成的文档中。例如，若你的库中有一个公开函数：&lt;/p&gt;</description></item><item><title>07-高级特性</title><link>https://before80.github.io/prgms/Rust/rustdoc/07-advanced-features/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/07-advanced-features/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="advanced-features"&gt;高级特性&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/advanced-features.html"&gt;https://doc.rust-lang.org/rustdoc/advanced-features.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;本页列出的特性不属于其他主要分类。&lt;/p&gt;
&lt;h2 id="cfgdoc-documenting-platform-specific-or-feature-specific-information"&gt;&lt;code&gt;#[cfg(doc)]&lt;/code&gt;：文档化平台相关或特性相关信息&lt;/h2&gt;
&lt;p&gt;对于条件编译，Rustdoc 对你的 crate 的处理方式与编译器相同。只有宿主目标上的内容可用（或使用给定的 &lt;code&gt;--target&lt;/code&gt; 时该目标上的内容），其余内容会从 crate 中被“过滤掉”。若你的 crate 在不同目标上提供不同内容，而你又希望文档反映所提供的全部项，这就会带来问题。&lt;/p&gt;</description></item><item><title>08-不稳定特性</title><link>https://before80.github.io/prgms/Rust/rustdoc/08-unstable-features/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/08-unstable-features/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="unstable-features"&gt;不稳定特性&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/unstable-features.html"&gt;https://doc.rust-lang.org/rustdoc/unstable-features.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Rustdoc 仍在积极开发中，与 Rust 编译器类似，有些功能仅在 nightly 版本中可用。其中一部分是新功能，需要更多测试才能广泛发布；另一部分则与编译器中的不稳定特性绑定。此处若干特性需要匹配的 &lt;code&gt;#![feature(...)]&lt;/code&gt; 属性才能启用，因此在 &lt;a href="https://doc.rust-lang.org/unstable-book/"&gt;不稳定手册（Unstable Book）&lt;/a&gt; 中有更完整的文档。相关小节会在必要时链接到该手册。&lt;/p&gt;</description></item><item><title>09-已弃用特性</title><link>https://before80.github.io/prgms/Rust/rustdoc/09-deprecated-features/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/09-deprecated-features/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="deprecated-features"&gt;已弃用特性&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/deprecated-features.html"&gt;https://doc.rust-lang.org/rustdoc/deprecated-features.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="passes"&gt;Passes&lt;/h2&gt;
&lt;p&gt;Rustdoc 有一个称为 “passes” 的概念。它们是 &lt;code&gt;rustdoc&lt;/code&gt; 在生成最终输出之前对文档执行的变换。&lt;/p&gt;
&lt;p&gt;自定义 passes &lt;strong&gt;已弃用&lt;/strong&gt;。可用的 passes 不视为稳定，可能在任何发行版中变更。&lt;/p&gt;</description></item><item><title>10-参考资料</title><link>https://before80.github.io/prgms/Rust/rustdoc/10-references/</link><pubDate>Sat, 01 Aug 2026 07:35:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/rustdoc/10-references/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://doc.rust-lang.org/rustdoc/"&gt;The rustdoc book&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="references"&gt;参考资料&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://doc.rust-lang.org/rustdoc/references.html"&gt;https://doc.rust-lang.org/rustdoc/references.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;网上有许多优秀的 &lt;code&gt;rustdoc&lt;/code&gt; 参考资料。
若你还知道其他好资源，欢迎提交 pull request！&lt;/p&gt;
&lt;h2 id="official"&gt;官方&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#making-useful-documentation-comments"&gt;Learn Rust&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://doc.rust-lang.org/stable/rust-by-example/meta/doc.html"&gt;Rust By Example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://doc.rust-lang.org/stable/reference/comments.html#doc-comments"&gt;Rust Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html"&gt;RFC 1574: More API Documentation Conventions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html"&gt;RFC 1946: Intra Rustdoc Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="community"&gt;社区&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://rust-lang.github.io/api-guidelines/documentation.html"&gt;API Guidelines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rust-lang/rfcs/issues?q=label%3AT-rustdoc"&gt;GitHub tagged RFCs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AT-rustdoc"&gt;GitHub tagged issues&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rust-lang/rfcs/pull/1687"&gt;RFC (stalled) front page styleguide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.guillaume-gomez.fr/articles/2020-03-12+Guide+on+how+to+write+documentation+for+a+Rust+crate"&gt;Guide on how to write documentation for a Rust crate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>