@@ -828,21 +828,6 @@ <h2 id="inside-safe-elements"><a class="header" href="#inside-safe-elements">Ins
828
828
< 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 >
829
829
< p > This document explains how to write documentation for the std/core public APIs.</ p >
830
830
< 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 >
846
831
< 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 >
847
832
< p > Whenever you are talking about a type or anything code related, it should be in a
848
833
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-
853
838
< p > Intra-doc links (you can see the full explanations for the feature
854
839
< a href ="https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html "> here</ a > )
855
840
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<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 >
865
844
< h3 id ="code-blocks "> < a class ="header " href ="#code-blocks "> Code blocks</ a > </ h3 >
866
845
< p > With rustdoc, code blocks are tested (because they are treated as Rust code
867
846
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>
916
895
</ code > </ pre >
917
896
< h3 id ="examples "> < a class ="header " href ="#examples "> Examples</ a > </ h3 >
918
897
< 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 >
920
900
< p > It is better if you use < code > assert*!</ code > macros at the end to ensure that the example
921
901
is working as expected. It also allows the readers to understand more easily
922
902
what the function is doing (or returning).</ p >
923
- < pre > < code class ="language-text "> # Examples
903
+ < pre > < code class ="language-text "> # Example
924
904
925
905
```
926
906
let s = MyType::new("hello ");
0 commit comments