about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/source-script.js
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-07-14 16:46:46 -0700
committerMichael Howell <michael@notriddle.com>2023-07-14 16:54:14 -0700
commite72fba416014427d14f37fa9efb48ef6a6208bf3 (patch)
tree8abfe85527065f1f6fb5a48dfb2652bb56d8f61a /src/librustdoc/html/static/js/source-script.js
parent34bc8fbea3b72ce1f9254dbed85fddb2d7985f75 (diff)
downloadrust-e72fba416014427d14f37fa9efb48ef6a6208bf3.tar.gz
rust-e72fba416014427d14f37fa9efb48ef6a6208bf3.zip
rustdoc: use `src` consistently over `source` in JavaScript
Since the directory that contains source files is called `src`,
it makes sense to name the scripts that way, too.
Diffstat (limited to 'src/librustdoc/html/static/js/source-script.js')
-rw-r--r--src/librustdoc/html/static/js/source-script.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js
index 54f3603865c..679c2341f02 100644
--- a/src/librustdoc/html/static/js/source-script.js
+++ b/src/librustdoc/html/static/js/source-script.js
@@ -1,5 +1,5 @@
 // From rust:
-/* global sourcesIndex */
+/* global srcIndex */
 
 // Local js definitions:
 /* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
@@ -101,9 +101,9 @@ function createSidebarToggle() {
     return sidebarToggle;
 }
 
-// This function is called from "source-files.js", generated in `html/render/write_shared.rs`.
+// This function is called from "src-files.js", generated in `html/render/write_shared.rs`.
 // eslint-disable-next-line no-unused-vars
-function createSourceSidebar() {
+function createSrcSidebar() {
     const container = document.querySelector("nav.sidebar");
 
     const sidebarToggle = createSidebarToggle();
@@ -118,9 +118,9 @@ function createSourceSidebar() {
     title.className = "title";
     title.innerText = "Files";
     sidebar.appendChild(title);
-    Object.keys(sourcesIndex).forEach(key => {
-        sourcesIndex[key][NAME_OFFSET] = key;
-        hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "", hasFoundFile);
+    Object.keys(srcIndex).forEach(key => {
+        srcIndex[key][NAME_OFFSET] = key;
+        hasFoundFile = createDirEntry(srcIndex[key], sidebar, "", hasFoundFile);
     });
 
     container.appendChild(sidebar);
@@ -133,7 +133,7 @@ function createSourceSidebar() {
 
 const lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
 
-function highlightSourceLines(match) {
+function highlightSrcLines(match) {
     if (typeof match === "undefined") {
         match = window.location.hash.match(lineNumbersRegex);
     }
@@ -172,7 +172,7 @@ function highlightSourceLines(match) {
     }
 }
 
-const handleSourceHighlight = (function() {
+const handleSrcHighlight = (function() {
     let prev_line_id = 0;
 
     const set_fragment = name => {
@@ -180,7 +180,7 @@ const handleSourceHighlight = (function() {
             y = window.scrollY;
         if (browserSupportsHistoryApi()) {
             history.replaceState(null, null, "#" + name);
-            highlightSourceLines();
+            highlightSrcLines();
         } else {
             location.replace("#" + name);
         }
@@ -221,15 +221,15 @@ const handleSourceHighlight = (function() {
 window.addEventListener("hashchange", () => {
     const match = window.location.hash.match(lineNumbersRegex);
     if (match) {
-        return highlightSourceLines(match);
+        return highlightSrcLines(match);
     }
 });
 
 onEachLazy(document.getElementsByClassName("src-line-numbers"), el => {
-    el.addEventListener("click", handleSourceHighlight);
+    el.addEventListener("click", handleSrcHighlight);
 });
 
-highlightSourceLines();
+highlightSrcLines();
 
-window.createSourceSidebar = createSourceSidebar;
+window.createSrcSidebar = createSrcSidebar;
 })();