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

Rustdoc: JSON backend experimental impl, with new tests. #79539

Merged
merged 5 commits into from
Dec 3, 2020

Conversation

aDotInTheVoid
Copy link
Member

@aDotInTheVoid aDotInTheVoid commented Nov 29, 2020

Based on #75114 by @P1n3appl3

The first commit is all of #75114, but squased to 1 commit, as that was much easier to rebase onto master.

The git history is a mess, but I think I'll edit it after review, so it's obvious whats new.

Still to do

  • Update docs.
  • Add bless option to tests.
  • Add test option for multiple files in same crate.
  • Decide if the tests should check for json to be equal or subset.
  • Go through the rest of the review for the original pr. (This is open because the test system is done(ish), but stuff like not using a hashmap and using CRATE_DEF_INDEX hasn't)

I'm also sure how many of these we need to do before landing on nightly, as it would be nice to get this in tree, so it isn't effected by churn like #79125, #79041, #79061

r? @jyn514

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 29, 2020
@aDotInTheVoid aDotInTheVoid marked this pull request as draft November 29, 2020 21:23
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 30, 2020
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.

I'm also sure how many of these we need to do before landing on nightly, as it would be nice to get this in tree, so it isn't effected by churn like #79125, #79041, #79061

Most of it can wait until later I think (although it should be done before stabilization). The things I'd consider blockers are:

  • Fixing the test suite, which currently does nothing. This should be as simple as reverting a66a97a. I see you already did, thank you! ❤️
  • Anything changing rustdoc's normal behavior, such as https://github.com/rust-lang/rust/pull/75114/files/a66a97ac588f26350cab886904ddbe70ce17d339#r519470764. It doesn't necessarily have to be reverted, but if not there should be an explanation for why it changed. I understand you're not the one who changed it and it makes things more difficult - maybe revert it, run the tests, and see what breaks?
  • Stripped items should not be included by default: JSON backend experimental impl #75114 (comment). This is totally against the stability guarantees of rust - the behavior around --document-private-items is a little unclear and we can have that discussion before stabilization, but including private items by default seems very wrong to me.

Other than that, I think this has been in limbo long enough and should get merged ASAP.

cc @tmandry, all is not lost 😆

src/tools/compiletest/src/runtest.rs Outdated Show resolved Hide resolved
Comment on lines 42 to 46
if expected_type == str and actual.startswith(base_dir):
if actual.replace(base_dir + "/", "") != expected:
raise SubsetException(
"expected `{}`, got: `{}`".format(
expected, actual.replace(base_dir + "/", "")
Copy link
Member

Choose a reason for hiding this comment

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

What is this doing?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a hack to get around the real output being "filename": "/home/nixon/upstreams/rust/rust/src/test/rustdoc-json/structs.rs", but the test is "filename": "structs.rs",.

Long term, it's probably usefull to do something like $TEST_BUILD_DIR, like the ui tests have.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, can you leave those examples as a comment in the source? Feel free to change the absolute path to something else as long as it's still clear it's absolute and not relative.

@jyn514 jyn514 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 Nov 30, 2020
@aDotInTheVoid
Copy link
Member Author

Anything changing rustdoc's normal behavior, such as https://github.com/rust-lang/rust/pull/75114/files/a66a97ac588f26350cab886904ddbe70ce17d339#r519470764. It doesn't necessarily have to be reverted, but if not there should be an explanation for why it changed. I understand you're not the one who changed it and it makes things more difficult - maybe revert it, run the tests, and see what breaks?

Reverting it seems fine, so I've done that.

Stripped items should not be included by default: #75114 (comment). This is totally against the stability guarantees of rust - the behavior around --document-private-items is a little unclear and we can have that discussion before stabilization, but including private items by default seems very wrong to me.

Done

@aDotInTheVoid aDotInTheVoid marked this pull request as ready for review November 30, 2020 22:24
@aDotInTheVoid
Copy link
Member Author

@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review

What do you want done with the git history

@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 Nov 30, 2020
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.

What do you want done with the git history

It's such a mess by now I don't know if it's worth messing with more 😅 up to you if you want to squash or not.

This looks way better than before :) thanks so much for taking this on! I'm really excited to see what people will build with this.

src/librustdoc/json/conversions.rs Outdated Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Nov 30, 2020

r=me unless @GuillaumeGomez or @tmandry want to take a look - I have more things I'd like to change, but I'd much rather get this on nightly so it's not stuck in limbo.

@jyn514 jyn514 added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 30, 2020
@GuillaumeGomez
Copy link
Member

Looks good to me as well, thanks a lot!

@bors: r=jyn514,GuillaumeGomez

@bors
Copy link
Contributor

bors commented Dec 1, 2020

📌 Commit 97011eb has been approved by jyn514,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-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Dec 1, 2020
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Dec 1, 2020
…illaumeGomez

Rustdoc: JSON backend experimental impl, with new tests.

Based on rust-lang#75114 by `@P1n3appl3`

The first commit is all of rust-lang#75114, but squased to 1 commit, as that was much easier to rebase onto master.

The git history is a mess, but I think I'll edit it after review, so it's obvious whats new.

## Still to do

- [ ] Update docs.
- [ ] Add bless option to tests.
- [ ] Add test option for multiple files in same crate.
- [ ] Decide if the tests should check for json to be equal or subset.
- [ ] Go through the rest of the review for the original pr. (This is open because the test system is done(ish), but stuff like [not using a hashmap](rust-lang#75114 (comment)) and [using `CRATE_DEF_INDEX` ](rust-lang#75114 (comment)) hasn't)

I'm also sure how many of these we need to do before landing on nightly, as it would be nice to get this in tree, so it isn't effected by churn like rust-lang#79125, rust-lang#79041, rust-lang#79061

r? `@jyn514`
P1n3appl3 and others added 3 commits December 1, 2020 18:34
Respond to comments and start adding tests

Fix re-exports and extern-crate

Add expected output tests

Add restricted paths

Format

Fix: associated methods missing in output

Ignore stripped items

Mark stripped items

removing them creates dangling references

Fix tests and update conversions

Don't panic if JSON backend fails to create a file

Fix attribute error in JSON testsuite

Move rustdoc-json to rustdoc/

This way it doesn't have to build rustc twice. Eventually it should
probably get its own suite, like rustdoc-js, but that can be fixed in a
follow-up.

Small cleanups

Don't prettify json before printing

This fully halves the size of the emitted JSON.

Add comments

[BREAKING CHANGE] rename version -> crate_version

[BREAKING CHANGE] rename source -> span

Use exhaustive matches

Don't qualify imports for DefId

Rename clean::{ItemEnum -> ItemKind}, clean::Item::{inner -> kind}

Fix Visibility conversion

clean::Visability was changed here:
https://github.com/rust-lang/rust/pull/77820/files#diff-df9f90aae0b7769e1eb6ea6f1d73c1c3f649e1ac48a20e169662a8930eb427beL1467-R1509

More churn catchup

Format
Move rustdoc/rustdoc-json to rustdoc-json

Scaffold rustdoc-json test mode

Implement run_rustdoc_json_test

Fix up python

Make tidy happy
Go back to CRATE_DEF_INDEX

Minor niceness improvements

Don't output hidden items

Remove striped items from fields

Add $TEST_BASE_DIR

Small catch
@jyn514
Copy link
Member

jyn514 commented Dec 1, 2020

@bors r=jyn514,GuillaumeGomez

@bors
Copy link
Contributor

bors commented Dec 1, 2020

📌 Commit 6018200 has been approved by jyn514,GuillaumeGomez

@bors
Copy link
Contributor

bors commented Dec 2, 2020

⌛ Testing commit 6018200 with merge 86c4e2f69b2692667f369170cb8a34a740ef16c9...

@bors
Copy link
Contributor

bors commented Dec 2, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 2, 2020
@aDotInTheVoid
Copy link
Member Author

Windows path separator problem.

__main__.SubsetException: ['source', 'filename']: expected `$TEST_BASE_DIR/structs.rs`, got: `$TEST_BASE_DIR\structs.rs`

@jyn514 jyn514 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 Dec 2, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 2, 2020

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Dec 2, 2020

📌 Commit 824d5ce57320cc4c1a5d0a343e44650211e7cd12 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 Dec 2, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 2, 2020

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Dec 2, 2020

📌 Commit d619271 has been approved by jyn514

@bors
Copy link
Contributor

bors commented Dec 2, 2020

⌛ Testing commit d619271 with merge 7dc1e85...

@bors
Copy link
Contributor

bors commented Dec 3, 2020

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing 7dc1e85 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 3, 2020
@bors bors merged commit 7dc1e85 into rust-lang:master Dec 3, 2020
@rustbot rustbot added this to the 1.50.0 milestone Dec 3, 2020
@aDotInTheVoid aDotInTheVoid deleted the json-mvp branch January 6, 2021 12:27
@aDotInTheVoid
Copy link
Member Author

@rustbot modify labels +A-rustdoc-json

@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend 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.

8 participants