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

Add --no-source option flag to rustdoc #75522

Closed
wants to merge 3 commits into from

Conversation

GuillaumeGomez
Copy link
Member

Fixes #75497.

A question though: should we go through an unstable phase or not considering the attribute is already stable?

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(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 Aug 14, 2020
@GuillaumeGomez
Copy link
Member Author

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned steveklabnik Aug 14, 2020
@jyn514
Copy link
Member

jyn514 commented Aug 14, 2020

Looks reasonable to me. I don't have a strong opinion on whether this should be insta-stable, but since it's just exposing an option that already exists through the command line I don't see why not.

@GuillaumeGomez
Copy link
Member Author

Forgot to write it down but if we go stable: I'll also need to add the related documentation too.

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. C-feature-accepted Category: A feature request that has been accepted pending implementation. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2020
@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 4, 2020
@GuillaumeGomez
Copy link
Member Author

Added the documentation.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

r=me after nits are fixed

src/doc/rustdoc/src/command-line-arguments.md Outdated Show resolved Hide resolved
src/doc/rustdoc/src/command-line-arguments.md Outdated Show resolved Hide resolved
src/librustdoc/config.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

@bors: r=jyn514

@bors
Copy link
Contributor

bors commented Sep 21, 2020

📌 Commit a867bd9a5389caa854103fd20221e2de354eaaa8 has been approved by jyn514

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 21, 2020
@ollie27
Copy link
Member

ollie27 commented Sep 21, 2020

@bors r-

New features require at least an FCP.

An issue with --no-source is that there is no way for rustdoc to know if a dependency has been documented with that flag so [src] links to that depedency would be broken. With the crate level attribute rustdoc can avoid generating broken [src] links to dependencies. Admittedly rustdoc doesn't yet do that but it could and should: #55957.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 21, 2020
@GuillaumeGomez
Copy link
Member Author

It's not a new feature, that's why I asked if it required to go through an unstable phase since it's only providing a command-line flag for an already stable attribute. So this is a different issue in my opinion: this PR is about adding a command-line flag for a stable attribute. If the attribute itself has issues, then it should be fixed in another PR. What do you think @ollie27 ?

@jyn514 jyn514 added needs-fcp This change is insta-stable, so needs a completed FCP to proceed. and removed C-feature-accepted Category: A feature request that has been accepted pending implementation. labels Sep 21, 2020
@crlf0710
Copy link
Member

crlf0710 commented Oct 8, 2020

Triage: What's the status here?

@crlf0710 crlf0710 added the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Oct 8, 2020
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 15, 2021
@GuillaumeGomez
Copy link
Member Author

ping @ollie27

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2021
src/doc/rustdoc/src/command-line-arguments.md Outdated Show resolved Hide resolved
src/librustdoc/config.rs Outdated Show resolved Hide resolved
src/test/rustdoc/html_source.rs Show resolved Hide resolved
src/doc/rustdoc/src/command-line-arguments.md Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

Fixed conflicts and fixed issues reported by @camelid !

@bors
Copy link
Contributor

bors commented Apr 2, 2021

☔ The latest upstream changes (presumably #83790) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@ollie27
Copy link
Member

ollie27 commented Apr 4, 2021

To be honest I'm not sure what do here.

As mentioned in #75497 (comment) you can already get the effect of --no-source using feature flags so I'm not convinced that we need a dedicated option for this.

The guidelines for command-line arguments in rustc explicitly recommend not using the no- prefix.

As well as not rendering source files for the current crate, #![doc(html_no_source)] (and --no-source as it's currently proposed) also prevent [src] links from being generated for items defined in external crates. I don't know if that's an intentional effect or not but it's not documented. I would expect rustdoc to only not generate [src] links to an external crate if that crate has #![doc(html_no_source)].

It's not a new feature

As far as I'm concerned, a new command line argument is a new feature no matter how simple it may appear so I would expect to see at least an FCP for it.

If the attribute itself has issues, then it should be fixed in another PR.

The attribute can be fixed but the command line argument can't. rustdoc will have no way of knowing if an external crate has been documented with --no-source or not so will either generate broken [src] links or none when it should. An option might be an argument like --extern-no-source to specify which external crates have been documented with --no-source along with some kind of integration with cargo. Are there plans for something like that?

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 23, 2021
@bors
Copy link
Contributor

bors commented May 1, 2021

☔ The latest upstream changes (presumably #83857) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez
Copy link
Member Author

As well as not rendering source files for the current crate, #![doc(html_no_source)] (and --no-source as it's currently proposed) also prevent [src] links from being generated for items defined in external crates. I don't know if that's an intentional effect or not but it's not documented. I would expect rustdoc to only not generate [src] links to an external crate if that crate has #![doc(html_no_source)].

I'm pretty sure we never generate [src] links to external crates, and I think we shouldn't. The only thing we should do is link to external items documentation page.

As far as I'm concerned, a new command line argument is a new feature no matter how simple it may appear so I would expect to see at least an FCP for it.

That's fair. Also, we should maybe go through a period of "nightly only" and then propose to stabilize it. So here what I suggest: I make this unstable for the time being, and open another PR to stabilize it with an FCP. What do you think?

The attribute can be fixed but the command line argument can't. rustdoc will have no way of knowing if an external crate has been documented with --no-source or not so will either generate broken [src] links or none when it should. An option might be an argument like --extern-no-source to specify which external crates have been documented with --no-source along with some kind of integration with cargo. Are there plans for something like that?

I'm not sure to understand your concern over this: we can already use an external URL to say where the external crate is supposed to be and we have no idea if it has been generated with source code or not. Also, like said above, we don't generate [src] links to external items' source and I think we should only link to external items' documentation.

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 11, 2021
@jyn514
Copy link
Member

jyn514 commented Jun 11, 2021

we have no idea if it has been generated with source code or not

I think Ollie's point is that, for the attribute, we can tell when the crate will never have docs and stop generating links to it. If someone passes --extern-html-root-url they're guaranteeing that the URL does in fact have docs at it, it's not rustdoc's responsibility.

I don't have a strong opinion on this either way, but given that there are already a ton of ways to replicate this already (e.g. --crate-attr html_no_source), are you sure there needs to be a dedicated flag? Most attributes aren't duplicated in flags.

@GuillaumeGomez
Copy link
Member Author

we have no idea if it has been generated with source code or not

I think Ollie's point is that, for the attribute, we can tell when the crate will never have docs and stop generating links to it. If someone passes --extern-html-root-url they're guaranteeing that the URL does in fact have docs at it, it's not rustdoc's responsibility.

That argument doesn't work since, like you said, we can reach the same result using -crate-attr html_no_source.

I don't have a strong opinion on this either way, but given that there are already a ton of ways to replicate this already (e.g. --crate-attr html_no_source), are you sure there needs to be a dedicated flag? Most attributes aren't duplicated in flags.

This is mostly for convenience, it's easier to use an explicit argument rather than going through attributes. I'd personally prefer to add this option (obviously) but I'll let it up to the team for the final decision.

@jyn514
Copy link
Member

jyn514 commented Jun 11, 2021

That argument doesn't work since, like you said, we can reach the same result using -crate-attr html_no_source.

No, like Ollie said earlier, rustdoc should stop generating links to source when it knows they won't exist: #55957

I'm not sure who "the team" is (do you want to ping more people?) but given all the discussion here I'd prefer not to add this, rustdoc has a ton of knobs already and this one doesn't seem particularly useful.

@GuillaumeGomez
Copy link
Member Author

By the team I meant ours. 😉

And fine by me! Let's close this then. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to exclude source code from docs
9 participants