@@ -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 "don't" or "can't". Do not
833- use these in documentation. Always write their "full form":</ p >
834- < ul >
835- < li > "do not" instead of "don't"</ li >
836- < li > "cannot" instead of "can't"</ li >
837- < li > "it would" instead of "it'd"</ li >
838- < li > "it will" instead of "it'll"</ li >
839- < li > "it is"/"it has" instead of "it's"</ li >
840- < li > "you are" instead of "you're"</ li >
841- < li > "they are" instead of "they're"</ li >
842- < li > etc</ li >
843- </ ul >
844- < p > The only exception to this rule is "let's" 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
848833inline 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 > )
855840should 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<String></ 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`]`<`[`String`]`>`.
862- </ code > </ pre >
863- < p > Extra explanations: since both < code > Vec</ code > and < code > String</ code > are in codeblocks, < code > <</ code > and < code > ></ 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
867846blocks 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
921901is working as expected. It also allows the readers to understand more easily
922902what the function is doing (or returning).</ p >
923- < pre > < code class ="language-text "> # Examples
903+ < pre > < code class ="language-text "> # Example
924904
925905```
926906let s = MyType::new("hello ");
0 commit comments