Skip to content

Add docs about crate level documentation support #76289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/doc/rustdoc/src/what-is-rustdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ passes `-L`, a flag that helps rustdoc find the dependencies
your code relies on. If our project used dependencies, we'd get
documentation for them as well!

## Outer and inner documentation

The `///` syntax is used to document the item present after it.
That's why it is called an outer documentation.
There is another syntax: `//!`, which is used to document the
item it is present inside. It is called an inner documentation.
It is often used when documenting the entire crate,
because nothing comes before it: it is the root of the crate.
So in order to document an entire crate, you need to use `//!` syntax.
For example:

``` rust
//! This is my first rust crate
```

When used in the crate root, it documents the item it is inside,
which is the crate itself.

For more information about the `//!` syntax, see [the Book].

[the Book]: https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#commenting-contained-items


## Using standalone Markdown files

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