Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd API documentation front page styleguide #1687
Conversation
added some commits
Jul 25, 2016
This comment has been minimized.
This comment has been minimized.
sfackler
reviewed
Jul 25, 2016
| > | ||
| > If no logging implementation is selected, the facade falls back to a "noop" implementation | ||
| > that ignores all log messages. The overhead in this case is very small - just an integer load, | ||
| > comparison and jump. > > A log request consists of a target, a level, and a body. A target |
This comment has been minimized.
This comment has been minimized.
sfackler
reviewed
Jul 25, 2016
|
|
||
| * A concise explanation of the crate's purpose. | ||
| * The summary describes how the crate behaves in 3 short paragraphs. | ||
| * Even if you don't want to read the rest of the `README`, you have enough to get started. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nagisa
Jul 26, 2016
Contributor
I always find myself copying the description from the crate-level introduction to README. Something that we could work on abstracting.
This comment has been minimized.
This comment has been minimized.
|
I think @sfackler's comment here is actually an interesting one when taken more broadly as well. In terms of the "front page" of a crate, should we conventionally put more efforts into READMEs or crate documentation? A README tends to actually be the first thing you read when hitting a crate (e.g. looking at the source on GitHub), and only afterwards might you go look at the documentation. That being said I'd personally prefer to put all documentation into the crate as it reduces duplication and it should "live with the code". Perhaps though discussion about this may be appropriate for this RFC? |
nagisa
reviewed
Jul 26, 2016
|
|
||
| This RFC is a companion to the [API doc guidelines proposal] | ||
| (https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md). | ||
| In this RFC, we focus on the format and style of the "front page" of an API. The goal of this |
This comment has been minimized.
This comment has been minimized.
nagisa
Jul 26, 2016
Contributor
You mean front page of documentation as generated by rustdoc? “API” is a function or a set of functions exposed to other programmers and the acronym is in no way related to presentation.
nagisa
reviewed
Jul 26, 2016
| What do we mean by "no jargon is introduced in the first few paragraphs"? Using the `rand` crate as | ||
| an example - the crate's initial documentation probably should _not_ include a discussion of | ||
| cryptographically secure random number generators since its primary purpose, for most Rust | ||
| developers, will be to produce any random number. This information should instead be provided in a |
This comment has been minimized.
This comment has been minimized.
nagisa
Jul 26, 2016
•
Contributor
primary purpose, for most Rust developers, will be to produce any random number
That is a great misconception. It is very easy to incorrectly decide on a random number generator for pretty much all the use cases without taking in account the cryptosafety of the generator and the need for it. Even the trivial die-rolling games are flawed without a crypto-safe generator in some circumstances.
That being said, I do agree that discussion about generator’s crypto-safety should be elsewhere (such as the generators themselves)
nagisa
reviewed
Jul 26, 2016
|
|
||
| Let's look at a sample of a good first example of a crate. Notice that the author has focused on | ||
| getting started, showing how to import and use the crate, and a few simple uses of common | ||
| functionality. |
This comment has been minimized.
This comment has been minimized.
nagisa
Jul 26, 2016
•
Contributor
Lately I’ve begun to also include a snippet that may be copy-pasted into a Cargo.toml (reasons in next paragraph). I’d suggest including that into this recommendation as well.
I do so, because the first thing I check out about the crate is its documentation. Seeing something like
//! ```toml
//! [build-dependencies]
//! gcc = "0.3"
//! ```
saves me the effort of:
- remembering the crate name (e.g. crate is gcc, repository is gcc-rs; causes confusion);
- figuring out what the latest version is;
- what section I am supposed to put the dependency into;
The last point is esp. important when adding a dependency to a project which had no dependencies before, or adding the dependency in non-trivial ways (say with some features enabled/disabled) – I have trouble remembering how to do those things all the time.
Basically my first example becomes a Usage instead with step-by-step instructions on how to use a crate beginning with getting it into your cargo project.
This comment has been minimized.
This comment has been minimized.
frewsxcv
Dec 15, 2016
Member
saves me the effort of:
- figuring out what the latest version is;
From what I've witnessed, It is very common for library maintainers to forget to bump this number in the documentation, which I think is a worse user-experience than just not mentioning it at all.
That said, when it is the correct version number, I do find the section helpful. So I'm pretty neutral on this.
This comment has been minimized.
This comment has been minimized.
|
When someone links to the docs, there often isn't a link back to the repo or the crate which isn't really nice. This can be manually added but often isn't. It could be added as a convention. Alternatively, maybe a shield could be added for the crate and repository or something. It seems like something which would probably be easy to include in rustdoc (not quite sure but it seems like it). |
This comment has been minimized.
This comment has been minimized.
If we make that a convention or shield, could we do the same for a link to crates.io, I also often want that from a docs page. |
nrc
added
the
T-libs
label
Jul 26, 2016
This comment has been minimized.
This comment has been minimized.
|
That's actually what I meant by crate but yeah, that'd be cool. |
jbcden
reviewed
Jul 27, 2016
| ## Introduction text to the crate | ||
|
|
||
| The first thing potential users of your crates will see is the introductory summary. This section is | ||
| a good place to introduce the what and the why the crate. A good introduction is concise but also |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
About the
These things shouldn't be in the doc and should remain in the |
jbcden
reviewed
Jul 27, 2016
| It's helpful to introduce and give a clear description for each capability separately to help your | ||
| readers understand each concept individually before they begin to combine capabilities. | ||
|
|
||
| Here's a good example from the 'rand' crate: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jbcden
Jul 27, 2016
I wonder if this should be a link. When mentioning the log crate above you make it a link. I don't think a link has been provided for rand yet despite multiple mentions.
jbcden
reviewed
Jul 27, 2016
| ## Capability Examples | ||
|
|
||
| Sample code for each crate capability should be as simple as possible and side effect free. In the | ||
| rand crate, thread safe RNG is demonstrated 5 lines of code: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Do these guidelines actually necessitate changing any crates to match the guidelines? |
alexcrichton
added
T-doc
and removed
T-libs
labels
Aug 15, 2016
peschkaj
and others
added some commits
Aug 19, 2016
This comment has been minimized.
This comment has been minimized.
|
I also find it useful when a landing page of the API docs contains links to source code repository and the Right now, for example, it is impossible to discover github repository of the |
This comment has been minimized.
This comment has been minimized.
I also see the value in adding a link to the source repository from the API documentation. This is tangential, but couldn't this be done automatically by retrieving the |
This comment has been minimized.
This comment has been minimized.
|
Ping on this RFC -- what's the status? |
This comment has been minimized.
This comment has been minimized.
aturon
referenced this pull request
Jan 31, 2017
Open
Rust should provide easy access to high quality crates #9
This comment has been minimized.
This comment has been minimized.
|
@aturon - got distracted onto other things. I'll see if I can find the notes on what needed to be revised... |
This comment has been minimized.
This comment has been minimized.
|
@jonathandturner Checking in again on this -- relevant to the libs team work. cc @dtolnay as well. |
dtolnay
added some commits
May 8, 2017
This comment has been minimized.
This comment has been minimized.
|
Hey @jonathandturner, could I get push access to your fork for the duration of this RFC? That way we can keep all the discussion in one PR. |
This comment has been minimized.
This comment has been minimized.
|
@dtolnay - invited! BTW, feel free to pull me into discussions on it. I'm glad someone's taking this and running with it |
dtolnay
added some commits
May 8, 2017
This comment has been minimized.
This comment has been minimized.
|
I have updated the RFC to address the feedback so far and add my own experience. Rendered
|
This comment has been minimized.
This comment has been minimized.
|
So, when talking with the docs team about it, we generally like what's going on here, but we're not entirely sure how to address the unresolved question of what's actually different between a crate's front matter and its README. I'll just add my own experience here. Here's what I put in a README that doesn't necessarily go in the front matter, in addition to the items already listed:
If I were to apply a generalization to these things and the things already listed in the RFC, I might consider "Things that apply solely or primarily to the source code or the layout of the repo belong in the README." The "how to use this" boilerplate would fall under an additional "background knowledge" provision, since I personally would consider that knowledge to be out of scope for the a specific library's documentation. |
This comment has been minimized.
This comment has been minimized.
|
Bump on this -- can we drive to a resolution? |
This comment has been minimized.
This comment has been minimized.
|
I am going to re-read this and related RFCs soon; some of the other ones may change the way this RFC should work, especially things like #1990 |
This comment has been minimized.
This comment has been minimized.
|
I don't think I have bandwidth for this in the next 2 weeks before the impl period. |
This comment has been minimized.
This comment has been minimized.
|
@dtolnay is postponing maybe the right choice then? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp postpone |
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp postpone |
rfcbot
added
the
proposed-final-comment-period
label
Sep 6, 2017
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Sep 6, 2017
•
|
Team member @steveklabnik has proposed to postpone this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This comment has been minimized.
This comment has been minimized.
|
Checking off @jonathandturner since he's not on the team anymore; should update @rfcbot ! |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot reviewed |
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
@rfcbot reviewed |
This comment has been minimized.
This comment has been minimized.
|
I'm going to go ahead and close this out as postponed, since the impl period has started. Thanks all! |
jonathandturner commentedJul 25, 2016
This adds a proposal for the API documentation front page (the front matter you see when you first look at a crate's documentation). This is intended specifically for rust-lang crates, but works as suggested guidelines for any crate authors.