Skip to content

Add - (stdin) support in rustdoc - #124611

Merged
bors merged 3 commits into
rust-lang:masterfrom
Urgau:rustdoc-stdin
May 18, 2024
Merged

bors merged 3 commits into
rust-lang:masterfrom
Urgau:rustdoc-stdin

Conversation

@Urgau

@Urgau Urgau commented May 2, 2024 •

Copy link
Copy Markdown
Member

This PR adds support for the special - input which threats the input as coming from stdin instead of being a filepath.

Doing this also makes rustdoc consistent with rustc and every other tools. Full motivation.

Fixes #123671
r? @fmease

@rustbot rustbot added 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. labels May 2, 2024
@rustbot

ghost commented May 2, 2024

Copy link
Copy Markdown
Collaborator

The run-make-support library was changed

cc @jieyouxu

Some changes occurred in run-make tests.

cc @jieyouxu

@camelid camelid added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label May 2, 2024

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, that's phenomenal! I have some small suggestions and questions.
Looks good overall but ofc, let's wait for the “rmake stdin” PR of yours that you mentioned. After that I'm gonna ping T-rustdoc and ask them for a FCP-merge.

Comment thread tests/run-make/stdin-rustdoc/rmake.rs Resolved
Comment thread src/librustdoc/core.rs Resolved
Comment thread src/librustdoc/config.rs Resolved
Comment thread src/librustdoc/core.rs Resolved
Comment thread tests/run-make/stdin-rustdoc/rmake.rs Resolved
@fmease fmease 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-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2024
@fmease

ghost commented May 3, 2024

Copy link
Copy Markdown
Member

Ofc, technically technically technically speaking this constitutes a breaking change but that's only theoretical in nature. On *nix systems, ppl can name their files -. This PR would break the following:

# Create a file called `-`:
printf 'pub fn omg() {}' > -
# Yes, we've just created a file called `-`.
# On the command-line, run the following to see the output:
< -
# Now document our wonderful crate:
rustdoc - --crate-name dash
# Docs were generated:
"$BROWSER" ./doc/dash/index.html

@Urgau
Urgau force-pushed the rustdoc-stdin branch from 9f75f54 to ee98bf0 Compare May 3, 2024 17:59
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 3, 2024
Comment thread src/librustdoc/config.rs Resolved
Comment thread src/librustdoc/lib.rs Resolved
@fmease

ghost commented May 4, 2024 •

Copy link
Copy Markdown
Member

Hey there @rust-lang/rustdoc, I propose merging this1 after an FCP.

This PR updates rustdoc's CLI to recognize the INPUT argument - (dash) as instructing rustdoc to read the source code from STDIN instead of from a path. Apart from the fact that this is a common CLI convention, it's also consistent with rustc's CLI.

Motivation:

  1. Consistency with rustc's CLI
  2. Doing what is expected from CLI applications
  3. Enabling power users of the rustdoc CLI (i.e., rustdoc & rustc devs)
    • to very quickly check if rustdoc accepts certain source code and/or
    • to rapidly generate docs for small snippets
    • for example during a rustdoc meeting where time is key
    • demo:
      1. $ printf 'pub fn f() -> impl Iterator { 0 }' | rustdoc -
      2. "Oh wow, rustdoc accepts this code..."
      3. "...wait — sanity check — rustc hopefully 🤞 doesn't accept that..."
      4. ↑←←←BSBS a.k.a. $ printf 'pub fn f() -> impl Iterator { 0 }' | rustc -
      5. "Indeed 😌, it doesn't"
      6. "Ah yes, now I remember ... rustdoc doesn't run all of rustc's semantic analysis steps, all good"

Maintenance Cost: Very low (next to zero)
Impact: Low

Potential Concerns:

  1. (negligible) It's technically speaking a breaking change on *nix systems. See my comment above
  2. At least on *nix systems (and by extension in WSL), you can already express this, so this new minor feature “doesn't gain us anything”.
    • E.g., printf 'pub fn f() {}' | rustdoc /dev/stdin (sh)
    • E.g., rustdoc <(printf 'pub fn f() {}') (sh)
    • However,
      • these alternatives are more verbose & obscure and
      • they don't work on Windows (outside of WSL) as far as I'm aware (I'm not a Windows dev, so I don't know the specifics)

Footnotes

  1. Modulo some smaller tweaks to the docs & the impl. See my latest review comments. ↩

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-team and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2024
@Urgau
Urgau force-pushed the rustdoc-stdin branch from ee98bf0 to 7e1dc74 Compare May 4, 2024 15:59
@Manishearth

ghost commented May 4, 2024

Copy link
Copy Markdown
Member

I think we should land this, and I'm surprised this wasn't previously supported

@GuillaumeGomez

ghost commented May 4, 2024

Copy link
Copy Markdown
Member

I'm also surprised it's not already there. Let's start the FCP then.

@rfcbot fcp merge

@rfcbot

ghost commented May 4, 2024 •

Copy link
Copy Markdown

Team member @GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 8, 2024
@rfcbot

ghost commented May 8, 2024

Copy link
Copy Markdown

🔔 This is now entering its final comment period, as per the review above. 🔔

@fmease fmease removed the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label May 12, 2024
@riking

ghost commented May 17, 2024

Copy link
Copy Markdown

re alternatives: If someone is actually putting source code in a file named -, you can still operate on it by making a path relative to the current directory: rustdoc ./- or rustdoc .\-.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 18, 2024
@rfcbot

ghost commented May 18, 2024

Copy link
Copy Markdown

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@GuillaumeGomez

ghost commented May 18, 2024

Copy link
Copy Markdown
Member

Thanks everyone!

@bors r+

@bors

ghost commented May 18, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 7e1dc74 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@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. S-waiting-on-team labels May 18, 2024
@bors

ghost commented May 18, 2024

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 7e1dc74 with merge bb97203...

@bors

ghost commented May 18, 2024

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing bb97203 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 18, 2024
@bors
bors merged commit bb97203 into rust-lang:master May 18, 2024
@rustbot rustbot added this to the 1.80.0 milestone May 18, 2024
@Urgau
Urgau deleted the rustdoc-stdin branch May 18, 2024 13:07
@rust-timer

ghost commented May 18, 2024

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (bb97203): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (primary -4.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.1% [-4.1%, -4.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.1% [-4.1%, -4.1%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 667.741s -> 668.952s (0.18%)
Artifact size: 316.07 MiB -> 316.33 MiB (0.08%)

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label May 24, 2024
@ojeda

ghost commented Jul 25, 2024

Copy link
Copy Markdown
Contributor

Thanks for this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

rustdoc doesn't support reading from STDIN via the fake path - (dash)