Skip to content

Add the rustdoc_ng binary to the makefile rules #9241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
$$(HBIN$(1)_H_$(3))/rustdoc_ng$$(X_$(3)) \
$$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
$$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
Expand Down
2 changes: 2 additions & 0 deletions mk/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ clean$(1)_H_$(2):
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustpkg$(X_$(2))
$(Q)rm -f $$(HBIN$(1)_H_$(2))/serializer$(X_$(2))
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc$(X_$(2))
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc_ng$(X_$(2))
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rusti$(X_$(2))
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rust$(X_$(2))
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTPKG_$(2))
Expand Down Expand Up @@ -105,6 +106,7 @@ clean$(1)_T_$(2)_H_$(3):
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$(X_$(2))
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/serializer$(X_$(2))
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc$(X_$(2))
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc_ng$(X_$(2))
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rusti$(X_$(2))
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rust$(X_$(2))
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2))
Expand Down
1 change: 1 addition & 0 deletions mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ PKG_FILES := \
libsyntax \
rt \
librustdoc \
rustdoc_ng \
rustllvm \
snapshots.txt \
test) \
Expand Down
3 changes: 3 additions & 0 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
$(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X_$(CFG_BUILD_TRIPLE)))
$(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD_TRIPLE)))
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD_TRIPLE)))
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc_ng$(X_$(CFG_BUILD_TRIPLE)))
$(Q)$(call INSTALL,$(HB2),$(PHB),rusti$(X_$(CFG_BUILD_TRIPLE)))
$(Q)$(call INSTALL,$(HB2),$(PHB),rust$(X_$(CFG_BUILD_TRIPLE)))
$(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD_TRIPLE)))
Expand Down Expand Up @@ -171,6 +172,7 @@ uninstall:
$(Q)rm -f $(PHB)/rusti$(X_$(CFG_BUILD_TRIPLE))
$(Q)rm -f $(PHB)/rust$(X_$(CFG_BUILD_TRIPLE))
$(Q)rm -f $(PHB)/rustdoc$(X_$(CFG_BUILD_TRIPLE))
$(Q)rm -f $(PHB)/rustdoc_ng$(X_$(CFG_BUILD_TRIPLE))
$(Q)rm -f $(PHL)/$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE))
$(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE))
$(Q)for i in \
Expand All @@ -180,6 +182,7 @@ uninstall:
$(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE))) \
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE))) \
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE))) \
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOCNG_GLOB_$(CFG_BUILD_TRIPLE))) \
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTI_GLOB_$(CFG_BUILD_TRIPLE))) \
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUST_GLOB_$(CFG_BUILD_TRIPLE))) \
; \
Expand Down
10 changes: 9 additions & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# The names of crates that must be tested
TEST_TARGET_CRATES = std extra
TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc syntax
TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc rustdocng syntax
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)

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

$(3)/stage$(1)/test/rustdocngtest-$(2)$$(X_$(2)): \
$$(RUSTDOCNG_LIB) $$(RUSTDOCNG_INPUTS) \
$$(SREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test

endef

$(foreach host,$(CFG_HOST_TRIPLES), \
Expand Down
10 changes: 9 additions & 1 deletion mk/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)

# rustdoc_ng, the next generation documentation tool

RUSTDOCNG_LIB := $(S)src/rustdoc_ng/lib.rs
RUSTDOCNG_LIB := $(S)src/rustdoc_ng/rustdoc_ng.rs
RUSTDOCNG_INPUTS := $(wildcard $(S)src/rustdoc_ng/*.rs)

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

$$(HBIN$(2)_H_$(4))/rustdoc_ng$$(X_$(4)): \
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc_ng$$(X_$(4)) \
$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTDOCNG_$(4)) \
$$(HSREQ$(2)_H_$(4)) \
| $$(HBIN$(2)_H_$(4))/
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTI_$(4)): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)) \
$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTC_$(4)) \
Expand Down
3 changes: 3 additions & 0 deletions src/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ extern mod this(name = "rust");
#[cfg(rustc)]
extern mod this(name = "rustc");

#[cfg(rustdoc_ng)]
extern mod this(name = "rustdoc_ng");

fn main() { this::main() }
24 changes: 0 additions & 24 deletions src/rustdoc_ng/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,27 +1043,3 @@ fn resolve_type(t: &Type) -> Type {
ResolvedPath {path: path.clone(), typarams: tpbs.clone(), id: def_id.node}
}
}

#[cfg(test)]
mod tests {
use super::NameValue;

#[test]
fn test_doc_collapsing() {
assert_eq!(collapse_docs(~"// Foo\n//Bar\n // Baz\n"), ~"Foo\nBar\nBaz");
assert_eq!(collapse_docs(~"* Foo\n * Bar\n *Baz\n"), ~"Foo\n Bar\nBaz");
assert_eq!(collapse_docs(~"* Short desc\n *\n * Bar\n *Baz\n"), ~"Short desc\n\nBar\nBaz");
assert_eq!(collapse_docs(~" * Foo"), ~"Foo");
assert_eq!(collapse_docs(~"\n *\n *\n * Foo"), ~"Foo");
}

fn collapse_docs(input: ~str) -> ~str {
let attrs = ~[NameValue(~"doc", input)];
let attrs_clean = super::collapse_docs(attrs);

match attrs_clean[0] {
NameValue(~"doc", s) => s,
_ => (fail!("dude where's my doc?"))
}
}
}
37 changes: 0 additions & 37 deletions src/rustdoc_ng/lib.rs

This file was deleted.

37 changes: 28 additions & 9 deletions src/rustdoc_ng/main.rs → src/rustdoc_ng/rustdoc_ng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,41 @@
// except according to those terms.

#[link(name = "rustdoc_ng",
vers = "0.1.0",
uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6")];
vers = "0.8-pre",
uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6",
url = "https://github.com/mozilla/rust/tree/master/src/rustdoc_ng")];

#[desc = "rustdoc, the Rust documentation extractor"];
#[license = "MIT/ASL2"];
#[crate_type = "bin"];
#[crate_type = "lib"];

extern mod syntax;
extern mod rustc;
extern mod extra;
extern mod rustdoc_ng;

use rustdoc_ng::*;
use extra::serialize::Encodable;
use std::cell::Cell;

use extra::serialize::Encodable;
pub mod core;
pub mod doctree;
pub mod clean;
pub mod visit_ast;
pub mod fold;
pub mod plugins;
pub mod passes;

pub static SCHEMA_VERSION: &'static str = "0.8.0";

local_data_key!(pub ctxtkey: @core::DocContext)

pub fn main() {
main_args(std::os::args());
}

fn main() {
pub fn main_args(args: &[~str]) {
use extra::getopts::*;
use extra::getopts::groups::*;

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

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

let crate = std::task::try(|| {let cr = cr.take(); core::run_core(libs.take(), &cr)}).unwrap();
let crate = do std::task::try {
let cr = cr.take();
core::run_core(libs.take(), &cr)
}.unwrap();

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