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

Extend CSS check to CSS variables #101813

Merged
merged 5 commits into from
Sep 16, 2022

Conversation

GuillaumeGomez
Copy link
Member

This PR is a bit big because the first commit is a rewrite of the CSS parser to something a bit simpler which still allows to get easily access to CSS properties name.

The other two are about adding tests and adding the CSS variables check.

This check was missing because we are relying more and more on CSS variables rather than CSS selectors in themes.

r? @notriddle

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Sep 14, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 14, 2022
Copy link
Contributor

@notriddle notriddle left a comment

Choose a reason for hiding this comment

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

More generally, I have concerns about producing non-rustdoc-specific warnings from the tool as it's written.

  • Good linters have support for localized silencing, like the #[allow()] directives in Rust itself. There's none of that here.

  • It's also fairly likely, since this parser hasn't really been tested against a production-grade battery of CSS test suite corner cases, that there's bugs in here.

    For example, you can totally include semicolons and curley braces in url({;}.png) without quotes. It looks like this parser tokenizes it incorrectly.

As long as it's just scanning for variables and selectors, it's probably okay, but if it's going to start producing more broadly-applicable warnings, it becomes more important to minimize false positives.

src/librustdoc/theme.rs Outdated Show resolved Hide resolved
@notriddle
Copy link
Contributor

In other words, I'm happy with checking CSS variables are filled in with all the data rustdoc needs. I just don't want scope creep from adding other warnings.

@GuillaumeGomez
Copy link
Member Author

I added them without thinking. Removing them.

@GuillaumeGomez
Copy link
Member Author

It's also fairly likely, since this parser hasn't really been tested against a production-grade battery of CSS test suite corner cases, that there's bugs in here.

For example, you can totally include semicolons and curley braces in url({;}.png) without quotes. It looks like this parser tokenizes it incorrectly.

Yes, bugs are very likely but the goal isn't to support the CSS syntax faithfully so we should be mostly fine on this part. As for why I didn't use an existing CSS parser: either they're way too big (in term of deps) or they provide way too advanced features, making it complicated to just query the information we want. But if you know one that isn't too big and covers just what we need, it'd be perfect!

@GuillaumeGomez
Copy link
Member Author

I added an extra handling for parens which fixes the issue you mentioned.

@GuillaumeGomez
Copy link
Member Author

@bors r=notriddle

@bors
Copy link
Contributor

bors commented Sep 15, 2022

📌 Commit d3529ce has been approved by notriddle

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 Sep 15, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 16, 2022
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#101494 (rustdoc mobile: move notable traits to return type)
 - rust-lang#101813 (Extend CSS check to CSS variables)
 - rust-lang#101825 (Fix back RPIT changes)
 - rust-lang#101843 (Suggest associated const for incorrect use of let in traits)
 - rust-lang#101859 (Slight vertical formatting)
 - rust-lang#101868 (rustdoc: use more precise URLs for jump-to-definition links)
 - rust-lang#101877 (rustdoc: remove no-op CSS `.block { padding: 0 }`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6f8d41c into rust-lang:master Sep 16, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 16, 2022
@GuillaumeGomez GuillaumeGomez deleted the check-css-variables branch September 16, 2022 17:33
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.

5 participants