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: Rename @has FILE PATTERN to @hasraw FILE PATTERN #100355

Merged
merged 7 commits into from
Aug 14, 2022

Conversation

camelid
Copy link
Member

@camelid camelid commented Aug 10, 2022

Fixes #100354.

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 10, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 10, 2022
@camelid
Copy link
Member Author

camelid commented Aug 10, 2022

For future reference, I used variations of this Find&Replace regex:

@matches ([^ ]+) ("[^"]+")$
@matchestext $1 $2

Copy link
Member Author

@camelid camelid left a comment

Choose a reason for hiding this comment

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

There are several instances of multiline commands that were incorrectly that I'll need to fixup manually.

@camelid camelid 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 Aug 10, 2022
@rust-log-analyzer

This comment has been minimized.

@camelid camelid changed the title rustdoc: Rename @has FILE PATTERN to @hastext FILE PATTERN rustdoc: Rename @has FILE PATTERN to @hasraw FILE PATTERN Aug 10, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid
Copy link
Member Author

camelid commented Aug 11, 2022

Oops forgot to update @!has.

@bors
Copy link
Contributor

bors commented Aug 12, 2022

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

Reasons:
1. It's shorter.
2. `@matches-literal` seems to contradict itself: a regex is
   intrinsically not a literal match, while it is still a textual match.
I think `@hasraw` is slightly clearer than `@hastext` since it is
actually matching against the raw HTML, not the text nodes.
Copy link
Member Author

@camelid camelid left a comment

Choose a reason for hiding this comment

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

Left comments at each place where I noticed that @!has was being used incorrectly before. It used @!has (or the other commands) with an XPath that was actually treated as a literal string of HTML code. All or almost all of the uses were with the negated commands (e.g., `@!has) since otherwise the tests would've noticeably failed.

src/test/rustdoc/internal.rs Outdated Show resolved Hide resolved
src/test/rustdoc/issue-61592.rs Outdated Show resolved Hide resolved
src/test/rustdoc/no-crate-filter.rs Outdated Show resolved Hide resolved
src/test/rustdoc/recursive-deref.rs Outdated Show resolved Hide resolved
src/test/rustdoc/remove-url-from-headings.rs Outdated Show resolved Hide resolved
src/test/rustdoc/table-in-docblock.rs Outdated Show resolved Hide resolved
src/test/rustdoc/toggle-item-contents.rs Outdated Show resolved Hide resolved
src/test/rustdoc/trait-impl-items-links-and-anchors.rs Outdated Show resolved Hide resolved
src/test/rustdoc/trait-impl.rs Outdated Show resolved Hide resolved
src/test/rustdoc/tuple-struct-fields-doc.rs Outdated Show resolved Hide resolved
`@!has` (and `@!matches`) with two arguments used to treat the second
argument as a literal string of HTML code. Now, that feature has been
renamed into `@!hasraw` (and `@!matchesraw`), and the arity-2 `@!has`
version is an error.

These uses thought the second argument was being treated as an XPath, as
with the arity-3 version, but in fact was being treated as literal HTML.
Because these were checking for the *absence* of the string, the tests
silently did nothing -- an XPath string won't ever be showing up in the
test's generated HTML!
@camelid camelid marked this pull request as ready for review August 13, 2022 05:33
@camelid camelid 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 Aug 13, 2022
@camelid
Copy link
Member Author

camelid commented Aug 13, 2022

Ok, I fixed all the incorrect uses of @!has, and the tests passed. This is ready for review!

@camelid
Copy link
Member Author

camelid commented Aug 13, 2022

Maybe r? @GuillaumeGomez

(@Mark-Simulacrum feel free to review if you'd like, though not sure why highfive assigned you since this is rustdoc-related)

@GuillaumeGomez
Copy link
Member

I'm confused: didn't you say in the issue that the problem was the commands should have a different name when then they had 2 vs 3 arguments? Because otherwise, I don't see the point of this PR: the command name is longer and definitely not more helpful.

@camelid
Copy link
Member Author

camelid commented Aug 13, 2022

That's what this PR does: it renames the 2-argument version to @hasraw. The 3-argument version is still @has. So this addresses the issue: they now have different names.

As you can see in the last commit, it turns out that a lot of tests made the same mistake I did and thought @has FILE PATTERN was the same as @has FILE PATTERN '' (which is what they intended).

Does that help? If not, please let me know which part you want me to clarify.

@camelid
Copy link
Member Author

camelid commented Aug 13, 2022

Note the 3-argument version keeps its name in this PR; only the 2-argument version is different.

@GuillaumeGomez
Copy link
Member

Sorry, I completely missed it somehow. I'll make another review shortly then. Thanks for the extra explanation!

@GuillaumeGomez
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Aug 13, 2022

📌 Commit 0d588e9 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2022
…mpiler-errors

Rollup of 11 pull requests

Successful merges:

 - rust-lang#100355 (rustdoc: Rename ``@has` FILE PATTERN` to ``@hasraw` FILE PATTERN`)
 - rust-lang#100407 (avoid some int2ptr casts in thread_local_key tests)
 - rust-lang#100434 (Fix HIR pretty printing of let else)
 - rust-lang#100438 (Erase regions better in `promote_candidate`)
 - rust-lang#100445 (adapt test for msan message change)
 - rust-lang#100447 (Remove more Clean trait implementations)
 - rust-lang#100464 (Make `[rust] use-lld=true` work on windows)
 - rust-lang#100475 (Give a helpful diagnostic when the next struct field has an attribute)
 - rust-lang#100490 (wf: correctly `shallow_resolve` consts)
 - rust-lang#100501 (nicer Miri backtraces for from_exposed_addr)
 - rust-lang#100509 (merge two test directories that mean the same thing)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4b51df3 into rust-lang:master Aug 14, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 14, 2022
@camelid camelid deleted the has2-rename branch August 14, 2022 04:41
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. 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: Rename @has FILE PATTERN to @hastext
7 participants