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

intra-doc links: Links with unexpected characters are silently ignored #77199

Closed
dylni opened this issue Sep 25, 2020 · 17 comments
Closed

intra-doc links: Links with unexpected characters are silently ignored #77199

dylni opened this issue Sep 25, 2020 · 17 comments
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name I-needs-decision Issue: In need of a decision. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@dylni
Copy link
Contributor

dylni commented Sep 25, 2020

Intra-doc links with unexpected characters are ignored here:

if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ch == ':' || ch == '_')) {
return;
}

However, it would be better if they caused a warning with --display-doctest-warnings. Developers might expect [`&[String]`] to link to the slice primitive, but that link would be ignored without a warning.

cc @jyn514
cc #76106 (comment)

@dylni dylni added the C-bug Category: This is a bug. label Sep 25, 2020
@jyn514 jyn514 added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-needs-decision Issue: In need of a decision. and removed C-bug Category: This is a bug. labels Sep 25, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue Mar 2, 2021
Update intra-doc link documentation to match the implementation

r? `@Manishearth`
cc `@camelid` `@m-ou-se`

Relevant PRs:
- rust-lang#74489
- rust-lang#80181
- rust-lang#76078
- rust-lang#77519
- rust-lang#73101

Relevant issues:
- rust-lang#78800
- rust-lang#77200
- rust-lang#77199 / rust-lang#54191

I haven't documented things that I consider 'just bugs', like rust-lang#77732, but I have documented features that aren't implemented, like rust-lang#78800.
@camelid
Copy link
Member

camelid commented Oct 22, 2021

FWIW, I think this is less of an issue now, since more characters are allowed in intra-doc links, and thus not ignored. Also, IIRC --display-warnings has now been renamed to --display-doctest-warnings, so that flag shouldn't be used here. Maybe we could add another lint or something? But like I said, it's less of an issue now.

@dylni dylni changed the title intra-doc links: --display-warnings ignores links with unexpected characters intra-doc links: --display-doctest-warnings ignores links with unexpected characters Nov 29, 2021
@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

@camelid Thanks, I updated the option name. However, I am still not seeing a warning for [`&[String]`], which was my primary concern. It would be ideal if bracketed text could either be properly linked or give a warning in all cases.

@camelid camelid changed the title intra-doc links: --display-doctest-warnings ignores links with unexpected characters intra-doc links: Don't silently ignore links with unexpected characters Nov 29, 2021
@camelid
Copy link
Member

camelid commented Nov 29, 2021

I've changed the title since --display-doctest-warnings is being removed and is not the right way to expose this anyway.

@camelid camelid changed the title intra-doc links: Don't silently ignore links with unexpected characters intra-doc links: Links with unexpected characters are silently ignored Nov 29, 2021
@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

That's great. Enabling the warnings by default is much better.

@camelid
Copy link
Member

camelid commented Nov 29, 2021

That's great. Enabling the warnings by default is much better.

I see the advantage of enabling them by default, but rustdoc intentionally silently ignores some links to avoid tons of lints being emitted for existing docs.

@jyn514
Copy link
Member

jyn514 commented Nov 29, 2021

This is a duplicate of #54191.

@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

rustdoc intentionally silently ignores some links

Is there a plan to allow requesting stricter behavior when --display-doctest-warnings is removed? I read through #73314, but there seems to be some confusion about the many purposes the option serves, which I assume is why it's being removed.

@jyn514
Copy link
Member

jyn514 commented Nov 29, 2021

@dylni what do you mean by stricter behavior? If you mean what's in this issue, I don't think it's a good idea for rustdoc to decide whether to resolve a link based on an option; it already does that for --document-private-items and it's pretty confusing IMO. If you mean something else, please open a new issue; I'm ok with adding additional lints but I'm not a fan of additional configuration.

@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

@jyn514 camelid mentioned

--display-doctest-warnings is being removed and is not the right way to expose this anyway.

I was wondering if there was a particular replacement planned for the option. In the past, it enabled warnings when intra-doc links failed to resolve, but that part seems to be enabled by default now. I was wondering if there's any additional strictness/warnings that would be lost by removing the option.

I don't think it's a good idea for rustdoc to decide whether to resolve a link based on an option

I agree. It doesn't matter to me if these links are resolved or fail. I would just prefer a warning when they're unresolved.

@camelid
Copy link
Member

camelid commented Nov 29, 2021

I was wondering if there was a particular replacement planned for the option. In the past, it enabled warnings when intra-doc links failed to resolve, but that part seems to be enabled by default now. I was wondering if there's any additional strictness/warnings that would be lost by removing the option.

Hmm, I didn't realize the flag used to enable intra-doc warnings. My understanding was that it was always used to show warnings in doctests (i.e., ``` code examples).

@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

Hmm, I didn't realize the flag used to enable intra-doc warnings.

That was the only reason I mentioned it in this issue. IIRC, at the time this issue was created, not using --display-warnings caused no warnings to be displayed for all broken intra-doc links.

@jyn514
Copy link
Member

jyn514 commented Nov 29, 2021

IIRC, at the time this issue was created, not using --display-warnings caused no warnings to be displayed for all broken intra-doc links.

That can't be correct. I started working on intra-doc links about 2 months before you opened the issue and they still gave warnings at that time; AFAIK they've never been behind any sort of feature gate other than originally only being available on nightly.

@jyn514
Copy link
Member

jyn514 commented Nov 29, 2021

Anyway, I think this is a distraction. CLI options seem like the wrong model for this and I don't think we should add more; this should be a new lint if we add it at all.

@jyn514
Copy link
Member

jyn514 commented Nov 29, 2021

I'm going to close this in favor of #54191.

@jyn514 jyn514 closed this as completed Nov 29, 2021
@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

AFAIK they've never been behind any sort of feature gate.

It's entirely possible this is correct, and you would know better than I. That is just what I recall.

Anyway, I think this is a distraction.

Right, this got a little off-topic.

I'm going to close this in favor of #54191.

Thanks for pointing out that issue!

@camelid
Copy link
Member

camelid commented Nov 29, 2021

@dylni Perhaps you were thinking of --deny warnings?

@dylni
Copy link
Contributor Author

dylni commented Nov 29, 2021

@camelid After investigating a bit, I think I may have falsely attributed the option with showing intra-doc warnings in addition to doctest warnings. Cached compilation not re-issuing warnings was likely what I was seeing instead. Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name I-needs-decision Issue: In need of a decision. 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

4 participants