Skip to content

Commit 4fd061c

Browse files
committed
Implement a web backend for rustdoc_ng
This large commit implements and `html` output option for rustdoc_ng. The executable has been altered to be invoked as "rustdoc_ng html <crate>" and it will dump everything into the local "doc" directory. JSON can still be generated by changing 'html' to 'json'. This also fixes a number of bugs in rustdoc_ng relating to comment stripping, along with some other various issues that I found along the way. The `make doc` command has been altered to generate the new documentation into the `doc/ng/$(CRATE)` directories.
1 parent a95604f commit 4fd061c

File tree

22 files changed

+3061
-133
lines changed

22 files changed

+3061
-133
lines changed

RELEASES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Version 0.8 (October 2013)
142142
* The runtime uses jemalloc for allocations.
143143
* Segmented stacks are temporarily disabled as part of the transition to
144144
the new runtime. Stack overflows are possible!
145+
* A new documentation backend, rustdoc_ng, is available for use
145146

146147
Version 0.7 (July 2013)
147148
-----------------------

mk/docs.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ else
213213

214214
# The rustdoc executable
215215
RUSTDOC = $(HBIN2_H_$(CFG_BUILD_TRIPLE))/rustdoc$(X_$(CFG_BUILD_TRIPLE))
216+
RUSTDOC_NG = $(HBIN2_H_$(CFG_BUILD_TRIPLE))/rustdoc_ng$(X_$(CFG_BUILD_TRIPLE))
216217

217218
# The library documenting macro
218219
# $(1) - The output directory
@@ -230,8 +231,22 @@ doc/$(1)/rust.css: rust.css
230231
DOCS += doc/$(1)/index.html
231232
endef
232233

234+
# The library documenting macro
235+
# $(1) - The output directory
236+
# $(2) - The crate file
237+
# $(3) - The crate soruce files
238+
define libdocng
239+
doc/ng/$(1)/index.html: $(2) $(3) $$(RUSTDOC_NG)
240+
@$$(call E, rustdoc_ng: $$@)
241+
$(Q)$(RUSTDOC_NG) html $(2) -o doc/ng
242+
243+
DOCS += doc/ng/$(1)/index.html
244+
endef
245+
233246
$(eval $(call libdoc,std,$(STDLIB_CRATE),$(STDLIB_INPUTS)))
234247
$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(EXTRALIB_INPUTS)))
248+
$(eval $(call libdocng,std,$(STDLIB_CRATE),$(STDLIB_INPUTS)))
249+
$(eval $(call libdocng,extra,$(EXTRALIB_CRATE),$(EXTRALIB_INPUTS)))
235250
endif
236251

237252

src/libextra/extra.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Rust extras are part of the standard Rust distribution.
2525
uuid = "122bed0b-c19b-4b82-b0b7-7ae8aead7297",
2626
url = "https://github.com/mozilla/rust/tree/master/src/libextra")];
2727

28+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
29+
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
30+
passes = "strip-hidden")];
31+
2832
#[comment = "Rust extras"];
2933
#[license = "MIT/ASL2"];
3034
#[crate_type = "lib"];

src/libstd/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#[macro_escape];
12+
#[doc(hidden)];
1213

1314
macro_rules! rterrln (
1415
($( $arg:expr),+) => ( {

src/libstd/num/int_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// FIXME(#4375): this shouldn't have to be a nested module named 'generated'
1212

1313
#[macro_escape];
14+
#[doc(hidden)];
1415

1516
macro_rules! int_module (($T:ty, $bits:expr) => (mod generated {
1617

src/libstd/num/uint_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// FIXME(#4375): this shouldn't have to be a nested module named 'generated'
1212

1313
#[macro_escape];
14+
#[doc(hidden)];
1415

1516
macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated {
1617

src/libstd/rt/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Several modules in `core` are clients of `rt`:
5454
5555
*/
5656

57-
#[doc(hidden)];
57+
// XXX: this should not be here.
58+
#[allow(missing_doc)];
5859

5960
use cell::Cell;
6061
use clone::Clone;

src/libstd/std.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ they contained the following prologue:
5757
#[license = "MIT/ASL2"];
5858
#[crate_type = "lib"];
5959

60+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
61+
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
62+
passes = "strip-hidden")];
63+
6064
// Don't link to std. We are std.
6165
#[no_std];
6266

src/libsyntax/ext/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl Context {
262262
let span = match self.names.find(&name) {
263263
Some(e) => e.span,
264264
None => {
265-
let msg = fmt!("There is no argument named `%s`", name);
265+
let msg = fmt!("there is no argument named `%s`", name);
266266
self.ecx.span_err(self.fmtsp, msg);
267267
return;
268268
}

src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
107107
}
108108

109109
if comment.starts_with("//") {
110-
// FIXME #5475:
111-
// return comment.slice(3u, comment.len()).to_owned();
112-
let r = comment.slice(3u, comment.len()); return r.to_owned();
110+
return comment.slice(3u, comment.len()).to_owned();
113111
}
114112

115113
if comment.starts_with("/*") {

0 commit comments

Comments
 (0)