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

Point to the rustdoc attribute where intralink resolution failed. #51111

Merged

Conversation

kennytm
Copy link
Member

@kennytm kennytm commented May 27, 2018

No description provided.

@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 27, 2018
@rust-highfive

This comment has been minimized.

@kennytm kennytm force-pushed the intralink-resolution-failure-line-numbers branch from b8d411d to 216c0af Compare May 27, 2018 19:24
@GuillaumeGomez
Copy link
Member

Can you add a test for multiple lines please? (I want to be sure it won't give the first line of the doc comment.)

Also, in a second time, it'd be nice to get the span for the link directly instead of its line (but it's just an improvement so not mandatory for this PR).

@kennytm kennytm force-pushed the intralink-resolution-failure-line-numbers branch from 216c0af to 6852c13 Compare May 28, 2018 10:11
@kennytm
Copy link
Member Author

kennytm commented May 28, 2018

@GuillaumeGomez Done. It now selects the entire documentation block.

Unfortunately, I don't think it is possible to get the span of the link directly, because such information is not passed into pulldown-cmark (the whole interface only deals with &strs).

Even we can compute the pointer offset of the &str relative to the whole markdown snippet, the generated span is still wrong because we removed those /// and //! inside collapsed_doc_value().

@GuillaumeGomez
Copy link
Member

What I meant was for example:

/// a [link]
///
/// [blabla]

To give:

warning: [link] cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:1:1
  |
1 |  /// a [link]

warning: [blabla] cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:3:1
  |
3 |  /// [blabla]

@kennytm
Copy link
Member Author

kennytm commented May 29, 2018

@GuillaumeGomez That's not possible either because collapsed_doc_value() (which returns a String) erased all information which doc_string the invalid link was found.

@GuillaumeGomez
Copy link
Member

Hum :-/

@shepmaster
Copy link
Member

Ping from triage, @GuillaumeGomez !

@GuillaumeGomez
Copy link
Member

I wonder what we should do in here... Maybe just print the line where the link is and the line where the doc comment started? As is, it's not really useful (still better than what we have but not complete enough). Do you think you can do this?

@kennytm kennytm force-pushed the intralink-resolution-failure-line-numbers branch from 6852c13 to 2886aca Compare June 3, 2018 10:25
@kennytm
Copy link
Member Author

kennytm commented Jun 3, 2018

@GuillaumeGomez The output now looks like this:


warning: [Uniooon::X] cannot be resolved, ignoring it...
  --> $DIR/intra-links-warning.rs:13:1
   |
13 | / //! Test with [Foo::baz], [Bar::foo], ...
14 | | //!
15 | | //! and [Uniooon::X].
   | |_____________________^
   |
   = note: the link appears in this line:
           
            and [Uniooon::X].
                 ^^^^^^^^^^ 

@GuillaumeGomez
Copy link
Member

Let's go for this version then. Thanks a lot!

@bors: r+

@bors
Copy link
Contributor

bors commented Jun 3, 2018

📌 Commit 2886aca has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 3, 2018
@bors
Copy link
Contributor

bors commented Jun 3, 2018

⌛ Testing commit 2886aca with merge 01a9b30...

bors added a commit that referenced this pull request Jun 3, 2018
…ers, r=GuillaumeGomez

Point to the rustdoc attribute where intralink resolution failed.
@bors
Copy link
Contributor

bors commented Jun 4, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: GuillaumeGomez
Pushing 01a9b30 to master...

@bors bors merged commit 2886aca into rust-lang:master Jun 4, 2018
@kennytm kennytm deleted the intralink-resolution-failure-line-numbers branch June 4, 2018 06:24
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 8, 2018
Use spans pointing at the inside of a rustdoc attribute

Follow up to rust-lang#51111.

Point to the link in a rustdoc attribute where intralink resolution failed, instead of the full rustdoc attribute's span.

r? @GuillaumeGomez cc @kennytm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants