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

Split doc.rs up into a subdirectory #11801

Merged
merged 1 commit into from
Nov 20, 2023
Merged

Conversation

y21
Copy link
Member

@y21 y21 commented Nov 13, 2023

So, first, sorry for the bad diff. 😅

In #11798, @flip1995 suggested splitting doc.rs up, much like how we have the methods/, matches/, types/ subdirectories.
I agree with this, the file is getting bigger as we add more and more doc lints that it makes sense to do this refactoring.

This is purely an internal change that moves things around a bit.
(EDIT: depending on the outcome of #11801 (comment) , this may change the lint group name from doc_markdoc to doc).

I tried to not change any of the actual logic of the lints and as such some things weren't as easy to move to a separate file. So we still have some span_lint* calls in the doc/mod.rs file, which I think is fine. This is also the case in methods/mod.rs.

Also worth mentioning that the lints missing_errors_doc, missing_panics_doc, missing_safety_doc and unnecessary_safety_doc have a lot of the same logic so it didn't make much sense for each of these to be in their own file. Instead I just put them all in missing_headers.rs

I also added a bit of documentation to the involved check_{attrs,doc} methods.

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Nov 13, 2023

r? @blyxyas

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 13, 2023
}
}

fn collect_doc_replacements(attrs: &[Attribute]) -> Vec<(Span, String)> {
Copy link
Member Author

Choose a reason for hiding this comment

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

The code in here was previously in the same function where we emit the lint but I extracted that into a separate function because I thought that looks better. If you disagree, I can change it back to have it all in the same function.

Copy link
Member

Choose a reason for hiding this comment

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

I don't disagree, but if we're not just moving some functions into other files, you could also refactor this commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

With this lint specifically I'm more familiar since I wrote it myself, and, actually that's how it looked like before my PR #11798 where I put them into one to save space since the file was getting large.
Do you have anything in mind that can be refactored in that other commit?

Copy link
Member Author

@y21 y21 Nov 19, 2023

Choose a reason for hiding this comment

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

@blyxyas ? :)
(the file is large, wondering if you want something specific refactored)

@blyxyas
Copy link
Member

blyxyas commented Nov 15, 2023

Could you please split this into a lint per commit 🙏 so that I can review better and the commit history is clearer (they won't be squashed on merge) (^..^)ノ

@bors
Copy link
Collaborator

bors commented Nov 16, 2023

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

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

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

Is there any other code change other than just changing code to files? If there isn't (outside that comment), I think this is pretty much ready.

clippy_lints/src/doc/link_with_quotes.rs Outdated Show resolved Hide resolved
}
}

fn collect_doc_replacements(attrs: &[Attribute]) -> Vec<(Span, String)> {
Copy link
Member

Choose a reason for hiding this comment

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

I don't disagree, but if we're not just moving some functions into other files, you could also refactor this commit.

@y21
Copy link
Member Author

y21 commented Nov 17, 2023

Is there any other code change other than just changing code to files?

Only in suspicious_doc_comments. I also added a FindPanicUnwrap::find_span function that can be used in a bunch of places in the main mod.rs.
Other lints are unchanged.

@y21
Copy link
Member Author

y21 commented Nov 17, 2023

Oh, the lint group was also changed from DocMarkdown to Doc. I initially thought that could be a small internal change that the user wouldn't notice, but #![warn(clippy::doc_markdown)] works, and won't anymore after this. Should I just change it back? I think doc is a better name for the group since it's really not about markdown anymore at that point, but I'm not sure if that's reason enough to do this change.

@blyxyas
Copy link
Member

blyxyas commented Nov 17, 2023

I'll nominate this issue, let's see what the team thinks about this. If we were to change its name, it would need to be deprecated some time before being removed =^● ⋏ ●^=

@y21
Copy link
Member Author

y21 commented Nov 17, 2023

If this ends up blocking the PR, I guess I could also just revert it for this PR, just so that this can remain an "internal-only" PR.
Renaming from DocMarkdown to Doc, if the team agrees, could be its own PR since that's a rather self-contained thing not relevant to this splitup.

Since this touches quite a lot of code and is prone to bit rot whenever someone makes a change to doc lints (and solving conflicts here is kind of a chore), I wouldn't want to leave this open for too long

@blyxyas blyxyas added the I-nominated Issue: Nominated to be discussed at the next Clippy meeting label Nov 17, 2023
@blyxyas
Copy link
Member

blyxyas commented Nov 19, 2023

Okis, rename the pass to DocMarkdown for now, we'll still discuss it with the rest of the team, but let's keep the ball rolling (=^・ω・^)y=

I think that the review should be addressed, and that this would be pretty ready to be merge-ready!

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! ❤️ I've revised these like 5 times and I still feel like there's something obvious that I don't see. Quite the GuillaumeGomez syndrome (=^-ω-^=)

@GuillaumeGomez
Copy link
Member

😆 Careful, it doesn't get better with time. ^^'

@blyxyas
Copy link
Member

blyxyas commented Nov 20, 2023

Oh no, I just remember that I said that they wouldn't be squashed ;(
Sorry for the chore, Timo, it's just my Alzheimer. I feel guilty now D:

@blyxyas
Copy link
Member

blyxyas commented Nov 20, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 20, 2023

📌 Commit 56cee3c has been approved by blyxyas

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Nov 20, 2023

⌛ Testing commit 56cee3c with merge 0487ed5...

bors added a commit that referenced this pull request Nov 20, 2023
Split `doc.rs` up into a subdirectory

So, first, sorry for the bad diff. 😅

In #11798, `@flip1995`  suggested splitting `doc.rs` up, much like how we have the `methods/`, `matches/`, `types/` subdirectories.
I agree with this, the file is getting bigger as we add more and more doc lints that it makes sense to do this refactoring.

This is purely an internal change that moves things around a bit.
(**EDIT:** depending on the outcome of #11801 (comment) , this may change the lint group name from `doc_markdoc` to `doc`).

I tried to not change any of the actual logic of the lints and as such some things weren't as easy to move to a separate file. So we still have some `span_lint*` calls in the `doc/mod.rs` file, which I think is fine. This is also the case in `methods/mod.rs`.

Also worth mentioning that the lints missing_errors_doc, missing_panics_doc, missing_safety_doc and unnecessary_safety_doc have a lot of the same logic so it didn't make much sense for each of these to be in their own file. Instead I just put them all in `missing_headers.rs`

I also added a bit of documentation to the involved `check_{attrs,doc}` methods.

changelog: none
@y21
Copy link
Member Author

y21 commented Nov 20, 2023

Did bors get stuck? 🤔
It's been going for a while

@flip1995
Copy link
Member

It lost track of this PR somehow. I re-synchronized bors for Clippy. Let's see if that helps.

@flip1995
Copy link
Member

Now it at least shows up as approved in the queue. Let's

@bors retry

so that it will be merged.

@bors
Copy link
Collaborator

bors commented Nov 20, 2023

⌛ Testing commit 56cee3c with merge 157ab49...

bors added a commit that referenced this pull request Nov 20, 2023
Split `doc.rs` up into a subdirectory

So, first, sorry for the bad diff. 😅

In #11798, `@flip1995`  suggested splitting `doc.rs` up, much like how we have the `methods/`, `matches/`, `types/` subdirectories.
I agree with this, the file is getting bigger as we add more and more doc lints that it makes sense to do this refactoring.

This is purely an internal change that moves things around a bit.
(**EDIT:** depending on the outcome of #11801 (comment) , this may change the lint group name from `doc_markdoc` to `doc`).

I tried to not change any of the actual logic of the lints and as such some things weren't as easy to move to a separate file. So we still have some `span_lint*` calls in the `doc/mod.rs` file, which I think is fine. This is also the case in `methods/mod.rs`.

Also worth mentioning that the lints missing_errors_doc, missing_panics_doc, missing_safety_doc and unnecessary_safety_doc have a lot of the same logic so it didn't make much sense for each of these to be in their own file. Instead I just put them all in `missing_headers.rs`

I also added a bit of documentation to the involved `check_{attrs,doc}` methods.

changelog: none
@bors
Copy link
Collaborator

bors commented Nov 20, 2023

⌛ Testing commit 56cee3c with merge 72c0d80...

@flip1995
Copy link
Member

First bors didn't want to do anything and now they do it twice. Weird fella.

@bors
Copy link
Collaborator

bors commented Nov 20, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: blyxyas
Pushing 72c0d80 to master...

@bors bors merged commit 72c0d80 into rust-lang:master Nov 20, 2023
5 checks passed
bors added a commit that referenced this pull request Nov 28, 2023
…Manishearth

rename `DocMarkdown` pass to `Documentation`

Followup of #11801

This was discussed in todays meeting: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202023-11-28/near/404667082

Decided to go with `Documentation`, because this would also make it consistent with how `Attributes` is named in `attrs.rs` (and it also sounds good).

changelog: none
@flip1995 flip1995 removed the I-nominated Issue: Nominated to be discussed at the next Clippy meeting label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants