about summary refs log tree commit diff
path: root/src/librustdoc/html/render/write_shared.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-23 14:58:39 +0200
committerGitHub <noreply@github.com>2021-10-23 14:58:39 +0200
commitdcf9242795fdd0be3873492fb36f77533dbf017c (patch)
tree15474e950bd74b1db9c7cd5f62681b11fa2944ff /src/librustdoc/html/render/write_shared.rs
parent55ccbd090d96ec3bb28dbcb383e65bbfa3c293ff (diff)
parentfd5d614b7708c2bbd0a7c796af3c3b63f31a19ac (diff)
downloadrust-dcf9242795fdd0be3873492fb36f77533dbf017c.tar.gz
rust-dcf9242795fdd0be3873492fb36f77533dbf017c.zip
Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514
Scrape code examples from examples/ directory for Rustdoc

Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123

Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525

Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
Diffstat (limited to 'src/librustdoc/html/render/write_shared.rs')
-rw-r--r--src/librustdoc/html/render/write_shared.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs
index e4c2556118a..31aaf46d7d5 100644
--- a/src/librustdoc/html/render/write_shared.rs
+++ b/src/librustdoc/html/render/write_shared.rs
@@ -304,6 +304,15 @@ pub(super) fn write_shared(
         )?;
     }
 
+    if cx.shared.layout.scrape_examples_extension {
+        cx.write_minify(
+            SharedResource::InvocationSpecific { basename: "scrape-examples.js" },
+            static_files::SCRAPE_EXAMPLES_JS,
+            options.enable_minification,
+            &options.emit,
+        )?;
+    }
+
     if let Some(ref css) = cx.shared.layout.css_file_extension {
         let buffer = try_err!(fs::read_to_string(css), css);
         // This varies based on the invocation, so it can't go through the write_minify wrapper.