Skip to content

Commit a72ad4e

Browse files
committed
rustdoc js: add rustdoc.ScrapedLoc type
1 parent b53be52 commit a72ad4e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/librustdoc/html/static/js/rustdoc.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ declare namespace rustdoc {
496496
* Single element in the data-locs field of a scraped example.
497497
* First field is the start and end char index,
498498
* other fields seem to be unused.
499+
*
500+
* generated by `render_call_locations` in `render/mod.rs`.
499501
*/
500502
type ScrapedLoc = [[number, number], string, string]
501503
}

src/librustdoc/html/static/js/scrape-examples.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@
127127
* @param {boolean} isHidden
128128
*/
129129
function setupLoc(example, isHidden) {
130-
const locs = example.locs = JSON.parse(nonnull(nonnull(example.attributes.getNamedItem("data-locs")).textContent));
130+
const locs_str = example.attributes.getNamedItem("data-locs")).textContent;
131+
const locs = example.locs =
132+
JSON.parse(nonnull(nonnull(locs_str));
131133
// Start with the first example in view
132134
scrollToLoc(example, locs[0][0], isHidden);
133135
}

0 commit comments

Comments
 (0)