Skip to content

Commit 91c3ef8

Browse files
authored
Rollup merge of #76289 - arijit79:master, r=jyn514
Add docs about crate level documentation support Wrote information about how to write documentation on the crate level in rhe rustdoc book
2 parents 5aed495 + fd5859a commit 91c3ef8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/doc/rustdoc/src/what-is-rustdoc.md

+23
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@ passes `-L`, a flag that helps rustdoc find the dependencies
9393
your code relies on. If our project used dependencies, we'd get
9494
documentation for them as well!
9595

96+
## Outer and inner documentation
97+
98+
The `///` syntax is used to document the item present after it.
99+
That's why it is called an outer documentation.
100+
There is another syntax: `//!`, which is used to document the
101+
item it is present inside. It is called an inner documentation.
102+
It is often used when documenting the entire crate,
103+
because nothing comes before it: it is the root of the crate.
104+
So in order to document an entire crate, you need to use `//!` syntax.
105+
For example:
106+
107+
``` rust
108+
//! This is my first rust crate
109+
```
110+
111+
When used in the crate root, it documents the item it is inside,
112+
which is the crate itself.
113+
114+
For more information about the `//!` syntax, see [the Book].
115+
116+
[the Book]: https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#commenting-contained-items
117+
118+
96119
## Using standalone Markdown files
97120

98121
`rustdoc` can also generate HTML from standalone Markdown files. Let's

0 commit comments

Comments
 (0)