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

Tracking Issue for intra-doc links in libstd #75080

Closed
jyn514 opened this issue Aug 3, 2020 · 111 comments
Closed

Tracking Issue for intra-doc links in libstd #75080

jyn514 opened this issue Aug 3, 2020 · 111 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Aug 3, 2020

This is a tracking issue for switching libstd to intra-doc links (rust-lang/rfcs#1946, #74430 (comment)).

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also uses as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Mentoring instructions (or rather, suggested workflow)

Please first leave a comment here stating that you want to work on file xxx.rs or module xxx, to make sure that this implements Sync.

  1. For each link of the form
[`Type`]: ../../std/module/kind.Name.html#method.foo

rewrite it as

[`Type`]: std::module::Name::foo

In most cases, the type will already be in scope, in which case you can remove the reference link altogether.
For an example PR, see #74470.

  1. Run x.py doc library/std. This should warn(broken_intra_doc_links) by default.
  2. Fix any warnings that appear.
  3. Once you are ready to make a PR, run ./x.py tidy, which will run rustfmt.

In case of rustdoc bugs, there may be broken links that didn't show up when you ran x.py doc. However, these will be caught by the test suite, so you don't have to check them locally.

Suggested tools

Caveats

Primitives that have the same name as a module in scope must use type@ to disambiguate them. For example, to link to char from std, use type@char. This was changed in #75318, char will now link to the primitive, not the module.

The following cannot use intra-doc links. If you run into an issue with them, it's ok to skip them. However, if you see an issue not mentioned here, please file a bug report!

TODO list

This list was generated with rg '\[.*\]: \.\./.*' library/ -l | sed 's/^/- [ ] /' and may not be complete. If you see other links not mentioned here, feel free to fix them as well.

Since most files only have a few links, it's fine to claim multiple files at the same time.

Unclaimed

In-progress

Completed

Cannot be fixed

The following links cannot yet be fixed due to limitations in rustdoc.

@jyn514 jyn514 added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Aug 3, 2020
@jyn514 jyn514 added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Aug 3, 2020
@denisvasilik
Copy link
Contributor

Hi @jyn514, I would like to work on the following files:

  • library/core/src/time.rs
  • library/core/src/cmp.rs
  • library/core/src/borrow.rs

@Manishearth
Copy link
Member

Go for it!

@RDambrosio016
Copy link
Contributor

Many of these links can be brute force replaced using a regex, for items such as ... ../../std/stuff/something.Item.html it can be brute forced with (\[.*\]: )\.\.\/\.\.\/std\/(\w*)\/(\w*)\.(\w*)\.html[^#], then replacing with $1std::$2::$4\n, many more like method ones can also be knocked out using regex replacement, that regex alone can knock out 384 links. So that might be something worth exploring so less work has to be done with replacing boring links like these

@RDambrosio016
Copy link
Contributor

RDambrosio016 commented Aug 4, 2020

Method links and others (207) can be caught with (\[.*\]: )\.\.\/\.\.\/std\/(\w*)\/(\w*)\.(\w*)\.html#\w+\.(\w*) and replaced with $1std::$2::$4::$5\n, although as pointed out by @jyn514, some of these are broke even if the replacement is correct, so that will have to be checked manually.

@RDambrosio016
Copy link
Contributor

Intrinsics furthermore has a lot (~80) of special ones which match (\[.*\])\(\.\.\/\.\.\/std\/(\w*)\/(\w*)\/\w*\.(\w*)\.\w+\) which can be replaced with $1(std::$2::$3::$4). There is another small use of this but with ../../std/module/stuff which can be matched with (\[.*\])\(\.\.\/\.\.\/std\/(\w*)\/\w*\.(\w*)\.\w+\) and replaced with $1(std::$2::$3)

@Manishearth
Copy link
Member

Go ahead and try the regex approach, if there are conflcits we can try and resolve them.

@RDambrosio016
Copy link
Contributor

I ran all replacements, then ran ./x.py test src/tools/linkchecker library/std, and there were no warnings. So i assume all of them worked correctly, however from my convo with @jyn514 some should not really work because they are fundamentally broken? so i am not quite sure if that is not the case or if testing is not working for me.

@Manishearth
Copy link
Member

I'm not sure which ones you think will be broken.

@jyn514
Copy link
Member Author

jyn514 commented Aug 4, 2020

I'm not sure which ones you think will be broken.

Associated items anywhere other than documenting the associated item itself (#74489)

@jyn514
Copy link
Member Author

jyn514 commented Aug 4, 2020

so i am not quite sure if that is not the case or if testing is not working for me.

You can check by manually introducing a broken link and see if it's caught. If so, the tests are working :) I recommend --keep-stage 0 --keep-stage 1 for that so you don't have to rebuild the compiler (edit: after building the compiler for the first time - you can't keep a stage that hasn't been built!).

@denisvasilik
Copy link
Contributor

Hi @RDambrosio016, could you do that for time.rs cmp.rs and borrow.rs as well? It's great to have a more automated variant.

@RDambrosio016
Copy link
Contributor

RDambrosio016 commented Aug 4, 2020

@denisvasilik not quite sure what you mean by do it for those files, as far as i can see all of the replacements in those files work. I identified another pattern of ../../std/module/index.html, which can be matched with \.\.\/\.\.\/std\/(\w*)\/index\.html and replaced with std::$1, as well as ../../std/primitive.primitive.html (not only primitive but also macro and others) which can be matched with \.\.\/\.\.\/std\/\w*\.(\w*)\.html and replaced with std::$1. i am not aware of any other major patterns, but if you are then please post it here and make a regex replacement, or just post it and i will do it when i have time 👍

@denisvasilik
Copy link
Contributor

I had troubles with files located under library/core. I guess it has something to do with the caveats mentioned above, which states that intra-doc links from core to std are not possible.

@RDambrosio016
Copy link
Contributor

Yeah a fair amount of these replacement may be broken, but the goal of this is to overall reduce the amount of changes needed to be done.

@denisvasilik
Copy link
Contributor

Here's another regex slightly modified to match core and std.
Example matches:

[`Add`]: ../../std/ops/trait.Add.html
[`GlobalAlloc`]: ../../core/alloc/trait.GlobalAlloc.html

Regex: (\[.*\]: )\.\.\/\.\.\/(core|std)\/(\w*)\/(\w*)\.(\w*)\.html[^#]
Replace: $1$2::$3::$5\n

@denisvasilik
Copy link
Contributor

I saw that I cannot reference std in time.rs. For example I tried to do the following replacements:

 [`ops`]: ../../std/ops/index.html
 [`ops`]: std::ops (results in unresolved link)
 [`ops`]: core::ops (results in unresolved link)

If I add use create::ops it works, but I get a warning, because that import is just used for documentation. Is there another way to handle this or should I just leave these kind of links as is?

@jyn514
Copy link
Member Author

jyn514 commented Aug 5, 2020

If I add use create::ops it works, but I get a warning, because that import is just used for documentation. Is there another way to handle this or should I just leave these kind of links as is?

Use crate::ops in the link instead:

 [`ops`]: crate::ops

Intra-doc links follow (almost) exactly the same rules as normal name resolution.

@chansuke
Copy link
Contributor

chansuke commented Aug 6, 2020

Thank you for the detailed explanation. I would like to work on:

  • library/core/src/mem/manually_drop.rs
  • library/core/src/mem/maybe_uninit.rs

@poliorcetics
Copy link
Contributor

I'll take library/std/src/path.rs.

@poliorcetics
Copy link
Contributor

poliorcetics commented Aug 8, 2020

Hello !

I wrote a Python (3.6+, tested with 3.7 and 3.8) script to help with this issue, here is the gist.

By default it will not modify the files you pass it, only showing what it would do. You can find more informations about it in the documentation of the script.

Feel free to use it to speed up the work but be aware it is not perfect and you still review the whole file as well as any changes it makes. It may miss lines or modify some that shouldn't be modified. It is not aware of uses so some modification will make the docs fail to compile but on the whole it should be good enough to help with this tedious task. 😄

The script should preserve indentation perfectly if nothing else so you shouldn't have to rerun x.py fmt <file> 🤞.

I attached an example of the output produced by the script, please check yours is similar before applying its proposed changes:

Screenshot 2020-08-08 at 16 17 50

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2020
…, r=jyn514

Move to intra-doc links in library/std/src/path.rs

Helps with rust-lang#75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

Known issue: The following links are broken (they are inside trait impls, undocumented in this file, inheriting from the original doc):

- [`Hasher`]
- [`Self`] (referencing `../primitive.slice.html`)
- [`Ordering`]
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Sep 21, 2020
…jyn514

Finish moving to intra doc links for std::sync

Helps with rust-lang#75080.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
RalfJung added a commit to RalfJung/rust that referenced this issue Sep 21, 2020
…=jyn514

Use intra-doc links in core/src/iter when possible

Helps with rust-lang#75080.

I also updated lots of links to use `fn()` instead of `fn` when possible.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
RalfJung added a commit to RalfJung/rust that referenced this issue Sep 21, 2020
…jyn514

Finish moving to intra doc links for std::sync

Helps with rust-lang#75080.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
RalfJung added a commit to RalfJung/rust that referenced this issue Sep 21, 2020
…=jyn514

Use intra-doc links in core/src/iter when possible

Helps with rust-lang#75080.

I also updated lots of links to use `fn()` instead of `fn` when possible.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
RalfJung added a commit to RalfJung/rust that referenced this issue Sep 21, 2020
…jyn514

Finish moving to intra doc links for std::sync

Helps with rust-lang#75080.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
@camelid
Copy link
Member

camelid commented Oct 11, 2020

In-progress

What's the status of this?

@jyn514
Copy link
Member Author

jyn514 commented Oct 11, 2020

Blocked on #75809 (well, it's not technically blocked but I don't want to mess with stringify!).

@camelid
Copy link
Member

camelid commented Oct 12, 2020

Links that can't yet be fixed

The following can be fixed or updated to be more specific after the beta release on the 27th (and #74489 is merged):

These can be fixed now! August 27th is long past and #74489 was merged a long time ago as well.

@poliorcetics
Copy link
Contributor

#75701 has been closed for inactivity, can we work on it now or is there another PR for it ?

@jyn514
Copy link
Member Author

jyn514 commented Oct 12, 2020

Sure, if you want to work on it go ahead.

@poliorcetics
Copy link
Contributor

Will do !

@pitaj
Copy link
Contributor

pitaj commented Oct 15, 2020

Are any of the "Unclaimed" things here actually unclaimed?

I can't find anything with [flush]: Write::flush that still uses the old links. Same with [TcpStream::read]: Read::read and [i32::MAX]. [crate::ptr] looks fixed too?

@jyn514
Copy link
Member Author

jyn514 commented Oct 15, 2020

@pitaj yes

It's a little misleading because I said what they should be in some cases, not what they are. But there are still links that need to be fixed.

@pitaj
Copy link
Contributor

pitaj commented Oct 15, 2020

Ah I see! Thanks for clearing that up.

@pitaj
Copy link
Contributor

pitaj commented Oct 16, 2020

I'll claim std::io::buffered and core::intrinsics

JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 6, 2020
Use Intra-doc links for std::io::buffered

Helps with rust-lang#75080. I used the implicit link style for intrinsics, as that was what `minnumf32` and others already had.

`@rustbot` modify labels: T-doc, A-intra-doc-links

r? `@jyn514`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 6, 2020
Use Intra-doc links for std::io::buffered

Helps with rust-lang#75080. I used the implicit link style for intrinsics, as that was what `minnumf32` and others already had.

``@rustbot`` modify labels: T-doc, A-intra-doc-links

r? ``@jyn514``
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 1, 2020
…jyn514

More intra doc links

Helps with rust-lang#75080.

I did a commit by group of file, I can squash if wanted.

`@rustbot` modify labels: T-doc, A-intra-doc-links

r? `@jyn514`
@GroteGnoom
Copy link

GroteGnoom commented Jan 7, 2021

Could [std::convert::identity]: crate::convert::identity be removed from the unclaimed list?

also [TcpStream::read]:
#78006

@jyn514

@poliorcetics
Copy link
Contributor

library/core/src/str/mod.rs has been done in #77875

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 25, 2021
Convert core/num/mod.rs to intra-doc links

Helps with rust-lang#75080.
This can't convert the associated constants `MAX` and `MIN` until rust-lang#74489 is merged.

r? `@poliorcetics`
@sjakobi
Copy link
Contributor

sjakobi commented Mar 27, 2021

Unclaimed

I can't find any old-style links in in library/core/src/ptr. I'm probably misunderstanding the task description though.

(And is whatever remains to be done still E-easy?!)

@jyn514
Copy link
Member Author

jyn514 commented Mar 27, 2021

I think there are few enough links left to convert it's not useful to have a tracking issue for them.

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 A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests