rustdoc-search: fix inaccurate type descriptions
This commit is contained in:
parent
a2541e861e
commit
1ab60f2a64
2 changed files with 63 additions and 54 deletions
|
@ -200,3 +200,59 @@ let FunctionSearchType;
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
let FunctionType;
|
let FunctionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f`
|
||||||
|
* are arrays with the same length. `q`, `a`, and `c` use a sparse
|
||||||
|
* representation for compactness.
|
||||||
|
*
|
||||||
|
* `n[i]` contains the name of an item.
|
||||||
|
*
|
||||||
|
* `t[i]` contains the type of that item
|
||||||
|
* (as a string of characters that represent an offset in `itemTypes`).
|
||||||
|
*
|
||||||
|
* `d[i]` contains the description of that item.
|
||||||
|
*
|
||||||
|
* `q` contains the full paths of the items. For compactness, it is a set of
|
||||||
|
* (index, path) pairs used to create a map. If a given index `i` is
|
||||||
|
* not present, this indicates "same as the last index present".
|
||||||
|
*
|
||||||
|
* `i[i]` contains an item's parent, usually a module. For compactness,
|
||||||
|
* it is a set of indexes into the `p` array.
|
||||||
|
*
|
||||||
|
* `f` contains function signatures, or `0` if the item isn't a function.
|
||||||
|
* More information on how they're encoded can be found in rustc-dev-guide
|
||||||
|
*
|
||||||
|
* Functions are themselves encoded as arrays. The first item is a list of
|
||||||
|
* types representing the function's inputs, and the second list item is a list
|
||||||
|
* of types representing the function's output. Tuples are flattened.
|
||||||
|
* Types are also represented as arrays; the first item is an index into the `p`
|
||||||
|
* array, while the second is a list of types representing any generic parameters.
|
||||||
|
*
|
||||||
|
* b[i] contains an item's impl disambiguator. This is only present if an item
|
||||||
|
* is defined in an impl block and, the impl block's type has more than one associated
|
||||||
|
* item with the same name.
|
||||||
|
*
|
||||||
|
* `a` defines aliases with an Array of pairs: [name, offset], where `offset`
|
||||||
|
* points into the n/t/d/q/i/f arrays.
|
||||||
|
*
|
||||||
|
* `doc` contains the description of the crate.
|
||||||
|
*
|
||||||
|
* `p` is a list of path/type pairs. It is used for parents and function parameters.
|
||||||
|
*
|
||||||
|
* `c` is an array of item indices that are deprecated.
|
||||||
|
* @typedef {{
|
||||||
|
* doc: string,
|
||||||
|
* a: Object,
|
||||||
|
* n: Array<string>,
|
||||||
|
* t: String,
|
||||||
|
* d: Array<string>,
|
||||||
|
* q: Array<[Number, string]>,
|
||||||
|
* i: Array<Number>,
|
||||||
|
* f: string,
|
||||||
|
* p: Array<Object>,
|
||||||
|
* b: Array<[Number, String]>,
|
||||||
|
* c: Array<Number>
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
|
let RawSearchIndexCrate;
|
||||||
|
|
|
@ -2924,6 +2924,11 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||||
return functionTypeFingerprint[(fullId * 4) + 3];
|
return functionTypeFingerprint[(fullId * 4) + 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert raw search index into in-memory search index.
|
||||||
|
*
|
||||||
|
* @param {[string, RawSearchIndexCrate][]} rawSearchIndex
|
||||||
|
*/
|
||||||
function buildIndex(rawSearchIndex) {
|
function buildIndex(rawSearchIndex) {
|
||||||
searchIndex = [];
|
searchIndex = [];
|
||||||
typeNameIdMap = new Map();
|
typeNameIdMap = new Map();
|
||||||
|
@ -2950,59 +2955,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||||
// This loop actually generates the search item indexes, including
|
// This loop actually generates the search item indexes, including
|
||||||
// normalized names, type signature objects and fingerprints, and aliases.
|
// normalized names, type signature objects and fingerprints, and aliases.
|
||||||
id = 0;
|
id = 0;
|
||||||
/**
|
|
||||||
* The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f`
|
|
||||||
* are arrays with the same length. `q`, `a`, and `c` use a sparse
|
|
||||||
* representation for compactness.
|
|
||||||
*
|
|
||||||
* `n[i]` contains the name of an item.
|
|
||||||
*
|
|
||||||
* `t[i]` contains the type of that item
|
|
||||||
* (as a string of characters that represent an offset in `itemTypes`).
|
|
||||||
*
|
|
||||||
* `d[i]` contains the description of that item.
|
|
||||||
*
|
|
||||||
* `q` contains the full paths of the items. For compactness, it is a set of
|
|
||||||
* (index, path) pairs used to create a map. If a given index `i` is
|
|
||||||
* not present, this indicates "same as the last index present".
|
|
||||||
*
|
|
||||||
* `i[i]` contains an item's parent, usually a module. For compactness,
|
|
||||||
* it is a set of indexes into the `p` array.
|
|
||||||
*
|
|
||||||
* `f[i]` contains function signatures, or `0` if the item isn't a function.
|
|
||||||
* Functions are themselves encoded as arrays. The first item is a list of
|
|
||||||
* types representing the function's inputs, and the second list item is a list
|
|
||||||
* of types representing the function's output. Tuples are flattened.
|
|
||||||
* Types are also represented as arrays; the first item is an index into the `p`
|
|
||||||
* array, while the second is a list of types representing any generic parameters.
|
|
||||||
*
|
|
||||||
* b[i] contains an item's impl disambiguator. This is only present if an item
|
|
||||||
* is defined in an impl block and, the impl block's type has more than one associated
|
|
||||||
* item with the same name.
|
|
||||||
*
|
|
||||||
* `a` defines aliases with an Array of pairs: [name, offset], where `offset`
|
|
||||||
* points into the n/t/d/q/i/f arrays.
|
|
||||||
*
|
|
||||||
* `doc` contains the description of the crate.
|
|
||||||
*
|
|
||||||
* `p` is a list of path/type pairs. It is used for parents and function parameters.
|
|
||||||
*
|
|
||||||
* `c` is an array of item indices that are deprecated.
|
|
||||||
*
|
|
||||||
* @type {{
|
|
||||||
* doc: string,
|
|
||||||
* a: Object,
|
|
||||||
* n: Array<string>,
|
|
||||||
* t: String,
|
|
||||||
* d: Array<string>,
|
|
||||||
* q: Array<[Number, string]>,
|
|
||||||
* i: Array<Number>,
|
|
||||||
* f: Array<RawFunctionSearchType>,
|
|
||||||
* p: Array<Object>,
|
|
||||||
* b: Array<[Number, String]>,
|
|
||||||
* c: Array<Number>
|
|
||||||
* }}
|
|
||||||
*/
|
|
||||||
for (const [crate, crateCorpus] of rawSearchIndex) {
|
for (const [crate, crateCorpus] of rawSearchIndex) {
|
||||||
// This object should have exactly the same set of fields as the "row"
|
// This object should have exactly the same set of fields as the "row"
|
||||||
// object defined below. Your JavaScript runtime will thank you.
|
// object defined below. Your JavaScript runtime will thank you.
|
||||||
|
@ -3039,7 +2992,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||||
const itemDescs = crateCorpus.d;
|
const itemDescs = crateCorpus.d;
|
||||||
// an array of (Number) the parent path index + 1 to `paths`, or 0 if none
|
// an array of (Number) the parent path index + 1 to `paths`, or 0 if none
|
||||||
const itemParentIdxs = crateCorpus.i;
|
const itemParentIdxs = crateCorpus.i;
|
||||||
// an array of (Object | null) the type of the function, if any
|
// an array of (Array | 0) the type of the function, if any
|
||||||
const itemFunctionSearchTypes = crateCorpus.f;
|
const itemFunctionSearchTypes = crateCorpus.f;
|
||||||
// an array of (Number) indices for the deprecated items
|
// an array of (Number) indices for the deprecated items
|
||||||
const deprecatedItems = new Set(crateCorpus.c);
|
const deprecatedItems = new Set(crateCorpus.c);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue