about summary refs log tree commit diff
path: root/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
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/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
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/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk')
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk b/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
new file mode 100644
index 00000000000..1fa1fae1a0b
--- /dev/null
+++ b/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
@@ -0,0 +1,20 @@
+-include ../../run-make-fulldeps/tools.mk
+
+OUTPUT_DIR := "$(TMPDIR)/rustdoc"
+
+$(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
+	$(RUSTDOC) examples/$*.rs --crate-name $* --crate-type bin --output $(OUTPUT_DIR) \
+	  --extern foobar=$(TMPDIR)/libfoobar.rmeta \
+		-Z unstable-options \
+		--scrape-examples-output-path $@ \
+		--scrape-examples-target-crate foobar
+
+$(TMPDIR)/lib%.rmeta: src/lib.rs
+	$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata
+
+scrape: $(foreach d,$(deps),$(TMPDIR)/$(d).calls)
+	$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
+		-Z unstable-options \
+		$(foreach d,$(deps),--with-examples $(TMPDIR)/$(d).calls)
+
+	$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs