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 upDevelop doc-comment style guide #4361
Comments
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
For comparison, standard Python style is to use the imperative "Return the …", which I find works well: http://www.python.org/dev/peps/pep-0257/#one-line-docstrings |
This comment has been minimized.
This comment has been minimized.
kud1ing
commented
Jan 6, 2013
|
Go has settled on the non-imperative style: http://golang.org/pkg/ |
This comment has been minimized.
This comment has been minimized.
|
Visiting for triage. Personally, I prefer imperative verbs, and a period at the end. As for doc comment style, I don't think we should enforce any particular way over another, at least not while the language defines multiple ways to do it. Also, my preferred way is
|
This comment has been minimized.
This comment has been minimized.
|
I also prefer the imperative. Style also needs to include a unified syntax for refering to types and arguments, so |
This comment has been minimized.
This comment has been minimized.
|
Visiting for triage. I have very little opinion about this. |
Armavica
referenced this issue
Jan 28, 2014
Closed
Grammatical inconsistencies in the documentation #11830
This comment has been minimized.
This comment has been minimized.
kud1ing
commented
Jan 28, 2014
|
Descriptive style:
Imperative style:
|
This comment has been minimized.
This comment has been minimized.
kud1ing
commented
Jan 28, 2014
|
I prefer the descriptive versions myself because a method definition does not do anything until i tell it to:
|
This comment has been minimized.
This comment has been minimized.
|
I am sensible to kud1ing's argument. Furthermore, if you read aloud a line the way it is presented in the doc:
then the declarative form makes it a real sentence |
This comment has been minimized.
This comment has been minimized.
kud1ing
commented
Jan 28, 2014
|
@Armavica: Which is actually a short form of Documentating and interface is presenting something to the audience. I think the imperative form makes more sense, when you explain what/how/why something is happening in the implementation. |
This comment has been minimized.
This comment has been minimized.
|
There's also #9403 about the style of the examples in documentation. |
This comment has been minimized.
This comment has been minimized.
|
P-low. |
pnkfelix
added
P-low
and removed
P-high-untriaged
labels
Feb 6, 2014
huonw
referenced this issue
Mar 13, 2014
Closed
Style guide for links/references/citations in docs #12862
This comment has been minimized.
This comment has been minimized.
|
cc #12928 |
This comment has been minimized.
This comment has been minimized.
|
From the comments here, descriptive style (e.g., "Converts a byte to a string.") seems more popular than imperative style ("Convert a byte to a string."). I don't much care which way we go, but it would be nice to have an official decision on this. |
lilyball
referenced this issue
Jun 30, 2014
Closed
std::os - Add join_paths, make setenv non-utf8 capable #15280
This comment has been minimized.
This comment has been minimized.
|
I think that calling this the imperative style is wrong. It's not imperative, because it's not instructing anyone to do anything. I think it's the first-person present indicative. I suspect that the urge to write /// Frob the twaddle.
fn frob() {}stems from the mindset of "I am the function. What do I do?", so it's the first-person present indicative. However, when reading documentation, most readers will naturally treat the function as a third-person singular subject instead of a first-person subject. To that end, the documentation should be written in the third-person singular instead of the first-person. The only reasonable argument I can see for considering this to be the imperative rather than the first-person present indicative is when the docstring describes a function declaration that the user is expected to implement. This is very common in OO languages, but in Rust that only applies to trait methods. This case suggests the use of the imperative because it's telling you what you must do in order to implement the method correctly. But I don't consider this argument to be persuasive. The primary use-case for documentation is telling the reader how to use the API, not how to implement it. The number of uses of an API vastly outstrips the number of implementations (in all but the most esoteric of cases). Therefore, I believe that it makes more sense to use the present indicative in the third-person singular than it does to use the imperative, even for trait methods. |
This comment has been minimized.
This comment has been minimized.
|
Another thing to deal with: hypens or en dashes: https://en.wikipedia.org/wiki/Dash#Relationships_and_connections
|
bors
added a commit
that referenced
this issue
Aug 19, 2014
thestinger
removed
the
I-completion
label
Sep 16, 2014
This comment has been minimized.
This comment has been minimized.
|
I have submitted an RFC: rust-lang/rfcs#505 |
ghost commentedJan 5, 2013
With a lot of library code expected to change before the 1.0 release, it doesn't make much sense to do this now, but the core and std libraries should use a consistent style for API documentation. The wiki makes some attempt at specifying conventions, but these need to be fleshed out and actually applied to the codebase.
Right now, some doc-comments are written in the third-person indicative:
and some are written in the imperative:
These two examples illustrate another inconsistency: Some summaries (the first line of the comment) have no terminal punctuation, while others end with a period.
One more thing that varies is the comment style itself. Some doc-comments look like
while others look like
Once these rules (and others) are codified, I'd be happy to start going through the doc-comments and updating them.