Skip to content

Commit c897ac0

Browse files
committed
Auto merge of #24177 - alexcrichton:rustdoc, r=aturon
This commit series starts out with more official test harness support for rustdoc tests, and then each commit afterwards adds a test (where appropriate). Each commit should also test and finish independently of all others (they're all pretty separable). I've uploaded a [copy of the documentation](http://people.mozilla.org/~acrichton/doc/std/) generated after all these commits were applied, and a double check on issues being closed would be greatly appreciated! I'll also browse the docs a bit and make sure nothing regressed too horribly.
2 parents 9539627 + 445faca commit c897ac0

File tree

126 files changed

+2128
-912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2128
-912
lines changed

configure

+1
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ do
11281128
make_dir $h/test/debuginfo-gdb
11291129
make_dir $h/test/debuginfo-lldb
11301130
make_dir $h/test/codegen
1131+
make_dir $h/test/rustdoc
11311132
done
11321133

11331134
# Configure submodules

mk/crates.mk

+3-32
Original file line numberDiff line numberDiff line change
@@ -118,42 +118,13 @@ ONLY_RLIB_collections := 1
118118
ONLY_RLIB_unicode := 1
119119
ONLY_RLIB_rustc_bitflags := 1
120120

121+
# Documented-by-default crates
122+
DOC_CRATES := std alloc collections core libc unicode
123+
121124
################################################################################
122125
# You should not need to edit below this line
123126
################################################################################
124127

125-
# On channels where the only usable crate is std, only build documentation for
126-
# std. This keeps distributions small and doesn't clutter up the API docs with
127-
# confusing internal details from the crates behind the facade.
128-
#
129-
# (Disabled while cmr figures out how to change rustdoc to make reexports work
130-
# slightly nicer. Otherwise, all cross-crate links to Vec will go to
131-
# libcollections, breaking them, and [src] links for anything reexported will
132-
# not work.)
133-
134-
#ifeq ($(CFG_RELEASE_CHANNEL),stable)
135-
#DOC_CRATES := std
136-
#else
137-
#ifeq ($(CFG_RELEASE_CHANNEL),beta)
138-
#DOC_CRATES := std
139-
#else
140-
DOC_CRATES := $(filter-out rustc, \
141-
$(filter-out rustc_trans, \
142-
$(filter-out rustc_typeck, \
143-
$(filter-out rustc_borrowck, \
144-
$(filter-out rustc_resolve, \
145-
$(filter-out rustc_driver, \
146-
$(filter-out rustc_privacy, \
147-
$(filter-out rustc_lint, \
148-
$(filter-out log, \
149-
$(filter-out getopts, \
150-
$(filter-out syntax, $(CRATES))))))))))))
151-
#endif
152-
#endif
153-
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
154-
rustc_typeck rustc_driver syntax rustc_privacy \
155-
rustc_lint
156-
157128
# This macro creates some simple definitions for each crate being built, just
158129
# some munging of all of the parameters above.
159130
#

mk/docs.mk

+6-4
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,20 @@ endif
250250
doc/$(1)/:
251251
$$(Q)mkdir -p $$@
252252

253-
$(2) += doc/$(1)/index.html
254253
doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET)
255254
doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/
256255
@$$(call E, rustdoc: $$@)
257256
$$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(CFG_BUILD)) \
258-
$$(RUSTDOC) --cfg dox --cfg stage2 $$<
257+
$$(RUSTDOC) --cfg dox --cfg stage2 $$(RUSTFLAGS_$(1)) $$<
259258
endef
260259

261-
$(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS)))
260+
$(foreach crate,$(CRATES),$(eval $(call DEF_LIB_DOC,$(crate))))
262261

262+
COMPILER_DOC_TARGETS := $(CRATES:%=doc/%/index.html)
263263
ifdef CFG_COMPILER_DOCS
264-
$(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPILER_DOC_TARGETS)))
264+
DOC_TARGETS += $(COMPILER_DOC_TARGETS)
265+
else
266+
DOC_TARGETS += $(DOC_CRATES:%=doc/%/index.html)
265267
endif
266268

267269
ifdef CFG_DISABLE_DOCS

mk/tests.mk

+20-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ $(eval $(call RUST_CRATE,coretest))
2222
DEPS_collectionstest :=
2323
$(eval $(call RUST_CRATE,collectionstest))
2424

25-
TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) collectionstest coretest
25+
TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) \
26+
collectionstest coretest
2627
TEST_DOC_CRATES = $(DOC_CRATES)
27-
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans rustc_lint,\
28+
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve \
29+
rustc_trans rustc_lint,\
2830
$(HOST_CRATES))
2931
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
3032

@@ -304,6 +306,7 @@ check-stage$(1)-T-$(2)-H-$(3)-exec: \
304306
check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
305307
check-stage$(1)-T-$(2)-H-$(3)-cfail-full-exec \
306308
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec \
309+
check-stage$(1)-T-$(2)-H-$(3)-rustdocck-exec \
307310
check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
308311
check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec \
309312
check-stage$(1)-T-$(2)-H-$(3)-bench-exec \
@@ -471,6 +474,7 @@ DEBUGINFO_GDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
471474
DEBUGINFO_LLDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
472475
CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
473476
CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
477+
RUSTDOCCK_RS := $(wildcard $(S)src/test/rustdoc/*.rs)
474478

475479
# perf tests are the same as bench tests only they run under
476480
# a performance monitor.
@@ -489,6 +493,7 @@ PRETTY_TESTS := $(PRETTY_RS)
489493
DEBUGINFO_GDB_TESTS := $(DEBUGINFO_GDB_RS)
490494
DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
491495
CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
496+
RUSTDOCCK_TESTS := $(RUSTDOCCK_RS)
492497

493498
CTEST_SRC_BASE_rpass = run-pass
494499
CTEST_BUILD_BASE_rpass = run-pass
@@ -550,6 +555,11 @@ CTEST_BUILD_BASE_codegen = codegen
550555
CTEST_MODE_codegen = codegen
551556
CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)
552557

558+
CTEST_SRC_BASE_rustdocck = rustdoc
559+
CTEST_BUILD_BASE_rustdocck = rustdoc
560+
CTEST_MODE_rustdocck = rustdoc
561+
CTEST_RUNTOOL_rustdocck = $(CTEST_RUNTOOL)
562+
553563
# CTEST_DISABLE_$(TEST_GROUP), if set, will cause the test group to be
554564
# disabled and the associated message to be printed as a warning
555565
# during attempts to run those tests.
@@ -618,12 +628,14 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
618628
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
619629
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
620630
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
631+
--rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
621632
--clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
622633
--llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
623634
--aux-base $$(S)src/test/auxiliary/ \
624635
--stage-id stage$(1)-$(2) \
625636
--target $(2) \
626637
--host $(3) \
638+
--python $$(CFG_PYTHON) \
627639
--gdb-version="$(CFG_GDB_VERSION)" \
628640
--lldb-version="$(CFG_LLDB_VERSION)" \
629641
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
@@ -660,6 +672,9 @@ CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
660672
$(S)src/etc/lldb_batchmode.py \
661673
$(S)src/etc/lldb_rust_formatters.py
662674
CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
675+
CTEST_DEPS_rustdocck_$(1)-T-$(2)-H-$(3) = $$(RUSTDOCCK_TESTS) \
676+
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
677+
$(S)src/etc/htmldocck.py
663678

664679
endef
665680

@@ -722,7 +737,8 @@ endif
722737

723738
endef
724739

725-
CTEST_NAMES = rpass rpass-valgrind rpass-full cfail-full rfail cfail pfail bench perf debuginfo-gdb debuginfo-lldb codegen
740+
CTEST_NAMES = rpass rpass-valgrind rpass-full cfail-full rfail cfail pfail \
741+
bench perf debuginfo-gdb debuginfo-lldb codegen rustdocck
726742

727743
$(foreach host,$(CFG_HOST), \
728744
$(eval $(foreach target,$(CFG_TARGET), \
@@ -890,6 +906,7 @@ TEST_GROUPS = \
890906
bench \
891907
perf \
892908
rmake \
909+
rustdocck \
893910
debuginfo-gdb \
894911
debuginfo-lldb \
895912
codegen \

src/compiletest/common.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub enum Mode {
2323
Pretty,
2424
DebugInfoGdb,
2525
DebugInfoLldb,
26-
Codegen
26+
Codegen,
27+
Rustdoc,
2728
}
2829

2930
impl FromStr for Mode {
@@ -39,6 +40,7 @@ impl FromStr for Mode {
3940
"debuginfo-lldb" => Ok(DebugInfoLldb),
4041
"debuginfo-gdb" => Ok(DebugInfoGdb),
4142
"codegen" => Ok(Codegen),
43+
"rustdoc" => Ok(Rustdoc),
4244
_ => Err(()),
4345
}
4446
}
@@ -56,6 +58,7 @@ impl fmt::Display for Mode {
5658
DebugInfoGdb => "debuginfo-gdb",
5759
DebugInfoLldb => "debuginfo-lldb",
5860
Codegen => "codegen",
61+
Rustdoc => "rustdoc",
5962
}, f)
6063
}
6164
}
@@ -71,6 +74,12 @@ pub struct Config {
7174
// The rustc executable
7275
pub rustc_path: PathBuf,
7376

77+
// The rustdoc executable
78+
pub rustdoc_path: PathBuf,
79+
80+
// The python executable
81+
pub python: String,
82+
7483
// The clang executable
7584
pub clang_path: Option<PathBuf>,
7685

src/compiletest/compiletest.rs

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
6060
vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
6161
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
6262
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
63+
reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH"),
64+
reqopt("", "python", "path to python to use for doc tests", "PATH"),
6365
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
6466
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
6567
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
@@ -128,6 +130,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
128130
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
129131
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
130132
rustc_path: opt_path(matches, "rustc-path"),
133+
rustdoc_path: opt_path(matches, "rustdoc-path"),
134+
python: matches.opt_str("python").unwrap(),
131135
clang_path: matches.opt_str("clang-path").map(|s| PathBuf::from(&s)),
132136
valgrind_path: matches.opt_str("valgrind-path"),
133137
force_valgrind: matches.opt_present("force-valgrind"),
@@ -168,6 +172,7 @@ pub fn log_config(config: &Config) {
168172
logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path));
169173
logv(c, format!("run_lib_path: {:?}", config.run_lib_path));
170174
logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
175+
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path.display()));
171176
logv(c, format!("src_base: {:?}", config.src_base.display()));
172177
logv(c, format!("build_base: {:?}", config.build_base.display()));
173178
logv(c, format!("stage_id: {}", config.stage_id));

0 commit comments

Comments
 (0)