rustdoc: allow searches to match against both type and name
repurposes existing syntax that previously had a nonsese meaning.
now fn:add, u8 -> u8 searches for fn items with "add" in the name, that take a u8 argument and return a u8.
the kind is included in anticipation that type based searches will soon work on items other than functions and methods.
fixes #131130
r? @notriddle
Some changes occurred in HTML/CSS/JS.
cc @GuillaumeGomez, @jsha
The job mingw-check-tidy failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
--stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#13 2.678 Building wheels for collected packages: reuse
#13 2.679 Building wheel for reuse (pyproject.toml): started
#13 2.924 Building wheel for reuse (pyproject.toml): finished with status 'done'
#13 2.925 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132720 sha256=026f3bb0f1aa8090b861fd0a0939cb1a782396d84c8aab7875096557d637a0f6
#13 2.925 Stored in directory: /tmp/pip-ephem-wheel-cache-z6y7sgvr/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#13 2.928 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#13 3.324 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#13 3.324 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#13 3.844 Collecting virtualenv
#13 3.844 Collecting virtualenv
#13 3.879 Downloading virtualenv-20.26.6-py3-none-any.whl (6.0 MB)
#13 3.954 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.0/6.0 MB 83.3 MB/s eta 0:00:00
#13 4.012 Collecting filelock<4,>=3.12.2
#13 4.015 Downloading filelock-3.16.1-py3-none-any.whl (16 kB)
#13 4.047 Collecting platformdirs<5,>=3.9.1
#13 4.050 Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
#13 4.067 Collecting distlib<1,>=0.3.7
#13 4.078 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 469.0/469.0 KB 86.9 MB/s eta 0:00:00
#13 4.078 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 469.0/469.0 KB 86.9 MB/s eta 0:00:00
#13 4.158 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#13 4.347 Successfully installed distlib-0.3.9 filelock-3.16.1 platformdirs-4.3.6 virtualenv-20.26.6
#13 DONE 4.4s
#14 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#14 DONE 0.0s
---
DirectMap4k: 219072 kB
DirectMap2M: 10266624 kB
DirectMap1G: 8388608 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel.
downloading https://static.rust-lang.org/dist/2024-10-16/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
---
fmt check
fmt: checked 5608 files
tidy check
tidy: Skipping binary file check, read-only filesystem
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:249: line longer than 100 chars
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:1980: tab character
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:3118: trailing whitespace
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:3126: line longer than 100 chars
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:3136: line longer than 100 chars
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (24.2)
All checks passed!
checking C++ file formatting
some tidy checks failed
some tidy checks failed
Command has failed. Rerun with -v to see more details.
local time: Thu Oct 17 20:40:19 UTC 2024
network time: Thu, 17 Oct 2024 20:40:20 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
cleaned up the formatting a bit, hopefully this satisfies tidy
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#16 3.274 Building wheels for collected packages: reuse
#16 3.276 Building wheel for reuse (pyproject.toml): started
#16 3.611 Building wheel for reuse (pyproject.toml): finished with status 'done'
#16 3.612 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132720 sha256=026f3bb0f1aa8090b861fd0a0939cb1a782396d84c8aab7875096557d637a0f6
#16 3.613 Stored in directory: /tmp/pip-ephem-wheel-cache-19gk5fbt/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#16 3.615 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#16 4.103 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#16 4.104 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#16 DONE 4.2s
---
info: ES-Check: there were no ES version matching errors! 🎉
+ eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/externs.js ../src/librustdoc/html/static/js/main.js ../src/librustdoc/html/static/js/scrape-examples.js ../src/librustdoc/html/static/js/search.js ../src/librustdoc/html/static/js/settings.js ../src/librustdoc/html/static/js/src-script.js ../src/librustdoc/html/static/js/storage.js
/checkout/src/librustdoc/html/static/js/search.js
249:9 error 'r' is never reassigned. Use 'const' instead prefer-const
258:26 error Unexpected parentheses around single function argument arrow-parens
3120:17 error 'name_elem' is never reassigned. Use 'const' instead prefer-const
3134:21 error 'real_path_dist' is never reassigned. Use 'const' instead prefer-const
3135:57 error Operator '/' must be spaced space-infix-ops
✖ 5 problems (5 errors, 0 warnings)
5 errors and 0 warnings potentially fixable with the `--fix` option.
local time: Sat Oct 19 19:18:40 UTC 2024
network time: Sat, 19 Oct 2024 19:18:40 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
I can't say that I like that comma. If it's tough to get rid of it (I think it would be, since it would require infinite lookahead to distinguish fn:a b, c from fn:a b), here's an alternative suggestion:
Intra-doc links use a disambiguator that's separated from the item itself with an @ instead of a :, as in fn@add. Perhaps that could be the syntax for the extraNameElem, so that the sample query becomes fn@add u8 -> u8.
The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
.......... (130/133)
..F (133/133)
/checkout/tests/rustdoc-gui/search-corrections.goml search-corrections... FAILED
[ERROR] `tests/rustdoc-gui/search-corrections.goml` line 100: ".error" not found: for command `assert-css: (".error", {
"display": "block"
})`
[ERROR] `tests/rustdoc-gui/search-corrections.goml` line 103: ".error" not found: for command `assert-text: (
".error",
"Query parser error: \"Generic type parameter notablestructwithlongnamr does not accept generic parameters\"."
Error: ()
Build completed unsuccessfully in 0:03:36
local time: Sat Oct 19 21:01:42 UTC 2024
I can't say that I like that comma. If it's tough to get rid of it (I think it would be, since it would require infinite lookahead to distinguish fn:a b, c from fn:a b), here's an alternative suggestion:
why do we even allow spaces in item names?
@lolbinarycat https://github.com/rust-lang/rust/pull/108537 was when that was added. The idea was that name-based search worked well when space was used to separate path components, because it's easier than ::
ah, that makes sense. we should probably document that behavior somewhere.
i mean... if we're going treat spaces as :: in that case, we should probably do it here too, since this does support path-based search. i think adding less special cases to the syntax is a good thing, and it would be weird if fn:vec p worked but fn:vec p -> usize didn't.
ultimately, it might not be the "prettiest", but i think keeping the syntax easy to learn and understand is the most important thing.
ah, that makes sense. we should probably document that behavior somewhere.
https://doc.rust-lang.org/nightly/rustdoc/read-documentation/search.html#search-by-name is supposed to describe it.
:umbrella: The latest upstream changes (presumably #127589) made this pull request unmergeable. Please resolve the merge conflicts.
The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
.......... (130/134)
...F (134/134)
/checkout/tests/rustdoc-gui/search-corrections.goml search-corrections... FAILED
[ERROR] `tests/rustdoc-gui/search-corrections.goml` line 100: ".error" not found: for command `assert-css: (".error", {
"display": "block"
})`
[ERROR] `tests/rustdoc-gui/search-corrections.goml` line 103: ".error" not found: for command `assert-text: (
".error",
"Query parser error: \"Generic type parameter NotableStructWithLongNamr does not accept generic parameters\"."
Error: ()
Build completed unsuccessfully in 0:03:20
local time: Mon Nov 11 19:48:55 UTC 2024
Another approach would be adding proper boolean combinators to rustdoc-search, that way we could just do add & u8 -> u8, however, that would be significantly more involved, and might have a performance overhead (we would have to bypass the trie for more complex searches)
:umbrella: The latest upstream changes (presumably #135615) made this pull request unmergeable. Please resolve the merge conflicts.
Now that type-based search does actually work for non-function items, do we want to revisit this?