about summary refs log tree commit diff
path: root/src/librustdoc/html/render/search_index.rs
AgeCommit message (Collapse)AuthorLines
2023-12-14Use Map instead of Object for source files and search indexGuillaume Gomez-1/+1
2023-11-19rustdoc-search: add support for associated typesMichael Howell-60/+362
2023-11-15Re-format code with new rustfmtMark Rousskov-4/+5
2023-09-21rustdoc-search: add impl disambiguator to duplicate assoc itemsMichael Howell-2/+31
Helps with #90929 This changes the search results, specifically, when there's more than one impl with an associated item with the same name. For example, the search queries `simd<i8> -> simd<i8>` and `simd<i64> -> simd<i64>` don't link to the same function, but most of the functions have the same names. This change should probably be FCP-ed, especially since it adds a new anchor link format for `main.js` to handle, so that URLs like `struct.Vec.html#impl-AsMut<[T]>-for-Vec<T,+A>/method.as_mut` redirect to `struct.Vec.html#method.as_mut-2`. It's a strange design, but there are a few reasons for it: * I'd like to avoid making the HTML bigger. Obviously, fixing this bug is going to add at least a little more data to the search index, but adding more HTML penalises viewers for the benefit of searchers. * Breaking `struct.Vec.html#method.len` would also be a disappointment. On the other hand: * The path-style anchors might be less prone to link rot than the numbered anchors. It's definitely less likely to have URLs that appear to "work", but silently point at the wrong thing. * This commit arranges the path-style anchor to redirect to the numbered anchor. Nothing stops rustdoc from doing the opposite, making path-style anchors the default and redirecting the "legacy" numbered ones.
2023-09-03rustdoc-search: add support for type parametersMichael Howell-109/+125
When writing a type-driven search query in rustdoc, specifically one with more than one query element, non-existent types become generic parameters instead of auto-correcting (which is currently only done for single-element queries) or giving no result. You can also force a generic type parameter by writing `generic:T` (and can force it to not use a generic type parameter with something like `struct:T` or whatever, though if this happens it means the thing you're looking for doesn't exist and will give you no results). There is no syntax provided for specifying type constraints for generic type parameters. When you have a generic type parameter in a search query, it will only match up with generic type parameters in the actual function, not concrete types that match, not concrete types that implement a trait. It also strictly matches based on when they're the same or different, so `option<T>, option<U> -> option<U>` matches `Option::and`, but not `Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches `Option::or`, but not `Option::and`.
2023-09-02Correctly handle paths from foreign itemsGuillaume Gomez-11/+46
2023-09-01Merge all loops into one when generating search indexGuillaume Gomez-92/+65
2023-09-01[rustdoc] Fix path in type-based searchGuillaume Gomez-13/+50
2023-05-30rustdoc: simplify `clean` by removing `FnRetTy`Michael Howell-18/+5
The default fn ret ty is always unit. Just use that. Looking back at the time when `FnRetTy` (then called `FunctionRetTy`) was first added to rustdoc, it seems to originally be there because `-> !` was a special form: the never type didn't exist back then. https://github.com/rust-lang/rust/commit/eb01b17b06eb35542bb80ff7456043b0ed5572ba#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9L921-L924
2023-05-22rustdoc: Cleanup doc string collapsingVadim Petrochenkov-7/+3
2023-04-24rustdoc-search: add slices and arrays to indexMichael Howell-2/+28
This indexes them as primitives with generics, so `slice<u32>` is how you search for `[u32]`, and `array<u32>` for `[u32; 1]`. A future commit will desugar the square bracket syntax to search both arrays and slices at once.
2023-04-12remove some unneeded importsKaDiWa-1/+1
2023-03-16Rollup merge of #108875 - notriddle:notriddle/return-trait, r=GuillaumeGomezMatthias Krüger-2/+7
rustdoc: fix type search for `Option` combinators
2023-03-11Rollup merge of #107629 - pitaj:rustdoc-search-deprecated, r=jshaMatthias Krüger-1/+22
rustdoc: sort deprecated items lower in search closes #98759 ### Screenshots `i32::MAX` show sup above `std::i32::MAX` and `core::i32::MAX` ![image](https://user-images.githubusercontent.com/803701/216725619-40afb7b0-e984-4a2e-ab5b-a95b24736b0e.png) If just searching for `min`, the deprecated results show up far below other things: ![image](https://user-images.githubusercontent.com/803701/216725672-e4325d37-9bfe-47eb-a1fe-0e57092aa811.png) one page later ![image](https://user-images.githubusercontent.com/803701/216725932-cd1c4a42-d527-44fb-a4ab-5a6d243659cc.png) ~~And, as you can see, the "Deprecation planned" message shows up in the search results. The same is true for fully-deprecated items like `mem::uninitialized`: ![image](https://user-images.githubusercontent.com/803701/216726268-1657e77a-563f-45a0-85a7-3a0cf4d66d6f.png)~~ Edit: the deprecation message change was removed from this PR. Only the sorting is changed.
2023-03-10rustdoc: sort deprecated items lower in searchPeter Jaszkowiak-1/+22
serialize `q` (`itemPaths`) sparsely overall 4% reduction in search index size
2023-03-07rustdoc: fix type search when more than one `where` clause appliesMichael Howell-1/+1
2023-03-07rustdoc: fix type search index for `fn<T>() -> &T where T: Trait`Michael Howell-1/+6
2023-03-04rustdoc: function signature search with traits in `where` clauseMichael Howell-21/+13
2023-02-13rustdoc: use a string with one-character codes for search index typesMichael Howell-1/+10
$ wc -c search-index.old.js search-index.new.js 3940530 search-index.old.js 3843222 search-index.new.js ((3940530-3843222)/3940530)*100 = 2.47% $ wc -c search-index.old.js.gz search-index.new.js.gz 380251 search-index.old.js.gz 379434 search-index.new.js.gz ((380251-379434)/380251)*100 = 0.214%
2023-01-15rustdoc: simplify some & ref erencesMatthias Krüger-2/+2
2023-01-13CrateData: don't allocate String when Serialize, &str is enoughklensy-1/+1
2023-01-13IndexItem.name String -> Symbolklensy-4/+4
2023-01-10Remove unneeded ItemId::Primitive variantGuillaume Gomez-20/+55
2022-12-29Fix index out of bounds issues in rustdocyukang-2/+1
2022-08-13avoid cloning and then iteratingKaDiWa-4/+9
2022-06-27Add comments, fixes for `0` sentinelMichael Howell-1/+27
2022-06-24Fix rustdoc under `#[no_core]`Michael Howell-28/+32
2022-06-24rustdoc: reference function signature types from the `p` arrayMichael Howell-51/+102
This reduces the size of the function signature index, because it's common to have many functions that operate on the same types. $ wc -c search-index-old.js search-index-new.js 5224374 search-index-old.js 3932314 search-index-new.js By my math, this reduces the uncompressed size of the search index by 32%. On compressed signatures, the wins are less drastic, a mere 8%: $ wc -c search-index-old.js.gz search-index-new.js.gz 404532 search-index-old.js.gz 371635 search-index-new.js.gz
2022-05-31rustdoc: also index raw pointersMichael Howell-2/+3
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2022-05-31rustdoc: also index impl traitMichael Howell-6/+24
2022-05-27cleanup librustdoc by making parent stack store itemsMichael Howell-15/+2
2022-05-26rustdoc: factor orphan impl items into an actual structMichael Howell-5/+7
2022-05-25rustdoc: include impl generics / self in search indexMichael Howell-13/+63
2022-05-24fix clippy perf lintsklensy-2/+2
2022-05-24fix simple clippy lintsklensy-1/+1
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-2/+6
2022-02-03rustdoc: clippy::complexity fixesMatthias Krüger-1/+1
clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
2022-01-17Correctly handle pure genericsGuillaume Gomez-4/+6
2022-01-17fix #90187: Replace all def_id_no_primitives with def_idzredb-1/+1
2022-01-17fix #90187zredb-6/+17
2022-01-17fix #90187zredb-13/+10
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-3/+7
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2021-12-28Add regression test for #59502Noah Lev-0/+2
This issue was fixed using a hacky recursion "fuel" argument, but the issue was never minimized nor was a regression test added. The underlying bug is still unfixed, so this test should help with fixing it and removing the `recurse` hack.
2021-12-28Remove unused parameterNoah Lev-6/+5
2021-12-27Give clearer names to several search index functionsNoah Lev-12/+24
2021-12-27Coalesce two arguments as `&Function`Noah Lev-6/+8
2021-12-27Make `search_index` functions private where possibleNoah Lev-2/+2
Now the only two crate-public items are `build_index` and `get_index_search_type` (because for some reason the latter is also used in `formats::cache`).
2021-12-27Move `ExternalLocation` to `clean::types`Noah Lev-10/+0
It was previously defined in `render::search_index` but wasn't used at all there. `clean::types` seems like a better fit since that's where `ExternalCrate` is defined.
2021-12-27rustdoc: Remove some unnecessary `cache` parametersNoah Lev-23/+12
Based on https://github.com/rust-lang/rust/pull/80883#issuecomment-774437832. The `tcx` parameters do seem to be used though, so I only removed the `cache` parameters.
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-0/+438
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.