about summary refs log tree commit diff
path: root/src/tools/rustdoc-js/tester.js
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-12-22 23:12:23 +0000
committerbors <bors@rust-lang.org>2018-12-22 23:12:23 +0000
commit16329b0ad3610b47a97a051df88405b1587238bd (patch)
tree7c92ea6763b3ad9db4d9e87680fab9ca929553c4 /src/tools/rustdoc-js/tester.js
parent2d3e909e4e68259e15ca2908ff9e854f0a68bbec (diff)
parent628c6d89e16cc00ecccb83129f30eaa9d89af9ff (diff)
downloadrust-16329b0ad3610b47a97a051df88405b1587238bd.tar.gz
rust-16329b0ad3610b47a97a051df88405b1587238bd.zip
Auto merge of #57063 - kennytm:rollup, r=kennytm
Rollup of 25 pull requests

Successful merges:

 - #56802 (Add DoubleEndedIterator::nth_back)
 - #56909 (static eval: Do not ICE on layout size overflow)
 - #56914 (Ignore ui/target-feature-gate on sparc, sparc64, powerpc, powerpc64 and powerpc64le)
 - #56919 (Remove a wrong multiplier on relocation offset computation)
 - #56933 (Add --progress to git submodule commands in x.py)
 - #56936 (rename div_euc -> div_euclid, and mod_euc -> rem_euclid)
 - #56941 (deny intra-doc link resolution failures in libstd)
 - #56945 (Fix rustdoc-js tests)
 - #56967 (Replace current crate's searchIndex when regenerating)
 - #56970 (Mem uninit doc ptr drop)
 - #56973 (make basic CTFE tracing available on release builds)
 - #56979 (Adding unwinding support for x86_64_fortanix_unknown_sgx target.)
 - #56981 (miri: allocation is infallible)
 - #56984 (A few tweaks to dropck_outlives)
 - #56989 (Fix compiletest `trim` deprecation warnings)
 - #56992 (suggest similar lint names for unknown lints)
 - #57002 (Stabilize Vec(Deque)::resize_with)
 - #57011 (rustdoc: add new CLI flag to load static files from a different location)
 - #57027 (Optimize away a move)
 - #57034 (Inline tweaks)
 - #57039 (Update migrate warning wording.)
 - #57040 (Fix feature gate to point to 1.32.0 for `path_from_str`)
 - #57049 (Stabilize #[repr(packed(N))])
 - #57050 (Fixed typo in HashMap documentation)
 - #57052 (Fix stabilization version numbers (exhaustive_integer_patterns + macro_literal_matcher))
Diffstat (limited to 'src/tools/rustdoc-js/tester.js')
-rw-r--r--src/tools/rustdoc-js/tester.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js
index f7c30df9f3e..65ed86742e7 100644
--- a/src/tools/rustdoc-js/tester.js
+++ b/src/tools/rustdoc-js/tester.js
@@ -26,7 +26,10 @@ function getNextStep(content, pos, stop) {
     return pos;
 }
 
-// Stupid function extractor based on indent.
+// Stupid function extractor based on indent. Doesn't support block
+// comments. If someone puts a ' or an " in a block comment this
+// will blow up. Template strings are not tested and might also be
+// broken.
 function extractFunction(content, functionName) {
     var indent = 0;
     var splitter = "function " + functionName + "(";
@@ -51,7 +54,14 @@ function extractFunction(content, functionName) {
             continue;
         }
         while (pos < content.length) {
-            if (content[pos] === '"' || content[pos] === "'") {
+            // Eat single-line comments
+            if (content[pos] === '/' && pos > 0 && content[pos-1] === '/') {
+                do {
+                    pos += 1;
+                } while (pos < content.length && content[pos] !== '\n');
+
+            // Eat quoted strings
+            } else if (content[pos] === '"' || content[pos] === "'" || content[pos] === "`") {
                 var stop = content[pos];
                 var is_escaped = false;
                 do {
@@ -62,6 +72,8 @@ function extractFunction(content, functionName) {
                     }
                 } while (pos < content.length &&
                          (content[pos] !== stop || content[pos - 1] === '\\'));
+
+            // Otherwise, check for indent
             } else if (content[pos] === '{') {
                 indent += 1;
             } else if (content[pos] === '}') {