Skip to content

Commit 1b56a24

Browse files
GH Actions RunnerGH Actions Runner
GH Actions Runner
authored and
GH Actions Runner
committed
publish: Merge pull request #38 from GuillaumeGomez/how-to-write-docs
generated from commit 0cb9115
1 parent 68902e5 commit 1b56a24

File tree

4 files changed

+14
-54
lines changed

4 files changed

+14
-54
lines changed

documentation/how-to-write-documentation.html

+6-26
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,6 @@ <h1 class="menu-title">Standard library developers Guide</h1>
151151
<h1 id="how-to-write-documentation"><a class="header" href="#how-to-write-documentation">How to write documentation</a></h1>
152152
<p>This document explains how to write documentation for the std/core public APIs.</p>
153153
<p>Let's start with some general information:</p>
154-
<h3 id="contractions"><a class="header" href="#contractions">Contractions</a></h3>
155-
<p>It is common in English to have contractions such as &quot;don't&quot; or &quot;can't&quot;. Do not
156-
use these in documentation. Always write their &quot;full form&quot;:</p>
157-
<ul>
158-
<li>&quot;do not&quot; instead of &quot;don't&quot;</li>
159-
<li>&quot;cannot&quot; instead of &quot;can't&quot;</li>
160-
<li>&quot;it would&quot; instead of &quot;it'd&quot;</li>
161-
<li>&quot;it will&quot; instead of &quot;it'll&quot;</li>
162-
<li>&quot;it is&quot;/&quot;it has&quot; instead of &quot;it's&quot;</li>
163-
<li>&quot;you are&quot; instead of &quot;you're&quot;</li>
164-
<li>&quot;they are&quot; instead of &quot;they're&quot;</li>
165-
<li>etc</li>
166-
</ul>
167-
<p>The only exception to this rule is &quot;let's&quot; as it is specific/known/common enough.</p>
168-
<p>The reason is simply to make the reading simpler for as many people as possible.</p>
169154
<h3 id="when-to-use-inline-code-blocks"><a class="header" href="#when-to-use-inline-code-blocks">When to use inline code blocks</a></h3>
170155
<p>Whenever you are talking about a type or anything code related, it should be in a
171156
inline code block. As a reminder, a inline code block is created with backticks
@@ -176,15 +161,9 @@ <h3 id="when-to-use-intra-doc-links"><a class="header" href="#when-to-use-intra-
176161
<p>Intra-doc links (you can see the full explanations for the feature
177162
<a href="https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html">here</a>)
178163
should be used as much as possible whenever a type is mentioned.</p>
179-
<p>Little note: when you are documenting an item, no need to link to it. So if you
180-
write documentation for <code>String::push_str</code> method, no need to link to the method
181-
<code>push_str</code> or to the <code>String</code> type.</p>
182-
<p>If you have cases like <code>Vec&lt;String&gt;</code>, you need to use intra-doc links on both
183-
<code>Vec</code> and <code>String</code> as well. It would look like this:</p>
184-
<pre><code class="language-text">This is a [`Vec`]`&lt;`[`String`]`&gt;`.
185-
</code></pre>
186-
<p>Extra explanations: since both <code>Vec</code> and <code>String</code> are in codeblocks, <code>&lt;</code> and <code>&gt;</code>
187-
should as well, otherwise it would render badly.</p>
164+
<p>Little note: when you are documenting an item, there is no need to link to it.
165+
So, if you write documentation for the <code>String::push_str</code> method, there is
166+
no need to link to the <code>push_str</code> method or the <code>String</code> type.</p>
188167
<h3 id="code-blocks"><a class="header" href="#code-blocks">Code blocks</a></h3>
189168
<p>With rustdoc, code blocks are tested (because they are treated as Rust code
190169
blocks by default). It allows us to know if the documentation is up to date. As
@@ -239,11 +218,12 @@ <h3 id="panic"><a class="header" href="#panic">Panic?</a></h3>
239218
</code></pre>
240219
<h3 id="examples"><a class="header" href="#examples">Examples</a></h3>
241220
<p>As for the examples, they have to show the usage of the function/method. Just
242-
like the <code>panic</code> section, they need to be prepended by a <code>Examples</code> title.</p>
221+
like the <code>panic</code> section, they need to be prepended by a <code>Example</code> title (plural
222+
if there is more than one).</p>
243223
<p>It is better if you use <code>assert*!</code> macros at the end to ensure that the example
244224
is working as expected. It also allows the readers to understand more easily
245225
what the function is doing (or returning).</p>
246-
<pre><code class="language-text"># Examples
226+
<pre><code class="language-text"># Example
247227

248228
```
249229
let s = MyType::new(&quot;hello &quot;);

print.html

+6-26
Original file line numberDiff line numberDiff line change
@@ -828,21 +828,6 @@ <h2 id="inside-safe-elements"><a class="header" href="#inside-safe-elements">Ins
828828
<div style="break-before: page; page-break-before: always;"></div><h1 id="how-to-write-documentation"><a class="header" href="#how-to-write-documentation">How to write documentation</a></h1>
829829
<p>This document explains how to write documentation for the std/core public APIs.</p>
830830
<p>Let's start with some general information:</p>
831-
<h3 id="contractions"><a class="header" href="#contractions">Contractions</a></h3>
832-
<p>It is common in English to have contractions such as &quot;don't&quot; or &quot;can't&quot;. Do not
833-
use these in documentation. Always write their &quot;full form&quot;:</p>
834-
<ul>
835-
<li>&quot;do not&quot; instead of &quot;don't&quot;</li>
836-
<li>&quot;cannot&quot; instead of &quot;can't&quot;</li>
837-
<li>&quot;it would&quot; instead of &quot;it'd&quot;</li>
838-
<li>&quot;it will&quot; instead of &quot;it'll&quot;</li>
839-
<li>&quot;it is&quot;/&quot;it has&quot; instead of &quot;it's&quot;</li>
840-
<li>&quot;you are&quot; instead of &quot;you're&quot;</li>
841-
<li>&quot;they are&quot; instead of &quot;they're&quot;</li>
842-
<li>etc</li>
843-
</ul>
844-
<p>The only exception to this rule is &quot;let's&quot; as it is specific/known/common enough.</p>
845-
<p>The reason is simply to make the reading simpler for as many people as possible.</p>
846831
<h3 id="when-to-use-inline-code-blocks"><a class="header" href="#when-to-use-inline-code-blocks">When to use inline code blocks</a></h3>
847832
<p>Whenever you are talking about a type or anything code related, it should be in a
848833
inline code block. As a reminder, a inline code block is created with backticks
@@ -853,15 +838,9 @@ <h3 id="when-to-use-intra-doc-links"><a class="header" href="#when-to-use-intra-
853838
<p>Intra-doc links (you can see the full explanations for the feature
854839
<a href="https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html">here</a>)
855840
should be used as much as possible whenever a type is mentioned.</p>
856-
<p>Little note: when you are documenting an item, no need to link to it. So if you
857-
write documentation for <code>String::push_str</code> method, no need to link to the method
858-
<code>push_str</code> or to the <code>String</code> type.</p>
859-
<p>If you have cases like <code>Vec&lt;String&gt;</code>, you need to use intra-doc links on both
860-
<code>Vec</code> and <code>String</code> as well. It would look like this:</p>
861-
<pre><code class="language-text">This is a [`Vec`]`&lt;`[`String`]`&gt;`.
862-
</code></pre>
863-
<p>Extra explanations: since both <code>Vec</code> and <code>String</code> are in codeblocks, <code>&lt;</code> and <code>&gt;</code>
864-
should as well, otherwise it would render badly.</p>
841+
<p>Little note: when you are documenting an item, there is no need to link to it.
842+
So, if you write documentation for the <code>String::push_str</code> method, there is
843+
no need to link to the <code>push_str</code> method or the <code>String</code> type.</p>
865844
<h3 id="code-blocks"><a class="header" href="#code-blocks">Code blocks</a></h3>
866845
<p>With rustdoc, code blocks are tested (because they are treated as Rust code
867846
blocks by default). It allows us to know if the documentation is up to date. As
@@ -916,11 +895,12 @@ <h3 id="panic"><a class="header" href="#panic">Panic?</a></h3>
916895
</code></pre>
917896
<h3 id="examples"><a class="header" href="#examples">Examples</a></h3>
918897
<p>As for the examples, they have to show the usage of the function/method. Just
919-
like the <code>panic</code> section, they need to be prepended by a <code>Examples</code> title.</p>
898+
like the <code>panic</code> section, they need to be prepended by a <code>Example</code> title (plural
899+
if there is more than one).</p>
920900
<p>It is better if you use <code>assert*!</code> macros at the end to ensure that the example
921901
is working as expected. It also allows the readers to understand more easily
922902
what the function is doing (or returning).</p>
923-
<pre><code class="language-text"># Examples
903+
<pre><code class="language-text"># Example
924904

925905
```
926906
let s = MyType::new(&quot;hello &quot;);

searchindex.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

searchindex.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)