1
Fork 0

rustdoc.d.ts: add window.{register_implementors,pending_implementors}

This commit is contained in:
binarycat 2025-03-10 14:29:08 -05:00
parent 2e1c8f088a
commit 749b6bf79f
2 changed files with 17 additions and 3 deletions

View file

@ -673,7 +673,6 @@ function preLoadCss(cssUrl) {
} }
// <https://github.com/search?q=repo%3Arust-lang%2Frust+[RUSTDOCIMPL]+trait.impl&type=code> // <https://github.com/search?q=repo%3Arust-lang%2Frust+[RUSTDOCIMPL]+trait.impl&type=code>
// @ts-expect-error
window.register_implementors = imp => { window.register_implementors = imp => {
const implementors = document.getElementById("implementors-list"); const implementors = document.getElementById("implementors-list");
const synthetic_implementors = document.getElementById("synthetic-implementors-list"); const synthetic_implementors = document.getElementById("synthetic-implementors-list");
@ -765,9 +764,7 @@ function preLoadCss(cssUrl) {
} }
} }
}; };
// @ts-expect-error
if (window.pending_implementors) { if (window.pending_implementors) {
// @ts-expect-error
window.register_implementors(window.pending_implementors); window.register_implementors(window.pending_implementors);
} }

View file

@ -44,6 +44,15 @@ declare global {
* Set up event listeners for a scraped source example. * Set up event listeners for a scraped source example.
*/ */
updateScrapedExample?: function(HTMLElement, HTMLElement), updateScrapedExample?: function(HTMLElement, HTMLElement),
/**
* register trait implementors, called by code generated in
* `write_shared.rs`
*/
register_implementors?: function(Implementors): void,
/**
* fallback in case `register_implementors` isn't defined yet.
*/
pending_implementors?: Implementors,
} }
interface HTMLElement { interface HTMLElement {
/** Used by the popover tooltip code. */ /** Used by the popover tooltip code. */
@ -415,4 +424,12 @@ declare namespace rustdoc {
}; };
type VlqData = VlqData[] | number; type VlqData = VlqData[] | number;
/**
* Maps from crate names to trait implementation data.
* Provied by generated `trait.impl` files.
*/
type Implementors = {
[key: string]: Array<[string, number, Array<string>]>
}
} }