Skip to content

Commit 876cb76

Browse files
committed
Add the rustdoc_ng binary to the makefile rules
Now rustdoc_ng will be built as both a binary and a library (using the same rules as all the other binaries that rust has). Furthermore, this will also start building rustdoc_ng unit tests (and running them).
1 parent bc89ade commit 876cb76

File tree

10 files changed

+56
-72
lines changed

10 files changed

+56
-72
lines changed

Makefile.in

+1
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
442442
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
443443
$$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
444444
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
445+
$$(HBIN$(1)_H_$(3))/rustdoc_ng$$(X_$(3)) \
445446
$$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
446447
$$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
447448
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \

mk/clean.mk

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ clean$(1)_H_$(2):
6868
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustpkg$(X_$(2))
6969
$(Q)rm -f $$(HBIN$(1)_H_$(2))/serializer$(X_$(2))
7070
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc$(X_$(2))
71+
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc_ng$(X_$(2))
7172
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rusti$(X_$(2))
7273
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rust$(X_$(2))
7374
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTPKG_$(2))
@@ -105,6 +106,7 @@ clean$(1)_T_$(2)_H_$(3):
105106
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$(X_$(2))
106107
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/serializer$(X_$(2))
107108
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc$(X_$(2))
109+
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc_ng$(X_$(2))
108110
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rusti$(X_$(2))
109111
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rust$(X_$(2))
110112
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2))

mk/dist.mk

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ PKG_FILES := \
3939
libsyntax \
4040
rt \
4141
librustdoc \
42+
rustdoc_ng \
4243
rustllvm \
4344
snapshots.txt \
4445
test) \

mk/install.mk

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
140140
$(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X_$(CFG_BUILD_TRIPLE)))
141141
$(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD_TRIPLE)))
142142
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD_TRIPLE)))
143+
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc_ng$(X_$(CFG_BUILD_TRIPLE)))
143144
$(Q)$(call INSTALL,$(HB2),$(PHB),rusti$(X_$(CFG_BUILD_TRIPLE)))
144145
$(Q)$(call INSTALL,$(HB2),$(PHB),rust$(X_$(CFG_BUILD_TRIPLE)))
145146
$(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD_TRIPLE)))
@@ -171,6 +172,7 @@ uninstall:
171172
$(Q)rm -f $(PHB)/rusti$(X_$(CFG_BUILD_TRIPLE))
172173
$(Q)rm -f $(PHB)/rust$(X_$(CFG_BUILD_TRIPLE))
173174
$(Q)rm -f $(PHB)/rustdoc$(X_$(CFG_BUILD_TRIPLE))
175+
$(Q)rm -f $(PHB)/rustdoc_ng$(X_$(CFG_BUILD_TRIPLE))
174176
$(Q)rm -f $(PHL)/$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE))
175177
$(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE))
176178
$(Q)for i in \
@@ -180,6 +182,7 @@ uninstall:
180182
$(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE))) \
181183
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE))) \
182184
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE))) \
185+
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOCNG_GLOB_$(CFG_BUILD_TRIPLE))) \
183186
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTI_GLOB_$(CFG_BUILD_TRIPLE))) \
184187
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUST_GLOB_$(CFG_BUILD_TRIPLE))) \
185188
; \

mk/tests.mk

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# The names of crates that must be tested
1717
TEST_TARGET_CRATES = std extra
18-
TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc syntax
18+
TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc rustdocng syntax
1919
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
2020

2121
# Markdown files under doc/ that should have their code extracted and run
@@ -393,6 +393,14 @@ $(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)): \
393393
@$$(call E, compile_and_link: $$@)
394394
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
395395

396+
$(3)/stage$(1)/test/rustdocngtest-$(2)$$(X_$(2)): \
397+
$$(RUSTDOCNG_LIB) $$(RUSTDOCNG_INPUTS) \
398+
$$(SREQ$(1)_T_$(2)_H_$(3)) \
399+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
400+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
401+
@$$(call E, compile_and_link: $$@)
402+
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
403+
396404
endef
397405

398406
$(foreach host,$(CFG_HOST_TRIPLES), \

mk/tools.mk

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)
2525

2626
# rustdoc_ng, the next generation documentation tool
2727

28-
RUSTDOCNG_LIB := $(S)src/rustdoc_ng/lib.rs
28+
RUSTDOCNG_LIB := $(S)src/rustdoc_ng/rustdoc_ng.rs
2929
RUSTDOCNG_INPUTS := $(wildcard $(S)src/rustdoc_ng/*.rs)
3030

3131
# Rusti, the JIT REPL
@@ -208,6 +208,14 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTDOCNG_$(4)): \
208208
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTDOCNG_DSYM_GLOB_$(4))) \
209209
$$(HLIB$(2)_H_$(4))
210210

211+
$$(HBIN$(2)_H_$(4))/rustdoc_ng$$(X_$(4)): \
212+
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc_ng$$(X_$(4)) \
213+
$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTDOCNG_$(4)) \
214+
$$(HSREQ$(2)_H_$(4)) \
215+
| $$(HBIN$(2)_H_$(4))/
216+
@$$(call E, cp: $$@)
217+
$$(Q)cp $$< $$@
218+
211219
$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTI_$(4)): \
212220
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)) \
213221
$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTC_$(4)) \

src/driver/driver.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ extern mod this(name = "rust");
2323
#[cfg(rustc)]
2424
extern mod this(name = "rustc");
2525

26+
#[cfg(rustdoc_ng)]
27+
extern mod this(name = "rustdoc_ng");
28+
2629
fn main() { this::main() }

src/rustdoc_ng/clean.rs

-24
Original file line numberDiff line numberDiff line change
@@ -1043,27 +1043,3 @@ fn resolve_type(t: &Type) -> Type {
10431043
ResolvedPath {path: path.clone(), typarams: tpbs.clone(), id: def_id.node}
10441044
}
10451045
}
1046-
1047-
#[cfg(test)]
1048-
mod tests {
1049-
use super::NameValue;
1050-
1051-
#[test]
1052-
fn test_doc_collapsing() {
1053-
assert_eq!(collapse_docs(~"// Foo\n//Bar\n // Baz\n"), ~"Foo\nBar\nBaz");
1054-
assert_eq!(collapse_docs(~"* Foo\n * Bar\n *Baz\n"), ~"Foo\n Bar\nBaz");
1055-
assert_eq!(collapse_docs(~"* Short desc\n *\n * Bar\n *Baz\n"), ~"Short desc\n\nBar\nBaz");
1056-
assert_eq!(collapse_docs(~" * Foo"), ~"Foo");
1057-
assert_eq!(collapse_docs(~"\n *\n *\n * Foo"), ~"Foo");
1058-
}
1059-
1060-
fn collapse_docs(input: ~str) -> ~str {
1061-
let attrs = ~[NameValue(~"doc", input)];
1062-
let attrs_clean = super::collapse_docs(attrs);
1063-
1064-
match attrs_clean[0] {
1065-
NameValue(~"doc", s) => s,
1066-
_ => (fail!("dude where's my doc?"))
1067-
}
1068-
}
1069-
}

src/rustdoc_ng/lib.rs

-37
This file was deleted.

src/rustdoc_ng/main.rs renamed to src/rustdoc_ng/rustdoc_ng.rs

+28-9
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,41 @@
99
// except according to those terms.
1010

1111
#[link(name = "rustdoc_ng",
12-
vers = "0.1.0",
13-
uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6")];
12+
vers = "0.8-pre",
13+
uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6",
14+
url = "https://github.com/mozilla/rust/tree/master/src/rustdoc_ng")];
15+
1416
#[desc = "rustdoc, the Rust documentation extractor"];
1517
#[license = "MIT/ASL2"];
16-
#[crate_type = "bin"];
18+
#[crate_type = "lib"];
1719

20+
extern mod syntax;
21+
extern mod rustc;
1822
extern mod extra;
19-
extern mod rustdoc_ng;
2023

21-
use rustdoc_ng::*;
24+
use extra::serialize::Encodable;
2225
use std::cell::Cell;
2326

24-
use extra::serialize::Encodable;
27+
pub mod core;
28+
pub mod doctree;
29+
pub mod clean;
30+
pub mod visit_ast;
31+
pub mod fold;
32+
pub mod plugins;
33+
pub mod passes;
34+
35+
pub static SCHEMA_VERSION: &'static str = "0.8.0";
36+
37+
local_data_key!(pub ctxtkey: @core::DocContext)
38+
39+
pub fn main() {
40+
main_args(std::os::args());
41+
}
2542

26-
fn main() {
43+
pub fn main_args(args: &[~str]) {
2744
use extra::getopts::*;
2845
use extra::getopts::groups::*;
2946

30-
let args = std::os::args();
3147
let opts = ~[
3248
optmulti("L", "library-path", "directory to add to crate search path", "DIR"),
3349
optmulti("p", "plugin", "plugin to load and run", "NAME"),
@@ -62,7 +78,10 @@ fn main() {
6278

6379
let cr = Cell::new(Path(matches.free[0]));
6480

65-
let crate = std::task::try(|| {let cr = cr.take(); core::run_core(libs.take(), &cr)}).unwrap();
81+
let crate = do std::task::try {
82+
let cr = cr.take();
83+
core::run_core(libs.take(), &cr)
84+
}.unwrap();
6685

6786
// { "schema": version, "crate": { parsed crate ... }, "plugins": { output of plugins ... }}
6887
let mut json = ~extra::treemap::TreeMap::new();

0 commit comments

Comments
 (0)