-
Notifications
You must be signed in to change notification settings - Fork 498
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
Style, formatting, and policy guide #599
Comments
We should be careful not to go too deep into this. In the case of
We do have a blanket disclaimer noting that parts of the reference is not normative. When there is parts that are undefined / unspecified I think it would be good to call it out explicitly.
I think we should follow latest stable as much as possible and not include version numbers. To do so will become just too messy to maintain. Eventually,
We should strive to let the reference be as independent as possible. If there are known
If they are part of the language definition, then they must be mentioned. Noting their deprecation is also a good idea imo.
Could you give an example?
In my view, the reference should be standalone such that you can remove any mentions to other things at it should still make sense. However, adding "read more" links to other books may make sense in some cases. Also, references referring to various papers and such are not a problem.
In all cases, Wrt. filesystem layout, that one is tricky... We have to be careful not to make whole file systems part of the spec. Not sure what the right answer is here...
Examples? I think it's important to note what information is historical when that happens and avoid having it intrude too much on main flow.
Examples are good but should strive to be complementary as opposed to acting as a source of truth. I think the goal of examples is to demonstrate a particular section of the reference; realistic examples are not necessary... instead, we should use minimalistic examples that carries the point across. Can you elaborate on
Lints are not part of the language definition so yes. Maybe we want to integrate them later into a linting section or denote lint triggers inline; I do think this is something that other Rust compilers would be interested in.
Yeah I think the reference should be agnostic unless compilation actually matters (and if it does then 😢).
Prefer standard academic IEEE style guidelines. CI checking spelling sounds good.
Makes sense 👍
Sure; and always use an Oxford comma.
Never use
Yes, but I believe we typically use "Rust 2018".
👍
Hmm... it may not be necessary for the grammar but I also don't see the harm. This is what I had in mind for typing rules. It is fairly standard practice in type theory and PLT papers to explain a given set of typing rules in prose afterwards. However, the formal specifications (non-prose) should be what is normative in all cases.
Semantic linefeeds or wrapping at 80 characters seems good to me. No wrapping is really hard to review in terms of diffs.
Generally, I find that either below a section or bottom of a file is good. Alphabetized (case-insensitive) sounds good.
This is where I start to wonder whether markdown is a good idea at all... LaTeX would deal with this nicely and is probably also necessary for typing rules.
I personally use
Yes, always.
Sentence case; these sort of stylistic things should be modified globally if need be (again why LaTeX is nice).
👍 |
I have a feeling Github Issues is probably not a good way to process this number of questions.
If the why is interesting or helps the person understand the existence, sure. "Why do struct literals exist" is a bad question to answer. "Why can't we use struct literals as the trailing subexpression in an if statement" is a good one.
Anything explicitly left unspecified should be explicitly called out as unspecified somewhere.
The reference ships with a specific version of
If the bug is a cause of unsound behavior and it won't get fixed soon, definitely. If it's a limitation on what can be written and won't get fixed soon, probably. If it affects people writing real programs, it should be documented.
Like @Centril said, if it's part of the language, it should be documented. We can't "remove" language features, only hide them under edition flags.
Preferably, standalone. The reference isn't for people learning how to use something for the first time. If your first look at e.g. enums, is at the reference, you're at the wrong place. As such, we shouldn't cater to people just learning the language for the first time.
Be explicit when talking about things that are hooked to
Where information is incomplete, linking to more complete documentation can be a temporary workaround. Otherwise, I'd rather not link to all the historical information. Having "The History of Rust" that does this would be a fun read, but having it done half-way inside the reference helps nobody.
Examples are useful for people who just need to see the code to remember something. Realistic examples that don't rely on domain-knowledge of some field (including maths) are nice, but if there's no terse realistic example, an arbitrary example would do better. Length vs. clarity are tradeoffs, but it's hard to give hard advice on it other than with all things being equal, prefer the one that is most clear or shorter.
Yes.
We have a note about this on the crates and source file chapter. If we had a location where we needed to say "compiled or interpreted", I'd rather it just said "compiled". There's no word that means both, right?
American spelling, as much as I'd rather have British.
If somebody set this up, I wouldn't be opposed.
I don't know if this is necessary.
Whichever is more clear should be used.
I'd add parentheticals to that list. More sentences are usually fine, and usually more quotable.
Don't.
This is a question for Rust Marketing™ to answer.
Is this not already done on the introduction page?
No comment here.
Wrap at 80, except link refs.
The current behavior is to re-wrap, even if the PRs are harder to understand.
Right now the sorta-standard is alphabetized, case-sensitive, with links at the bottom. We could do away with the case-sensitive question and make all link refs all-lowercase. All link refs should be at the bottom of the file unless there's a lot of linking in one section that is out-of-the-norm in the kind of links from the rest of the document.
Yes.
The formatting is specified on the introduction page. If something is inconsistent with that, it should be fixed. I'd like to do wiki-template style
I prefer using asterisks, but I don't think it ultimately matters.
Yes.
I just want us to pick one. @Centril gives a good argument for sentence case.
Yes. Don't block a PR on this though. |
See
Code examples marked with
I think I meant this in a different way. Deprecations are usually implemented as lints, which means the reference is now including lints. I definitely think deprecations should be included, I meant that this rule presents an exception to the rules of "don't document lints" and "don't include future functionality" (usually these are worded as "will become a hard error in the future" which I think is fine, but a violation of talking about future functionality). |
Drop it; we don't actually make this recommendation and I think such "how should I write my code"-tips is not interesting for the reference. This is more appropriate for API-guidelines.
This one seems reasonable to keep; as it explains why something that is seemingly redundant otherwise is supported.
I wouldn't have added the caveat about the version... fortunately, the bare trait object style will just become deprecated and so we can note that; in Rust 2021 it might (I hope) become a hard error.
If we take an example such as https://doc.rust-lang.org/nightly/reference/items/traits.html#object-safety, I would make the reference to the RFC either into a proper IEEE style citation or a footnote. These are imo the proper way to have an aside note without impeding main reading flow.
Use the "strictest" mode possible whatever that means. E.g. if you want to ensure compilation failure, then check that it actually fails to compile with
I agree with this. As we beef up the reference I think normal lints can also be included as a non-normative but recommended part of a Rust compiler / interpreter.
Note that C-future-compatibility lints are an exception to the exception; they are |
I think it might be useful to have a guide for style, formatting, and what should and should not be included. If there is, care should be taken to communicate that they are guidelines on how documentation should be written, not necessarily how it must be written, since overly pedantic rules can discourage contribution.
Policy
When should the reference include why something is done in a particular way? Often the reference avoids the "why", but I think it can sometimes provide interesting context.
type_length_limit
explains what it does, but not why it is there. I think it could be useful to say something like:type_length_limit
is used to prevent the compiler from hanging and to better deal with polymorphic recursion.How can reference writers know when something should be intentionally undefined? (Like certain evaluation orders.) Seems like it would be easy to accidentally document some behavior without knowing it shouldn't be specified. Maybe someone in-the-know could call out exactly what should be left undefined, I suspect the list is not very long.
How to deal with rustc version numbers? Is the rustc version number the same as the "The Rust Language" version number? Should the reference actively avoid mentioning version numbers? In general, they could be useful in some situations, but generally are difficult to mark what is changed/added/removed with enough granularity, and to deal with changes over time. (See Should we document when features are stabilized? #60)
Should the reference document actual rust behavior (including bugs)? Or should it document the intended behavior? Or both?
Should the reference mention things that are deprecated?
Should the reference avoid talking about past behavior?
How should overlap with other documentation be handled? Should the reference duplicate everything and be completely standalone? Or can it link to other books?
How should the reference handle
rustc
-specific things? Where does the line get drawn? What is OK to mention? For example, compiler flags? Should it just be opportunistically helpful? For example,extern crate
briefly mentions Cargo's dash-to-underscore rename. Another example: is the filesystem layout part of the language or part of the implementation? What is implementation-specific?What is the policy for linking to historical information, such as RFCs, PRs, GitHub issues, blog posts, etc? These sources are mostly static and not updated, and thus may provide outdated or incorrect information. However, as historical context they are useful.
Should examples be encouraged? Any guidelines for writing examples?
no_run
orignore
.Guidelines for documenting lints. Generally I think they are always avoided, that's what the rustc book is for.
Should the reference be agnostic about whether code is "compiled" or "interpreted"? Should it avoid using the term "compile"?
Style
E
in "2018 Edition" capitalized?=
) followed by an expression".Formatting
-
or*
or anything?Links of interest
The text was updated successfully, but these errors were encountered: