Skip to content
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

API Docs: std::ops #29365

Closed
13 tasks
steveklabnik opened this issue Oct 26, 2015 · 10 comments · Fixed by #43724
Closed
13 tasks

API Docs: std::ops #29365

steveklabnik opened this issue Oct 26, 2015 · 10 comments · Fixed by #43724
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority

Comments

@steveklabnik
Copy link
Member

steveklabnik commented Oct 26, 2015

Part of #29329

http://doc.rust-lang.org/std/ops/

Here's what needs to be done to close out this issue:

  • almost all of the traits suffer from "stuttering", that is, their summary lines should drop "the X trait" and say "the X operator", with the symbol. Don't stutter in operator trait descriptions #40818
  • Range needs a better summary/explanation distinction.
  • RangeFrom has the same issue.
  • RangeFull same
  • RangeTo same
  • All of these range traits could use examples of implementing them to let people pass ranges directly, with examples.
  • Deref is a very important trait with little documentation.
  • DerefMut should link to Deref, and vice versa.
  • Drop is very important yet has little documentation.
  • Fn has a bad summary and a lot of its explanation is inside of the example.
  • FnMut same
  • FnOnce same
  • Some traits only have "prints when called" examples, while others have amazing, real examples. Improving these would be nice but isn't required to close this ticket.
matthew-piziak added a commit to matthew-piziak/rust that referenced this issue Aug 18, 2016
Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.

Part of rust-lang#29365

wrap identifiers in backticks

minor rephrasing

fix module-level documentation to be more truthful

This branch changes the example for `Add` to no longer be a "minimum implementation that prints something to the screen".
matthew-piziak added a commit to matthew-piziak/rust that referenced this issue Aug 18, 2016
Part of rust-lang#29365

explain that std::mem::drop in prelude will invoke Drop

change "prelude" -> "the prelude"; change links to reference-style

move link references to links' section
steveklabnik added a commit to steveklabnik/rust that referenced this issue Aug 18, 2016
…=GuillaumeGomez

replace `Add` example with something more evocative of addition

Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.

Part of rust-lang#29365
steveklabnik added a commit to steveklabnik/rust that referenced this issue Aug 18, 2016
…veklabnik

note that calling drop() explicitly is a compiler error

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 19, 2016
…=GuillaumeGomez

replace `Add` example with something more evocative of addition

Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 19, 2016
…veklabnik

note that calling drop() explicitly is a compiler error

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 19, 2016
…=GuillaumeGomez

replace `Add` example with something more evocative of addition

Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 19, 2016
…veklabnik

note that calling drop() explicitly is a compiler error

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 20, 2016
…=GuillaumeGomez

replace `Add` example with something more evocative of addition

Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 20, 2016
…veklabnik

note that calling drop() explicitly is a compiler error

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 20, 2016
…veklabnik

note that calling drop() explicitly is a compiler error

Part of rust-lang#29365
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 20, 2016
…=GuillaumeGomez

replace `Add` example with something more evocative of addition

Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.

Part of rust-lang#29365
matthew-piziak added a commit to matthew-piziak/rust that referenced this issue Aug 22, 2016
These examples are exactly analogous to those in PRs rust-lang#35709 and rust-lang#35806. I'll probably remove the `fn main` wrappers for `Add` and `Sub` once this is merged in.

Part of rust-lang#29365.

r? @steveklabnik
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 24, 2016
…laumeGomez

more evocative examples for `Sub` and `SubAssign`

These examples are exactly analogous to those in PRs rust-lang#35709 and rust-lang#35806. I'll probably remove the `fn main` wrappers for `Add` and `Sub` once this is merged in.

Part of rust-lang#29365.

r? @steveklabnik
steveklabnik added a commit to steveklabnik/rust that referenced this issue Sep 30, 2016
@steveklabnik steveklabnik added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label Mar 24, 2017
@theotherphil
Copy link
Contributor

theotherphil commented Mar 24, 2017

I'd like to give this a go. Is there a getting started guide to contributing docs changes?

@steveklabnik
Copy link
Member Author

@theotherphil great!

Is there a getting started guide to contributing docs changes?

We have https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#writing-documentation, but I'd like to add more :) For example, https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md is a big list of conventions, though you don't need to really know them well to submit PRs; we'll make sure it follows them in the review.

As far as this specific stuff goes, https://github.com/rust-lang/rust/blob/master/src/libcore/ops.rs is the file you'll want to edit; everything here should be in there.

I'm happy to elaborate with more detail, but that should maybe get you started? 😄

@theotherphil
Copy link
Contributor

Great, thanks.

theotherphil added a commit to theotherphil/rust that referenced this issue Mar 25, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 26, 2017
Don't stutter in operator trait descriptions

Fixes first item on rust-lang#29365.

r? @steveklabnik
alexcrichton added a commit to alexcrichton/rust that referenced this issue Mar 27, 2017
Don't stutter in operator trait descriptions

Fixes first item on rust-lang#29365.

r? @steveklabnik
@terrynsun
Copy link
Contributor

I'd like to help on this too. @theotherphil, which of the sub-issues are you working on/ want to work on?

@theotherphil
Copy link
Contributor

@terrynsun: I've done the first issue and have started to think a little about the next five (i.e. all the RangeX) issues. I've not looked at the others - do you want to do those? (Or split the work any other way?)

@terrynsun
Copy link
Contributor

I can take a shot at Deref/DerefMut/Drop.

@mandeep
Copy link
Contributor

mandeep commented Apr 17, 2017

I'll be working on the last item in the list. Specifically, adding examples of implementing traits with generics.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 14, 2017
…meGomez,frewsxcv

Added generic example of std::ops::Add in doc comments

We discussed on IRC how the std::ops examples were potentially missing examples using generics. This PR adds an example to std::ops::Add that shows the use of a generic type T. I'm not sure this is ready for merge as I think the two examples now make the documentation a bit verbose, but I think it's a good starting point. I'd love to hear others thoughts on this. This is in relation to the last item in issue rust-lang#29365.
bors added a commit that referenced this issue Jul 24, 2017
Add generic example of std::ops::Sub in doc comments

This PR adds an example of using generics with std::ops::Sub and is a follow up of PR #41612 and is related to issue #29365. I also wanted to add examples to Mul and Div, but I think these two traits are already loaded with examples.
@Mark-Simulacrum Mark-Simulacrum added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Jul 24, 2017
@chordowl
Copy link
Contributor

chordowl commented Aug 6, 2017

I'm working on getting as much of this done as I can in the next few days; I've already noticed quite a few examples implement PartialEq manually when they don't have to (distracting from what is supposed to be shown). Additionally, I'll try to incorporate some of the API guidelines into the docs (e.g. that implementations should be unsurprising, that Deref/DerefMut should only be implemented for smart pointers, etc.).

bors added a commit that referenced this issue Aug 12, 2017
Improve std::ops docs

Fixes #29365. (This fixes all but one point from @steveklabnik's list, but that point was referring to examples of implementing range traits, but there are no range traits in std::ops.)

The main changes are quite a bit of copyediting, adding more "real" examples for some of the traits, incorporating some guidance from the API docs, more linking (cross-docs and to the book & reference), cleaning up examples, moving things around, and so on. Refer to the commit messages for more details.

Note: I decided to link to the second edition of the book since I think it's more appropriate now for the sections I linked, if this is not okay, please say so!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants