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

General rustdoc improvements #450

Merged
merged 11 commits into from
Jul 22, 2018

Conversation

dekellum
Copy link
Contributor

I started this general branch of rustdoc improvements as part of the effort to document for #339. A description of blocking in the runtime module warrants a summary of the feature and links to greater detail. In particular, 014229f promotes your (@carllerche) recent documentation of tokio-threadpool to rustdoc so I can reference it.

@dekellum
Copy link
Contributor Author

I could use some high level guidance on this. In particular, where as promoting the newest tokio-threadpool crate documentation over the (now hidden, older) tokio::executor::thread_pool docs seems to add value (4076bea...992d4f7), resolving the apparent redundancy in places like with the reactor will require more effort:

Current links:

22:README.md:[reactor]: https://docs.rs/tokio/0.1/tokio/reactor/index.html
1723:src/runtime/current_thread/mod.rs://! [reactor]: ../../reactor/struct.Reactor.html
1906:src/runtime/mod.rs://! [reactor]: ../reactor/struct.Reactor.html

tokio-fs is in a slightly different state:

I suspect moving all the docs to the associated split-out crates with only links from the tokio crate would be best, and the sooner the better, as it would be less confusing to users in current versions, without any code changes. This can be done in advance of deprecating the re-exports in tokio, at least where they are not essential or proving difficult to maintain.

To reiterate, the reason I've wandered down this particular rabbit hole is the desire to summarize on blocking in runtime (#339) by referencing details in tokio-threadpool and tokio-fs.

Thoughts on how to proceed?

@carllerche
Copy link
Member

Thanks! Sorry for the delay. I have been out of town and am still catching up :)

@carllerche
Copy link
Member

I don't think I have a great answer.

The facade strategy means that crates can be used standalone by lib authors, and application authors just depend on tokio and get everything pulled in.

The problem with documentation is that there are now two paths to get to docs depending on your use case. When looking at the sub crate doc, you need to be able to use the library standalone. When coming from the facade, you want to know how everything fits together. This is why the docs are a bit different. When documenting tokio::fs, you want to know how it works combined with tokio::runtime, but not if you go to tokio-fs the crate.

Because tokio::executor::thread_pool was deprecated, I don't expect "application devs" to need to know about the thread pool directly. Instead, they will use tokio::runtime.

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some thoughts inline.

@@ -44,79 +44,10 @@
pub mod current_thread;

#[deprecated(since = "0.1.8", note = "use tokio-threadpool crate instead")]
#[doc(hidden)]
/// Re-exports of [`tokio-threadpool`], deprecated in favor of the crate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why you removed #[doc(hidden)]?

Copy link
Contributor Author

@dekellum dekellum Jul 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed #[doc(hidden)] so that the deprecation tag plus the short note and link I added to tokio-threadpool is visible. As of the last 0.1.7 release there was the full documentation here. Otherwise, on current master (without my change) the module just vanishes from the rustdoc, without even the deprecation tag being visible, which isn't super helpful to anyone currently using that path and wondering how to upgrade.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is the deprecation message would provide the upgrade hint. The pattern in the past is to hide deprecated APIs from docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrespective of conventions, my change improves the rustdoc by showing the deprecation and a link. The deprecation note is still useful/visible when compiling something that uses this path. Also I removed the much larger doc-comment section that would show up without the doc(hidden), so that is also at parity.

If you feel strongly that deprecated re-exports must not be documented (I respectfully disagree), then I can put the #[doc(hidden)] back and remove my new doc-comment and link.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, it can be sorted later.

// thread is able to block. Once it finishes processing the blocking future, the
// thread has no additional work and is inserted into the backup pool. This
// makes it available to other workers that encounter a `blocking` call.
//! A work-stealing based thread pool for executing futures.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation was mostly intended for those who are exploring the source. Do you think it is useful to users of the library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Most importantly, because this is the only place where the two types of threads (worker and backup) are described. These details are essential to gaining sufficient understanding of the blocking strategy.

Toward making these docs more generally useful, maybe the ¶ Crate layout section could be renamed ¶ Implementation notes and moved to the end?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest that the three following sections stay as code comments as I don't see them providing any insight to users:

  • Crate layout
  • Sleeping workers
  • Notifying workers

The other sections are probably fine to include in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One point of potential clarification for backup threads. Is it correct to say that if there is a fully sleeping backup thread at the point where a new worker is needed (blocking called on an existing worker thread), then sleeping backup can be promoted to a new worker? Or is that more a potential future optimization then a current one? It would also be fare if you told me that the rustdoc (-threadpool root) can omit that level of detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I also stated below, I don't think this an essential clarification needed to merge this. Can improve that latter, with a more targetted/ less "general" PR.

pub mod thread_pool {
//! Maintains a pool of threads across which the set of spawned tasks are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this doc can probably be moved to tokio-threadpool/src/lib.rs as the crate leevele docs there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that some (but looking at specifics, not necessarily all) of the original remains useful and could be reused for tokio-threadpool. I will include that in update plan.

@lnicola lnicola mentioned this pull request Jul 6, 2018
3 tasks
@dekellum
Copy link
Contributor Author

dekellum commented Jul 8, 2018

I was out of town for your reply, thanks. I'll reply to specific questions and guidance, and conclude by proposing a set of steps to move this forward.

@dekellum
Copy link
Contributor Author

dekellum commented Jul 8, 2018

Regarding "two paths" and two use cases, would it be a reasonable goal for the tokio crate, façade rustdocs to become more overview ("how [things] fit together") with a link to the specific crate, where the lower-level details may be found? I won't go any further with this here, in this PR, but I will start making those adjustments for tokio-fs (in or after #454 is merged), if that is agreeable.

Proposed plan to move this PR forward:

  • Rebase
  • Reuse useful parts of tokio::executor::thread_pool for tokio-threadpool crate root rustdoc.
  • Preserve but separate and de-emphasize "Implementation notes" aspects of tokio-threadpool crate root rustdoc.

Sound reasonable?

docs.rs is smart enough to show docs for the latest M.N.P release when
M.N is used in the link. For example:

  https://docs.rs/mio/0.6/mio/struct.Poll.html

..will show mio 0.6.14 and later docs. While using the `M.N.*`
(ASTERISK) syntax also works, `M.N` is the more common usage, so
standarize a few existing links to that format.
Some of the previously hidden rustdoc, deleted in:

   30e0034 Replace hidden tokio::executor::thread_pool docs with deprecation note

...is here reused in the tokio-threadpool crate root rustdoc.
...and general improvements and linking.
@dekellum dekellum force-pushed the general-rustdoc-improvements branch from 58498a8 to 311d7cc Compare July 8, 2018 19:13
@dekellum
Copy link
Contributor Author

dekellum commented Jul 8, 2018

I hope so! Rebased, and added the changes as planned.

@dekellum
Copy link
Contributor Author

I'm hoping for feedback on this with us both back in town? Thanks!

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,

I responded to your thoughts. Also, if you could avoid rebasing PRs after an initial review, that would be appreciated. Rebasing makes it harder to tell what exactly changed since last review.

@dekellum
Copy link
Contributor Author

I only rebased because there was a new conflict after the first two weeks, but I will defer to your preference in the future. There is no conflict now, so my (new updated, latest feedback) plan is to hide the three sections you indicate. Sound reasonable?

Per review suggestion by @carllerche on tokio-rs#450, this essentially reverts
the promotion of these low-level detail sections, as done originally
in:

    014229f Promote tokio-threadpool crate level comments to rustdoc

github: cc tokio-rs#421
@dekellum
Copy link
Contributor Author

OK, that one point of potential clarification could be adding in another PR, in any case. How is this as of a0880e0 as far as merge acceptability then?

@dekellum
Copy link
Contributor Author

dekellum commented Jul 11, 2018

Resolved conflicts by a merge from master, instead of rebase, with ad04b61.

@dekellum
Copy link
Contributor Author

All checks pass @carllerche. Are we good here?

@dekellum
Copy link
Contributor Author

Hey @carllerche I thought we were pretty close to resolving this one. Have I done something to offend or done something wrong with the github review UI?

@dekellum
Copy link
Contributor Author

@carllerche, was there something more I was supposed to do on my end with this? Otherwise, can it be merged? I have runtime docs on my TODO list but at lower priority, I hope you understand, if I can't get this merged.

@kpp
Copy link
Contributor

kpp commented Jul 20, 2018

Have I done something to offend

No =) The PR seems good to me but you have to rebase on master to fix conflicts.

@dekellum
Copy link
Contributor Author

OK, merged again.

@carllerche
Copy link
Member

Sorry for the delay (have a new baby). I'll try to take a look asap.

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@carllerche carllerche merged commit 491f158 into tokio-rs:master Jul 22, 2018
@dekellum
Copy link
Contributor Author

Great, thanks (and congrats!)

@dekellum
Copy link
Contributor Author

dekellum commented Aug 4, 2018

Listed as dependency of #437.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants