Add test for ordering of examples, simplify with single scrape.mk file
This commit is contained in:
parent
9e4958a3e6
commit
b1616f34ef
8 changed files with 49 additions and 40 deletions
|
@ -1,21 +1,5 @@
|
|||
-include ../../run-make-fulldeps/tools.mk
|
||||
deps := ex ex2
|
||||
|
||||
OUTPUT_DIR := "$(TMPDIR)/rustdoc"
|
||||
-include ./scrape.mk
|
||||
|
||||
all: $(TMPDIR)/ex.calls $(TMPDIR)/ex2.calls
|
||||
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
|
||||
-Z unstable-options \
|
||||
--with-examples $(TMPDIR)/ex.calls \
|
||||
--with-examples $(TMPDIR)/ex2.calls
|
||||
|
||||
$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
|
||||
|
||||
$(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
|
||||
all: scrape
|
||||
|
|
20
src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
Normal file
20
src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
Normal file
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
// @has foobar/fn.ok.html '//*[@class="prev"]' ''
|
||||
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//*[@class="prev"]' ''
|
||||
// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' ''
|
||||
|
||||
pub fn ok() {}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
deps := ex1 ex2
|
||||
|
||||
-include ../rustdoc-scrape-examples-multiple/scrape.mk
|
||||
|
||||
all: scrape
|
|
@ -0,0 +1,9 @@
|
|||
fn main() {
|
||||
foobar::ok();
|
||||
|
||||
// this is a
|
||||
|
||||
// BIG
|
||||
|
||||
// item
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
foobar::ok();
|
||||
// small item
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' 'ex2'
|
||||
// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' 'ex1'
|
||||
|
||||
pub fn ok() {}
|
|
@ -1,22 +1,5 @@
|
|||
-include ../../run-make-fulldeps/tools.mk
|
||||
deps := ex
|
||||
|
||||
OUTPUT_DIR := "$(TMPDIR)/rustdoc"
|
||||
-include ../rustdoc-scrape-examples-multiple/scrape.mk
|
||||
|
||||
all:
|
||||
# 1. compile the library crate and emit an rmeta
|
||||
$(RUSTC) src/lib.rs --crate-name foobar --crate-type lib --emit=metadata
|
||||
|
||||
# 2. scrape examples from the reverse-dependency into an ex.calls file
|
||||
$(RUSTDOC) examples/ex.rs --crate-name ex --crate-type bin --output $(OUTPUT_DIR) \
|
||||
--extern foobar=$(TMPDIR)/libfoobar.rmeta \
|
||||
-Z unstable-options \
|
||||
--scrape-examples-output-path $(TMPDIR)/ex.calls \
|
||||
--scrape-examples-target-crate foobar
|
||||
|
||||
# 3. pass those examples to rustdoc when documenting the library crate
|
||||
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
|
||||
-Z unstable-options \
|
||||
--with-examples $(TMPDIR)/ex.calls
|
||||
|
||||
# 4. check that the examples were scraped successfully
|
||||
$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
|
||||
all: scrape
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue