-
Notifications
You must be signed in to change notification settings - Fork 13k
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
tests: Add htmldocck.py script for the use of Rustdoc tests. #21304
Conversation
The script is intended as a tool for doing every sort of verifications amenable to Rustdoc's HTML output. For example, link checkers would go to this script. It already parses HTML into a document tree form (with a slight caveat), so future tests can make use of it. As an example, relevant `rustdoc-*` run-make tests have been updated to use `htmldocck.py` and got their `verify.sh` removed. In the future they may go to a dedicated directory with htmldocck running by default. The detailed explanation of test scripts is provided as a docstring of htmldocck. cc rust-lang#19723
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
@brson ❤️ tests |
This is great! Hopefully this will help prevent a lot of regressions in rustdocs when things change internally by making it easier to write tests. Will we be able to test cross-crate docs this way too? Specifically I mean checking that where clauses, lifetimes, and things like that are preserved when using |
@tomjakubowski In principle yes, one can invoke |
Should |
This... is amazing! Thanks so much for doing this @lifthrasiir! Some thoughts:
If you're comfortable landing this now, I don't mind getting this in-tree ASAP to start requesting regression tests for rustdoc :) |
I can also help out with any form of integration with |
@alexcrichton I'll try a little bit with CSS-to-XPath converter this night, but I don't mind the immediate merging. |
Okay, I seriously tried that. Actually, it was not that hard to get a functional CSS parser in about 50 or 60 lines of additional code, but the resulting CSS selector will be severely limited since the partial matching of classes won't work (e.g. |
Alright, thanks for investigating! We can continue to iterate a bit in-tree |
@lifthrasiir yeah, XPath unfortunately doesn't have a nice shortcut for matching on whitespace-delimited tokens in an attribute (like CSS3's |
@tomjakubowski ElementTree does not support any function besides from |
The script is intended as a tool for doing every sort of verifications amenable to Rustdoc's HTML output. For example, link checkers would go to this script. It already parses HTML into a document tree form (with a slight caveat), so future tests can make use of it. As an example, relevant `rustdoc-*` run-make tests have been updated to use `htmldocck.py` and got their `verify.sh` removed. In the future they may go to a dedicated directory with htmldocck running by default. The detailed explanation of test scripts is provided as a docstring of htmldocck. cc #19723
It might be a good idea to make the python code here forward compatible with python3. Always good to prepare for the inevitable. |
The script is intended as a tool for doing every sort of verifications amenable to Rustdoc's HTML output. For example, link checkers would go to this script. It already parses HTML into a document tree form (with a slight caveat), so future tests can make use of it.
As an example, relevant
rustdoc-*
run-make tests have been updated to usehtmldocck.py
and got theirverify.sh
removed. In the future they may go to a dedicated directory with htmldocck running by default. The detailed explanation of test scripts is provided as a docstring of htmldocck.cc #19723