Skip to content

Commit b1616f3

Browse files
committed
Add test for ordering of examples, simplify with single scrape.mk file
1 parent 9e4958a commit b1616f3

File tree

8 files changed

+49
-40
lines changed

8 files changed

+49
-40
lines changed
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
-include ../../run-make-fulldeps/tools.mk
1+
deps := ex ex2
22

3-
OUTPUT_DIR := "$(TMPDIR)/rustdoc"
3+
-include ./scrape.mk
44

5-
all: $(TMPDIR)/ex.calls $(TMPDIR)/ex2.calls
6-
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
7-
-Z unstable-options \
8-
--with-examples $(TMPDIR)/ex.calls \
9-
--with-examples $(TMPDIR)/ex2.calls
10-
11-
$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
12-
13-
$(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
14-
$(RUSTDOC) examples/$*.rs --crate-name $* --crate-type bin --output $(OUTPUT_DIR) \
15-
--extern foobar=$(TMPDIR)/libfoobar.rmeta \
16-
-Z unstable-options \
17-
--scrape-examples-output-path $@ \
18-
--scrape-examples-target-crate foobar
19-
20-
$(TMPDIR)/lib%.rmeta: src/lib.rs
21-
$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata
5+
all: scrape
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-include ../../run-make-fulldeps/tools.mk
2+
3+
OUTPUT_DIR := "$(TMPDIR)/rustdoc"
4+
5+
$(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
6+
$(RUSTDOC) examples/$*.rs --crate-name $* --crate-type bin --output $(OUTPUT_DIR) \
7+
--extern foobar=$(TMPDIR)/libfoobar.rmeta \
8+
-Z unstable-options \
9+
--scrape-examples-output-path $@ \
10+
--scrape-examples-target-crate foobar
11+
12+
$(TMPDIR)/lib%.rmeta: src/lib.rs
13+
$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata
14+
15+
scrape: $(foreach d,$(deps),$(TMPDIR)/$(d).calls)
16+
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
17+
-Z unstable-options \
18+
$(foreach d,$(deps),--with-examples $(TMPDIR)/$(d).calls)
19+
20+
$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @has foobar/fn.ok.html '//*[@class="prev"]' ''
1+
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//*[@class="prev"]' ''
22
// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' ''
33

44
pub fn ok() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
deps := ex1 ex2
2+
3+
-include ../rustdoc-scrape-examples-multiple/scrape.mk
4+
5+
all: scrape
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
foobar::ok();
3+
4+
// this is a
5+
6+
// BIG
7+
8+
// item
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
foobar::ok();
3+
// small item
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' 'ex2'
2+
// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' 'ex1'
3+
4+
pub fn ok() {}
Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
-include ../../run-make-fulldeps/tools.mk
1+
deps := ex
22

3-
OUTPUT_DIR := "$(TMPDIR)/rustdoc"
3+
-include ../rustdoc-scrape-examples-multiple/scrape.mk
44

5-
all:
6-
# 1. compile the library crate and emit an rmeta
7-
$(RUSTC) src/lib.rs --crate-name foobar --crate-type lib --emit=metadata
8-
9-
# 2. scrape examples from the reverse-dependency into an ex.calls file
10-
$(RUSTDOC) examples/ex.rs --crate-name ex --crate-type bin --output $(OUTPUT_DIR) \
11-
--extern foobar=$(TMPDIR)/libfoobar.rmeta \
12-
-Z unstable-options \
13-
--scrape-examples-output-path $(TMPDIR)/ex.calls \
14-
--scrape-examples-target-crate foobar
15-
16-
# 3. pass those examples to rustdoc when documenting the library crate
17-
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
18-
-Z unstable-options \
19-
--with-examples $(TMPDIR)/ex.calls
20-
21-
# 4. check that the examples were scraped successfully
22-
$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
5+
all: scrape

0 commit comments

Comments
 (0)