rustdoc: Camel case
This commit is contained in:
parent
e86e8c16e6
commit
b3b1e62750
|
@ -21,53 +21,53 @@ use rustc::back::link;
|
|||
use rustc::metadata::filesearch;
|
||||
use rustc::front;
|
||||
|
||||
export ctxt;
|
||||
export ctxt_handler;
|
||||
export srv;
|
||||
export Ctxt;
|
||||
export CtxtHandler;
|
||||
export Srv;
|
||||
export from_str;
|
||||
export from_file;
|
||||
export exec;
|
||||
|
||||
type ctxt = {
|
||||
type Ctxt = {
|
||||
ast: @ast::crate,
|
||||
ast_map: ast_map::map
|
||||
};
|
||||
|
||||
type srv_owner<T> = fn(srv: srv) -> T;
|
||||
type ctxt_handler<T> = fn~(ctxt: ctxt) -> T;
|
||||
type parser = fn~(session, ~str) -> @ast::crate;
|
||||
type SrvOwner<T> = fn(srv: Srv) -> T;
|
||||
type CtxtHandler<T> = fn~(ctxt: Ctxt) -> T;
|
||||
type Parser = fn~(session, ~str) -> @ast::crate;
|
||||
|
||||
enum msg {
|
||||
handle_request(fn~(ctxt)),
|
||||
exit
|
||||
enum Msg {
|
||||
HandleRequest(fn~(Ctxt)),
|
||||
Exit
|
||||
}
|
||||
|
||||
enum srv = {
|
||||
ch: comm::Chan<msg>
|
||||
enum Srv = {
|
||||
ch: comm::Chan<Msg>
|
||||
};
|
||||
|
||||
fn from_str<T>(source: ~str, owner: srv_owner<T>) -> T {
|
||||
fn from_str<T>(source: ~str, owner: SrvOwner<T>) -> T {
|
||||
run(owner, source, parse::from_str_sess)
|
||||
}
|
||||
|
||||
fn from_file<T>(file: ~str, owner: srv_owner<T>) -> T {
|
||||
fn from_file<T>(file: ~str, owner: SrvOwner<T>) -> T {
|
||||
run(owner, file, |sess, f| parse::from_file_sess(sess, &Path(f)))
|
||||
}
|
||||
|
||||
fn run<T>(owner: srv_owner<T>, source: ~str, +parse: parser) -> T {
|
||||
fn run<T>(owner: SrvOwner<T>, source: ~str, +parse: Parser) -> T {
|
||||
|
||||
let srv_ = srv({
|
||||
let srv_ = Srv({
|
||||
ch: do task::spawn_listener |po| {
|
||||
act(po, source, parse);
|
||||
}
|
||||
});
|
||||
|
||||
let res = owner(srv_);
|
||||
comm::send(srv_.ch, exit);
|
||||
comm::send(srv_.ch, Exit);
|
||||
return res;
|
||||
}
|
||||
|
||||
fn act(po: comm::Port<msg>, source: ~str, parse: parser) {
|
||||
fn act(po: comm::Port<Msg>, source: ~str, parse: Parser) {
|
||||
let sess = build_session();
|
||||
|
||||
let ctxt = build_ctxt(
|
||||
|
@ -78,10 +78,10 @@ fn act(po: comm::Port<msg>, source: ~str, parse: parser) {
|
|||
let mut keep_going = true;
|
||||
while keep_going {
|
||||
match comm::recv(po) {
|
||||
handle_request(f) => {
|
||||
HandleRequest(f) => {
|
||||
f(ctxt);
|
||||
}
|
||||
exit => {
|
||||
Exit => {
|
||||
keep_going = false;
|
||||
}
|
||||
}
|
||||
|
@ -89,12 +89,12 @@ fn act(po: comm::Port<msg>, source: ~str, parse: parser) {
|
|||
}
|
||||
|
||||
fn exec<T:Send>(
|
||||
srv: srv,
|
||||
+f: fn~(ctxt: ctxt) -> T
|
||||
srv: Srv,
|
||||
+f: fn~(ctxt: Ctxt) -> T
|
||||
) -> T {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let msg = handle_request(fn~(move f, ctxt: ctxt) {
|
||||
let msg = HandleRequest(fn~(move f, ctxt: Ctxt) {
|
||||
comm::send(ch, f(ctxt))
|
||||
});
|
||||
comm::send(srv.ch, msg);
|
||||
|
@ -102,7 +102,7 @@ fn exec<T:Send>(
|
|||
}
|
||||
|
||||
fn build_ctxt(sess: session,
|
||||
ast: @ast::crate) -> ctxt {
|
||||
ast: @ast::crate) -> Ctxt {
|
||||
|
||||
use rustc::front::config;
|
||||
|
||||
|
@ -129,7 +129,7 @@ fn build_session() -> session {
|
|||
session
|
||||
}
|
||||
|
||||
type error_handlers = {
|
||||
type ErrorHandlers = {
|
||||
emitter: diagnostic::emitter,
|
||||
span_handler: diagnostic::span_handler
|
||||
};
|
||||
|
@ -138,13 +138,13 @@ type error_handlers = {
|
|||
// errors
|
||||
fn build_error_handlers(
|
||||
codemap: codemap::codemap
|
||||
) -> error_handlers {
|
||||
) -> ErrorHandlers {
|
||||
|
||||
type diagnostic_handler = {
|
||||
type DiagnosticHandler = {
|
||||
inner: diagnostic::handler,
|
||||
};
|
||||
|
||||
impl diagnostic_handler: diagnostic::handler {
|
||||
impl DiagnosticHandler: diagnostic::handler {
|
||||
fn fatal(msg: ~str) -> ! { self.inner.fatal(msg) }
|
||||
fn err(msg: ~str) { self.inner.err(msg) }
|
||||
fn bump_err_count() {
|
||||
|
|
|
@ -9,11 +9,11 @@ use syntax::ast;
|
|||
use syntax::attr;
|
||||
use core::tuple;
|
||||
|
||||
export crate_attrs;
|
||||
export CrateAttrs;
|
||||
export parse_crate, parse_desc;
|
||||
export parse_hidden;
|
||||
|
||||
type crate_attrs = {
|
||||
type CrateAttrs = {
|
||||
name: Option<~str>
|
||||
};
|
||||
|
||||
|
@ -59,7 +59,7 @@ fn doc_meta(
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_crate(attrs: ~[ast::attribute]) -> crate_attrs {
|
||||
fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
|
||||
let link_metas = attr::find_linkage_metas(attrs);
|
||||
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
of the natural-language documentation for a crate."
|
||||
)];
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
use extract::to_str;
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
|
@ -14,7 +14,7 @@ use std::map::HashMap;
|
|||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
{
|
||||
name: ~"attr",
|
||||
f: run
|
||||
|
@ -22,10 +22,10 @@ fn mk_pass() -> pass {
|
|||
}
|
||||
|
||||
fn run(
|
||||
srv: astsrv::srv,
|
||||
doc: doc::doc
|
||||
) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
srv: astsrv::Srv,
|
||||
doc: doc::Doc
|
||||
) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_crate: fold_crate,
|
||||
fold_item: fold_item,
|
||||
fold_enum: fold_enum,
|
||||
|
@ -37,9 +37,9 @@ fn run(
|
|||
}
|
||||
|
||||
fn fold_crate(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::cratedoc
|
||||
) -> doc::cratedoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::CrateDoc
|
||||
) -> doc::CrateDoc {
|
||||
|
||||
let srv = fold.ctxt;
|
||||
let doc = fold::default_seq_fold_crate(fold, doc);
|
||||
|
@ -50,7 +50,7 @@ fn fold_crate(
|
|||
};
|
||||
|
||||
{
|
||||
topmod: doc::moddoc_({
|
||||
topmod: doc::ModDoc_({
|
||||
item: {
|
||||
name: option::get_default(attrs.name, doc.topmod.name()),
|
||||
.. doc.topmod.item
|
||||
|
@ -67,9 +67,9 @@ fn should_replace_top_module_name_with_crate_name() {
|
|||
}
|
||||
|
||||
fn fold_item(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::itemdoc
|
||||
) -> doc::itemdoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::ItemDoc
|
||||
) -> doc::ItemDoc {
|
||||
|
||||
let srv = fold.ctxt;
|
||||
let doc = fold::default_seq_fold_item(fold, doc);
|
||||
|
@ -90,8 +90,8 @@ fn fold_item(
|
|||
}
|
||||
|
||||
fn parse_item_attrs<T:Send>(
|
||||
srv: astsrv::srv,
|
||||
id: doc::ast_id,
|
||||
srv: astsrv::Srv,
|
||||
id: doc::AstId,
|
||||
+parse_attrs: fn~(~[ast::attribute]) -> T) -> T {
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
let attrs = match ctxt.ast_map.get(id) {
|
||||
|
@ -134,9 +134,9 @@ fn should_extract_fn_attributes() {
|
|||
}
|
||||
|
||||
fn fold_enum(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::enumdoc
|
||||
) -> doc::enumdoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::EnumDoc
|
||||
) -> doc::EnumDoc {
|
||||
|
||||
let srv = fold.ctxt;
|
||||
let doc_id = doc.id();
|
||||
|
@ -184,9 +184,9 @@ fn should_extract_variant_docs() {
|
|||
}
|
||||
|
||||
fn fold_trait(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::traitdoc
|
||||
) -> doc::traitdoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::TraitDoc
|
||||
) -> doc::TraitDoc {
|
||||
let srv = fold.ctxt;
|
||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
|
@ -197,10 +197,10 @@ fn fold_trait(
|
|||
}
|
||||
|
||||
fn merge_method_attrs(
|
||||
srv: astsrv::srv,
|
||||
item_id: doc::ast_id,
|
||||
docs: ~[doc::methoddoc]
|
||||
) -> ~[doc::methoddoc] {
|
||||
srv: astsrv::Srv,
|
||||
item_id: doc::AstId,
|
||||
docs: ~[doc::MethodDoc]
|
||||
) -> ~[doc::MethodDoc] {
|
||||
|
||||
// Create an assoc list from method name to attributes
|
||||
let attrs: ~[(~str, Option<~str>)] = do astsrv::exec(srv) |ctxt| {
|
||||
|
@ -259,9 +259,9 @@ fn should_extract_trait_method_docs() {
|
|||
|
||||
|
||||
fn fold_impl(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::impldoc
|
||||
) -> doc::impldoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::ImplDoc
|
||||
) -> doc::ImplDoc {
|
||||
let srv = fold.ctxt;
|
||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
|
@ -290,7 +290,7 @@ fn should_extract_impl_method_docs() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
use result::Result;
|
||||
use std::getopts;
|
||||
|
||||
export output_format;
|
||||
export output_style;
|
||||
export config;
|
||||
export OutputFormat;
|
||||
export OutputStyle;
|
||||
export Config;
|
||||
export default_config;
|
||||
export parse_config;
|
||||
export usage;
|
||||
export markdown, pandoc_html;
|
||||
export doc_per_crate, doc_per_mod;
|
||||
export Markdown, PandocHtml;
|
||||
export DocPerCrate, DocPerMod;
|
||||
|
||||
/// The type of document to output
|
||||
enum output_format {
|
||||
enum OutputFormat {
|
||||
/// Markdown
|
||||
markdown,
|
||||
Markdown,
|
||||
/// HTML, via markdown and pandoc
|
||||
pandoc_html
|
||||
PandocHtml
|
||||
}
|
||||
|
||||
impl output_format : cmp::Eq {
|
||||
pure fn eq(&&other: output_format) -> bool {
|
||||
impl OutputFormat : cmp::Eq {
|
||||
pure fn eq(&&other: OutputFormat) -> bool {
|
||||
(self as uint) == (other as uint)
|
||||
}
|
||||
pure fn ne(&&other: output_format) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: OutputFormat) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
/// How to organize the output
|
||||
enum output_style {
|
||||
enum OutputStyle {
|
||||
/// All in a single document
|
||||
doc_per_crate,
|
||||
DocPerCrate,
|
||||
/// Each module in its own document
|
||||
doc_per_mod
|
||||
DocPerMod
|
||||
}
|
||||
|
||||
impl output_style : cmp::Eq {
|
||||
pure fn eq(&&other: output_style) -> bool {
|
||||
impl OutputStyle : cmp::Eq {
|
||||
pure fn eq(&&other: OutputStyle) -> bool {
|
||||
(self as uint) == (other as uint)
|
||||
}
|
||||
pure fn ne(&&other: output_style) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: OutputStyle) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
/// The configuration for a rustdoc session
|
||||
type config = {
|
||||
type Config = {
|
||||
input_crate: Path,
|
||||
output_dir: Path,
|
||||
output_format: output_format,
|
||||
output_style: output_style,
|
||||
output_format: OutputFormat,
|
||||
output_style: OutputStyle,
|
||||
pandoc_cmd: Option<~str>
|
||||
};
|
||||
|
||||
|
@ -81,17 +81,17 @@ fn usage() {
|
|||
println(~"");
|
||||
}
|
||||
|
||||
fn default_config(input_crate: &Path) -> config {
|
||||
fn default_config(input_crate: &Path) -> Config {
|
||||
{
|
||||
input_crate: *input_crate,
|
||||
output_dir: Path("."),
|
||||
output_format: pandoc_html,
|
||||
output_style: doc_per_mod,
|
||||
output_format: PandocHtml,
|
||||
output_style: DocPerMod,
|
||||
pandoc_cmd: None
|
||||
}
|
||||
}
|
||||
|
||||
type program_output = fn~((&str), (&[~str])) ->
|
||||
type ProgramOutput = fn~((&str), (&[~str])) ->
|
||||
{status: int, out: ~str, err: ~str};
|
||||
|
||||
fn mock_program_output(_prog: &str, _args: &[~str]) -> {
|
||||
|
@ -104,14 +104,14 @@ fn mock_program_output(_prog: &str, _args: &[~str]) -> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_config(args: ~[~str]) -> Result<config, ~str> {
|
||||
fn parse_config(args: ~[~str]) -> Result<Config, ~str> {
|
||||
parse_config_(args, run::program_output)
|
||||
}
|
||||
|
||||
fn parse_config_(
|
||||
args: ~[~str],
|
||||
program_output: program_output
|
||||
) -> Result<config, ~str> {
|
||||
program_output: ProgramOutput
|
||||
) -> Result<Config, ~str> {
|
||||
let args = vec::tail(args);
|
||||
let opts = vec::unzip(opts()).first();
|
||||
match getopts::getopts(args, opts) {
|
||||
|
@ -134,8 +134,8 @@ fn parse_config_(
|
|||
fn config_from_opts(
|
||||
input_crate: &Path,
|
||||
matches: getopts::Matches,
|
||||
program_output: program_output
|
||||
) -> Result<config, ~str> {
|
||||
program_output: ProgramOutput
|
||||
) -> Result<Config, ~str> {
|
||||
|
||||
let config = default_config(input_crate);
|
||||
let result = result::Ok(config);
|
||||
|
@ -190,28 +190,28 @@ fn config_from_opts(
|
|||
return result;
|
||||
}
|
||||
|
||||
fn parse_output_format(output_format: ~str) -> Result<output_format, ~str> {
|
||||
fn parse_output_format(output_format: ~str) -> Result<OutputFormat, ~str> {
|
||||
match output_format {
|
||||
~"markdown" => result::Ok(markdown),
|
||||
~"html" => result::Ok(pandoc_html),
|
||||
~"markdown" => result::Ok(Markdown),
|
||||
~"html" => result::Ok(PandocHtml),
|
||||
_ => result::Err(fmt!("unknown output format '%s'", output_format))
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_output_style(output_style: ~str) -> Result<output_style, ~str> {
|
||||
fn parse_output_style(output_style: ~str) -> Result<OutputStyle, ~str> {
|
||||
match output_style {
|
||||
~"doc-per-crate" => result::Ok(doc_per_crate),
|
||||
~"doc-per-mod" => result::Ok(doc_per_mod),
|
||||
~"doc-per-crate" => result::Ok(DocPerCrate),
|
||||
~"doc-per-mod" => result::Ok(DocPerMod),
|
||||
_ => result::Err(fmt!("unknown output style '%s'", output_style))
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_find_pandoc(
|
||||
config: config,
|
||||
config: Config,
|
||||
maybe_pandoc_cmd: Option<~str>,
|
||||
program_output: program_output
|
||||
program_output: ProgramOutput
|
||||
) -> Result<Option<~str>, ~str> {
|
||||
if config.output_format != pandoc_html {
|
||||
if config.output_format != PandocHtml {
|
||||
return result::Ok(maybe_pandoc_cmd);
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ fn maybe_find_pandoc(
|
|||
#[test]
|
||||
fn should_find_pandoc() {
|
||||
let config = {
|
||||
output_format: pandoc_html,
|
||||
output_format: PandocHtml,
|
||||
.. default_config(&Path("test"))
|
||||
};
|
||||
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
|
||||
|
@ -260,7 +260,7 @@ fn should_find_pandoc() {
|
|||
#[test]
|
||||
fn should_error_with_no_pandoc() {
|
||||
let config = {
|
||||
output_format: pandoc_html,
|
||||
output_format: PandocHtml,
|
||||
.. default_config(&Path("test"))
|
||||
};
|
||||
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
|
||||
|
@ -276,7 +276,7 @@ fn should_error_with_no_pandoc() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn parse_config(args: ~[~str]) -> Result<config, ~str> {
|
||||
fn parse_config(args: ~[~str]) -> Result<Config, ~str> {
|
||||
parse_config_(args, mock_program_output)
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ fn should_set_output_dir_if_provided() {
|
|||
#[test]
|
||||
fn should_set_output_format_to_pandoc_html_if_not_provided() {
|
||||
let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]);
|
||||
assert result::get(config).output_format == pandoc_html;
|
||||
assert result::get(config).output_format == PandocHtml;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -319,7 +319,7 @@ fn should_set_output_format_to_markdown_if_requested() {
|
|||
let config = test::parse_config(~[
|
||||
~"rustdoc", ~"crate.rc", ~"--output-format", ~"markdown"
|
||||
]);
|
||||
assert result::get(config).output_format == markdown;
|
||||
assert result::get(config).output_format == Markdown;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -327,7 +327,7 @@ fn should_set_output_format_to_pandoc_html_if_requested() {
|
|||
let config = test::parse_config(~[
|
||||
~"rustdoc", ~"crate.rc", ~"--output-format", ~"html"
|
||||
]);
|
||||
assert result::get(config).output_format == pandoc_html;
|
||||
assert result::get(config).output_format == PandocHtml;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -341,7 +341,7 @@ fn should_error_on_bogus_format() {
|
|||
#[test]
|
||||
fn should_set_output_style_to_doc_per_mod_by_default() {
|
||||
let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]);
|
||||
assert result::get(config).output_style == doc_per_mod;
|
||||
assert result::get(config).output_style == DocPerMod;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -349,7 +349,7 @@ fn should_set_output_style_to_one_doc_if_requested() {
|
|||
let config = test::parse_config(~[
|
||||
~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-crate"
|
||||
]);
|
||||
assert result::get(config).output_style == doc_per_crate;
|
||||
assert result::get(config).output_style == DocPerCrate;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -357,7 +357,7 @@ fn should_set_output_style_to_doc_per_mod_if_requested() {
|
|||
let config = test::parse_config(~[
|
||||
~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-mod"
|
||||
]);
|
||||
assert result::get(config).output_style == doc_per_mod;
|
||||
assert result::get(config).output_style == DocPerMod;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -14,21 +14,21 @@
|
|||
/// The base price of a muffin on a non-holiday
|
||||
const price_of_a_muffin: float = 70f;
|
||||
|
||||
type waitperson = {
|
||||
type WaitPerson = {
|
||||
hair_color: ~str
|
||||
};
|
||||
|
||||
/// The type of things that produce omnomnom
|
||||
enum omnomnomy {
|
||||
enum OmNomNomy {
|
||||
/// Delicious sugar cookies
|
||||
cookie,
|
||||
Cookie,
|
||||
/// It's pizza
|
||||
pizza_pie(~[uint])
|
||||
PizzaPie(~[uint])
|
||||
}
|
||||
|
||||
fn take_my_order_please(
|
||||
_waitperson: waitperson,
|
||||
_order: ~[omnomnomy]
|
||||
_waitperson: WaitPerson,
|
||||
_order: ~[OmNomNomy]
|
||||
) -> uint {
|
||||
|
||||
/*!
|
||||
|
@ -111,7 +111,7 @@ mod blade_runner {
|
|||
* eget ante feugiat tortor congue auctor ac quis ante. Proin
|
||||
* condimentum lacinia tincidunt.
|
||||
*/
|
||||
struct bored {
|
||||
struct Bored {
|
||||
bored: bool,
|
||||
drop { log(error, self.bored); }
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ struct bored {
|
|||
* neighboring hillside churchyard of St. John's, whose hidden expanse of
|
||||
* Eighteenth Century gravestones had for him a peculiar fascination.
|
||||
*/
|
||||
trait the_shunned_house {
|
||||
trait TheShunnedHouse {
|
||||
/**
|
||||
* Now the irony is this. In this walk, so many times repeated, the
|
||||
* world's greatest master of the terrible and the bizarre was
|
||||
|
@ -175,7 +175,7 @@ trait the_shunned_house {
|
|||
}
|
||||
|
||||
/// Whatever
|
||||
impl omnomnomy: the_shunned_house {
|
||||
impl OmNomNomy: TheShunnedHouse {
|
||||
fn dingy_house(_unkempt_yard: int) {
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
* is interpreted as the brief description.
|
||||
*/
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
{
|
||||
name: ~"desc_to_brief",
|
||||
f: run
|
||||
|
@ -17,10 +17,10 @@ fn mk_pass() -> pass {
|
|||
}
|
||||
|
||||
fn run(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc
|
||||
) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc
|
||||
) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_item: fold_item,
|
||||
fold_trait: fold_trait,
|
||||
fold_impl: fold_impl,
|
||||
|
@ -29,7 +29,7 @@ fn run(
|
|||
fold.fold_doc(fold, doc)
|
||||
}
|
||||
|
||||
fn fold_item(fold: fold::fold<()>, doc: doc::itemdoc) -> doc::itemdoc {
|
||||
fn fold_item(fold: fold::Fold<()>, doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||
let doc = fold::default_seq_fold_item(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ fn fold_item(fold: fold::fold<()>, doc: doc::itemdoc) -> doc::itemdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_trait(fold: fold::fold<()>, doc: doc::traitdoc) -> doc::traitdoc {
|
||||
fn fold_trait(fold: fold::Fold<()>, doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||
let doc =fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ fn fold_trait(fold: fold::fold<()>, doc: doc::traitdoc) -> doc::traitdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc {
|
||||
fn fold_impl(fold: fold::Fold<()>, doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||
let doc =fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ fn should_promote_impl_method_desc() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = attr_pass::mk_pass().f(srv, doc);
|
||||
|
|
|
@ -1,62 +1,62 @@
|
|||
//! The document model
|
||||
|
||||
type ast_id = int;
|
||||
type AstId = int;
|
||||
|
||||
type doc_ = {
|
||||
pages: ~[page]
|
||||
type Doc_ = {
|
||||
pages: ~[Page]
|
||||
};
|
||||
|
||||
impl doc_ : cmp::Eq {
|
||||
pure fn eq(&&other: doc_) -> bool {
|
||||
impl Doc_ : cmp::Eq {
|
||||
pure fn eq(&&other: Doc_) -> bool {
|
||||
self.pages == other.pages
|
||||
}
|
||||
pure fn ne(&&other: doc_) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: Doc_) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
enum doc {
|
||||
doc_(doc_)
|
||||
enum Doc {
|
||||
Doc_(Doc_)
|
||||
}
|
||||
|
||||
impl doc : cmp::Eq {
|
||||
pure fn eq(&&other: doc) -> bool { *self == *other }
|
||||
pure fn ne(&&other: doc) -> bool { *self != *other }
|
||||
impl Doc : cmp::Eq {
|
||||
pure fn eq(&&other: Doc) -> bool { *self == *other }
|
||||
pure fn ne(&&other: Doc) -> bool { *self != *other }
|
||||
}
|
||||
|
||||
enum page {
|
||||
cratepage(cratedoc),
|
||||
itempage(itemtag)
|
||||
enum Page {
|
||||
CratePage(CrateDoc),
|
||||
ItemPage(ItemTag)
|
||||
}
|
||||
|
||||
impl page : cmp::Eq {
|
||||
pure fn eq(&&other: page) -> bool {
|
||||
impl Page : cmp::Eq {
|
||||
pure fn eq(&&other: Page) -> bool {
|
||||
match self {
|
||||
cratepage(e0a) => {
|
||||
CratePage(e0a) => {
|
||||
match other {
|
||||
cratepage(e0b) => e0a == e0b,
|
||||
CratePage(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
itempage(e0a) => {
|
||||
ItemPage(e0a) => {
|
||||
match other {
|
||||
itempage(e0b) => e0a == e0b,
|
||||
ItemPage(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pure fn ne(&&other: page) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: Page) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
enum implementation {
|
||||
required,
|
||||
provided,
|
||||
enum Implementation {
|
||||
Required,
|
||||
Provided,
|
||||
}
|
||||
|
||||
impl implementation : cmp::Eq {
|
||||
pure fn eq(&&other: implementation) -> bool {
|
||||
impl Implementation : cmp::Eq {
|
||||
pure fn eq(&&other: Implementation) -> bool {
|
||||
(self as uint) == (other as uint)
|
||||
}
|
||||
pure fn ne(&&other: implementation) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: Implementation) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,112 +64,112 @@ impl implementation : cmp::Eq {
|
|||
* Most rustdocs can be parsed into 'sections' according to their markdown
|
||||
* headers
|
||||
*/
|
||||
type section = {
|
||||
type Section = {
|
||||
header: ~str,
|
||||
body: ~str
|
||||
};
|
||||
|
||||
impl section : cmp::Eq {
|
||||
pure fn eq(&&other: section) -> bool {
|
||||
impl Section : cmp::Eq {
|
||||
pure fn eq(&&other: Section) -> bool {
|
||||
self.header == other.header && self.body == other.body
|
||||
}
|
||||
pure fn ne(&&other: section) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: Section) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
// FIXME (#2596): We currently give topmod the name of the crate. There
|
||||
// would probably be fewer special cases if the crate had its own name
|
||||
// and topmod's name was the empty string.
|
||||
type cratedoc = {
|
||||
topmod: moddoc,
|
||||
type CrateDoc = {
|
||||
topmod: ModDoc,
|
||||
};
|
||||
|
||||
impl cratedoc : cmp::Eq {
|
||||
pure fn eq(&&other: cratedoc) -> bool {
|
||||
impl CrateDoc : cmp::Eq {
|
||||
pure fn eq(&&other: CrateDoc) -> bool {
|
||||
self.topmod == other.topmod
|
||||
}
|
||||
pure fn ne(&&other: cratedoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: CrateDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
enum itemtag {
|
||||
modtag(moddoc),
|
||||
nmodtag(nmoddoc),
|
||||
consttag(constdoc),
|
||||
fntag(fndoc),
|
||||
enumtag(enumdoc),
|
||||
traittag(traitdoc),
|
||||
impltag(impldoc),
|
||||
tytag(tydoc)
|
||||
enum ItemTag {
|
||||
ModTag(ModDoc),
|
||||
NmodTag(NmodDoc),
|
||||
ConstTag(ConstDoc),
|
||||
FnTag(FnDoc),
|
||||
EnumTag(EnumDoc),
|
||||
TraitTag(TraitDoc),
|
||||
ImplTag(ImplDoc),
|
||||
TyTag(TyDoc)
|
||||
}
|
||||
|
||||
impl itemtag : cmp::Eq {
|
||||
pure fn eq(&&other: itemtag) -> bool {
|
||||
impl ItemTag : cmp::Eq {
|
||||
pure fn eq(&&other: ItemTag) -> bool {
|
||||
match self {
|
||||
modtag(e0a) => {
|
||||
ModTag(e0a) => {
|
||||
match other {
|
||||
modtag(e0b) => e0a == e0b,
|
||||
ModTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
nmodtag(e0a) => {
|
||||
NmodTag(e0a) => {
|
||||
match other {
|
||||
nmodtag(e0b) => e0a == e0b,
|
||||
NmodTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
consttag(e0a) => {
|
||||
ConstTag(e0a) => {
|
||||
match other {
|
||||
consttag(e0b) => e0a == e0b,
|
||||
ConstTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
fntag(e0a) => {
|
||||
FnTag(e0a) => {
|
||||
match other {
|
||||
fntag(e0b) => e0a == e0b,
|
||||
FnTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
enumtag(e0a) => {
|
||||
EnumTag(e0a) => {
|
||||
match other {
|
||||
enumtag(e0b) => e0a == e0b,
|
||||
EnumTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
traittag(e0a) => {
|
||||
TraitTag(e0a) => {
|
||||
match other {
|
||||
traittag(e0b) => e0a == e0b,
|
||||
TraitTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
impltag(e0a) => {
|
||||
ImplTag(e0a) => {
|
||||
match other {
|
||||
impltag(e0b) => e0a == e0b,
|
||||
ImplTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
tytag(e0a) => {
|
||||
TyTag(e0a) => {
|
||||
match other {
|
||||
tytag(e0b) => e0a == e0b,
|
||||
TyTag(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pure fn ne(&&other: itemtag) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: ItemTag) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type itemdoc = {
|
||||
id: ast_id,
|
||||
type ItemDoc = {
|
||||
id: AstId,
|
||||
name: ~str,
|
||||
path: ~[~str],
|
||||
brief: Option<~str>,
|
||||
desc: Option<~str>,
|
||||
sections: ~[section],
|
||||
sections: ~[Section],
|
||||
// Indicates that this node is a reexport of a different item
|
||||
reexport: bool
|
||||
};
|
||||
|
||||
impl itemdoc : cmp::Eq {
|
||||
pure fn eq(&&other: itemdoc) -> bool {
|
||||
impl ItemDoc : cmp::Eq {
|
||||
pure fn eq(&&other: ItemDoc) -> bool {
|
||||
self.id == other.id &&
|
||||
self.name == other.name &&
|
||||
self.path == other.path &&
|
||||
|
@ -178,114 +178,114 @@ impl itemdoc : cmp::Eq {
|
|||
self.sections == other.sections &&
|
||||
self.reexport == other.reexport
|
||||
}
|
||||
pure fn ne(&&other: itemdoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: ItemDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type simpleitemdoc = {
|
||||
item: itemdoc,
|
||||
type SimpleItemDoc = {
|
||||
item: ItemDoc,
|
||||
sig: Option<~str>
|
||||
};
|
||||
|
||||
impl simpleitemdoc : cmp::Eq {
|
||||
pure fn eq(&&other: simpleitemdoc) -> bool {
|
||||
impl SimpleItemDoc : cmp::Eq {
|
||||
pure fn eq(&&other: SimpleItemDoc) -> bool {
|
||||
self.item == other.item && self.sig == other.sig
|
||||
}
|
||||
pure fn ne(&&other: simpleitemdoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: SimpleItemDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type moddoc_ = {
|
||||
item: itemdoc,
|
||||
items: ~[itemtag],
|
||||
index: Option<index>
|
||||
type ModDoc_ = {
|
||||
item: ItemDoc,
|
||||
items: ~[ItemTag],
|
||||
index: Option<Index>
|
||||
};
|
||||
|
||||
impl moddoc_ : cmp::Eq {
|
||||
pure fn eq(&&other: moddoc_) -> bool {
|
||||
impl ModDoc_ : cmp::Eq {
|
||||
pure fn eq(&&other: ModDoc_) -> bool {
|
||||
self.item == other.item &&
|
||||
self.items == other.items &&
|
||||
self.index == other.index
|
||||
}
|
||||
pure fn ne(&&other: moddoc_) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: ModDoc_) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
enum moddoc {
|
||||
moddoc_(moddoc_)
|
||||
enum ModDoc {
|
||||
ModDoc_(ModDoc_)
|
||||
}
|
||||
|
||||
impl moddoc : cmp::Eq {
|
||||
pure fn eq(&&other: moddoc) -> bool { *self == *other }
|
||||
pure fn ne(&&other: moddoc) -> bool { *self != *other }
|
||||
impl ModDoc : cmp::Eq {
|
||||
pure fn eq(&&other: ModDoc) -> bool { *self == *other }
|
||||
pure fn ne(&&other: ModDoc) -> bool { *self != *other }
|
||||
}
|
||||
|
||||
type nmoddoc = {
|
||||
item: itemdoc,
|
||||
fns: ~[fndoc],
|
||||
index: Option<index>
|
||||
type NmodDoc = {
|
||||
item: ItemDoc,
|
||||
fns: ~[FnDoc],
|
||||
index: Option<Index>
|
||||
};
|
||||
|
||||
impl nmoddoc : cmp::Eq {
|
||||
pure fn eq(&&other: nmoddoc) -> bool {
|
||||
impl NmodDoc : cmp::Eq {
|
||||
pure fn eq(&&other: NmodDoc) -> bool {
|
||||
self.item == other.item &&
|
||||
self.fns == other.fns &&
|
||||
self.index == other.index
|
||||
}
|
||||
pure fn ne(&&other: nmoddoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: NmodDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type constdoc = simpleitemdoc;
|
||||
type ConstDoc = SimpleItemDoc;
|
||||
|
||||
type fndoc = simpleitemdoc;
|
||||
type FnDoc = SimpleItemDoc;
|
||||
|
||||
type enumdoc = {
|
||||
item: itemdoc,
|
||||
variants: ~[variantdoc]
|
||||
type EnumDoc = {
|
||||
item: ItemDoc,
|
||||
variants: ~[VariantDoc]
|
||||
};
|
||||
|
||||
impl enumdoc : cmp::Eq {
|
||||
pure fn eq(&&other: enumdoc) -> bool {
|
||||
impl EnumDoc : cmp::Eq {
|
||||
pure fn eq(&&other: EnumDoc) -> bool {
|
||||
self.item == other.item && self.variants == other.variants
|
||||
}
|
||||
pure fn ne(&&other: enumdoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: EnumDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type variantdoc = {
|
||||
type VariantDoc = {
|
||||
name: ~str,
|
||||
desc: Option<~str>,
|
||||
sig: Option<~str>
|
||||
};
|
||||
|
||||
impl variantdoc : cmp::Eq {
|
||||
pure fn eq(&&other: variantdoc) -> bool {
|
||||
impl VariantDoc : cmp::Eq {
|
||||
pure fn eq(&&other: VariantDoc) -> bool {
|
||||
self.name == other.name &&
|
||||
self.desc == other.desc &&
|
||||
self.sig == other.sig
|
||||
}
|
||||
pure fn ne(&&other: variantdoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: VariantDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type traitdoc = {
|
||||
item: itemdoc,
|
||||
methods: ~[methoddoc]
|
||||
type TraitDoc = {
|
||||
item: ItemDoc,
|
||||
methods: ~[MethodDoc]
|
||||
};
|
||||
|
||||
impl traitdoc : cmp::Eq {
|
||||
pure fn eq(&&other: traitdoc) -> bool {
|
||||
impl TraitDoc : cmp::Eq {
|
||||
pure fn eq(&&other: TraitDoc) -> bool {
|
||||
self.item == other.item && self.methods == other.methods
|
||||
}
|
||||
pure fn ne(&&other: traitdoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: TraitDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type methoddoc = {
|
||||
type MethodDoc = {
|
||||
name: ~str,
|
||||
brief: Option<~str>,
|
||||
desc: Option<~str>,
|
||||
sections: ~[section],
|
||||
sections: ~[Section],
|
||||
sig: Option<~str>,
|
||||
implementation: implementation,
|
||||
implementation: Implementation,
|
||||
};
|
||||
|
||||
impl methoddoc : cmp::Eq {
|
||||
pure fn eq(&&other: methoddoc) -> bool {
|
||||
impl MethodDoc : cmp::Eq {
|
||||
pure fn eq(&&other: MethodDoc) -> bool {
|
||||
self.name == other.name &&
|
||||
self.brief == other.brief &&
|
||||
self.desc == other.desc &&
|
||||
|
@ -293,37 +293,37 @@ impl methoddoc : cmp::Eq {
|
|||
self.sig == other.sig &&
|
||||
self.implementation == other.implementation
|
||||
}
|
||||
pure fn ne(&&other: methoddoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: MethodDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type impldoc = {
|
||||
item: itemdoc,
|
||||
type ImplDoc = {
|
||||
item: ItemDoc,
|
||||
trait_types: ~[~str],
|
||||
self_ty: Option<~str>,
|
||||
methods: ~[methoddoc]
|
||||
methods: ~[MethodDoc]
|
||||
};
|
||||
|
||||
impl impldoc : cmp::Eq {
|
||||
pure fn eq(&&other: impldoc) -> bool {
|
||||
impl ImplDoc : cmp::Eq {
|
||||
pure fn eq(&&other: ImplDoc) -> bool {
|
||||
self.item == other.item &&
|
||||
self.trait_types == other.trait_types &&
|
||||
self.self_ty == other.self_ty &&
|
||||
self.methods == other.methods
|
||||
}
|
||||
pure fn ne(&&other: impldoc) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: ImplDoc) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
type tydoc = simpleitemdoc;
|
||||
type TyDoc = SimpleItemDoc;
|
||||
|
||||
type index = {
|
||||
entries: ~[index_entry]
|
||||
type Index = {
|
||||
entries: ~[IndexEntry]
|
||||
};
|
||||
|
||||
impl index : cmp::Eq {
|
||||
pure fn eq(&&other: index) -> bool {
|
||||
impl Index : cmp::Eq {
|
||||
pure fn eq(&&other: Index) -> bool {
|
||||
self.entries == other.entries
|
||||
}
|
||||
pure fn ne(&&other: index) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: Index) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,254 +336,254 @@ impl index : cmp::Eq {
|
|||
* * brief - The brief description
|
||||
* * link - A format-specific string representing the link target
|
||||
*/
|
||||
type index_entry = {
|
||||
type IndexEntry = {
|
||||
kind: ~str,
|
||||
name: ~str,
|
||||
brief: Option<~str>,
|
||||
link: ~str
|
||||
};
|
||||
|
||||
impl index_entry : cmp::Eq {
|
||||
pure fn eq(&&other: index_entry) -> bool {
|
||||
impl IndexEntry : cmp::Eq {
|
||||
pure fn eq(&&other: IndexEntry) -> bool {
|
||||
self.kind == other.kind &&
|
||||
self.name == other.name &&
|
||||
self.brief == other.brief &&
|
||||
self.link == other.link
|
||||
}
|
||||
pure fn ne(&&other: index_entry) -> bool { !self.eq(other) }
|
||||
pure fn ne(&&other: IndexEntry) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
impl doc {
|
||||
fn cratedoc() -> cratedoc {
|
||||
impl Doc {
|
||||
fn CrateDoc() -> CrateDoc {
|
||||
option::get(vec::foldl(None, self.pages, |_m, page| {
|
||||
match page {
|
||||
doc::cratepage(doc) => Some(doc),
|
||||
doc::CratePage(doc) => Some(doc),
|
||||
_ => None
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
fn cratemod() -> moddoc {
|
||||
self.cratedoc().topmod
|
||||
fn cratemod() -> ModDoc {
|
||||
self.CrateDoc().topmod
|
||||
}
|
||||
}
|
||||
|
||||
/// Some helper methods on moddoc, mostly for testing
|
||||
impl moddoc {
|
||||
/// Some helper methods on ModDoc, mostly for testing
|
||||
impl ModDoc {
|
||||
|
||||
fn mods() -> ~[moddoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
modtag(moddoc) => Some(moddoc),
|
||||
fn mods() -> ~[ModDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
ModTag(ModDoc) => Some(ModDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn nmods() -> ~[nmoddoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
nmodtag(nmoddoc) => Some(nmoddoc),
|
||||
fn nmods() -> ~[NmodDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
NmodTag(nModDoc) => Some(nModDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fns() -> ~[fndoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
fntag(fndoc) => Some(fndoc),
|
||||
fn fns() -> ~[FnDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
FnTag(FnDoc) => Some(FnDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn consts() -> ~[constdoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
consttag(constdoc) => Some(constdoc),
|
||||
fn consts() -> ~[ConstDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
ConstTag(ConstDoc) => Some(ConstDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn enums() -> ~[enumdoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
enumtag(enumdoc) => Some(enumdoc),
|
||||
fn enums() -> ~[EnumDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
EnumTag(EnumDoc) => Some(EnumDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn traits() -> ~[traitdoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
traittag(traitdoc) => Some(traitdoc),
|
||||
fn traits() -> ~[TraitDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
TraitTag(TraitDoc) => Some(TraitDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn impls() -> ~[impldoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
impltag(impldoc) => Some(impldoc),
|
||||
fn impls() -> ~[ImplDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
ImplTag(ImplDoc) => Some(ImplDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn types() -> ~[tydoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
tytag(tydoc) => Some(tydoc),
|
||||
fn types() -> ~[TyDoc] {
|
||||
do vec::filter_map(self.items) |ItemTag| {
|
||||
match ItemTag {
|
||||
TyTag(TyDoc) => Some(TyDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait page_utils {
|
||||
fn mods() -> ~[moddoc];
|
||||
fn nmods() -> ~[nmoddoc];
|
||||
fn fns() -> ~[fndoc];
|
||||
fn consts() -> ~[constdoc];
|
||||
fn enums() -> ~[enumdoc];
|
||||
fn traits() -> ~[traitdoc];
|
||||
fn impls() -> ~[impldoc];
|
||||
fn types() -> ~[tydoc];
|
||||
trait PageUtils {
|
||||
fn mods() -> ~[ModDoc];
|
||||
fn nmods() -> ~[NmodDoc];
|
||||
fn fns() -> ~[FnDoc];
|
||||
fn consts() -> ~[ConstDoc];
|
||||
fn enums() -> ~[EnumDoc];
|
||||
fn traits() -> ~[TraitDoc];
|
||||
fn impls() -> ~[ImplDoc];
|
||||
fn types() -> ~[TyDoc];
|
||||
}
|
||||
|
||||
impl ~[page]: page_utils {
|
||||
impl ~[Page]: PageUtils {
|
||||
|
||||
fn mods() -> ~[moddoc] {
|
||||
fn mods() -> ~[ModDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(modtag(moddoc)) => Some(moddoc),
|
||||
ItemPage(ModTag(ModDoc)) => Some(ModDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn nmods() -> ~[nmoddoc] {
|
||||
fn nmods() -> ~[NmodDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(nmodtag(nmoddoc)) => Some(nmoddoc),
|
||||
ItemPage(NmodTag(nModDoc)) => Some(nModDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fns() -> ~[fndoc] {
|
||||
fn fns() -> ~[FnDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(fntag(fndoc)) => Some(fndoc),
|
||||
ItemPage(FnTag(FnDoc)) => Some(FnDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn consts() -> ~[constdoc] {
|
||||
fn consts() -> ~[ConstDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(consttag(constdoc)) => Some(constdoc),
|
||||
ItemPage(ConstTag(ConstDoc)) => Some(ConstDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn enums() -> ~[enumdoc] {
|
||||
fn enums() -> ~[EnumDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(enumtag(enumdoc)) => Some(enumdoc),
|
||||
ItemPage(EnumTag(EnumDoc)) => Some(EnumDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn traits() -> ~[traitdoc] {
|
||||
fn traits() -> ~[TraitDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(traittag(traitdoc)) => Some(traitdoc),
|
||||
ItemPage(TraitTag(TraitDoc)) => Some(TraitDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn impls() -> ~[impldoc] {
|
||||
fn impls() -> ~[ImplDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(impltag(impldoc)) => Some(impldoc),
|
||||
ItemPage(ImplTag(ImplDoc)) => Some(ImplDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn types() -> ~[tydoc] {
|
||||
fn types() -> ~[TyDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
itempage(tytag(tydoc)) => Some(tydoc),
|
||||
ItemPage(TyTag(TyDoc)) => Some(TyDoc),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait item {
|
||||
pure fn item() -> itemdoc;
|
||||
trait Item {
|
||||
pure fn item() -> ItemDoc;
|
||||
}
|
||||
|
||||
impl itemtag: item {
|
||||
pure fn item() -> itemdoc {
|
||||
impl ItemTag: Item {
|
||||
pure fn item() -> ItemDoc {
|
||||
match self {
|
||||
doc::modtag(doc) => doc.item,
|
||||
doc::nmodtag(doc) => doc.item,
|
||||
doc::fntag(doc) => doc.item,
|
||||
doc::consttag(doc) => doc.item,
|
||||
doc::enumtag(doc) => doc.item,
|
||||
doc::traittag(doc) => doc.item,
|
||||
doc::impltag(doc) => doc.item,
|
||||
doc::tytag(doc) => doc.item
|
||||
doc::ModTag(doc) => doc.item,
|
||||
doc::NmodTag(doc) => doc.item,
|
||||
doc::FnTag(doc) => doc.item,
|
||||
doc::ConstTag(doc) => doc.item,
|
||||
doc::EnumTag(doc) => doc.item,
|
||||
doc::TraitTag(doc) => doc.item,
|
||||
doc::ImplTag(doc) => doc.item,
|
||||
doc::TyTag(doc) => doc.item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl simpleitemdoc: item {
|
||||
pure fn item() -> itemdoc { self.item }
|
||||
impl SimpleItemDoc: Item {
|
||||
pure fn item() -> ItemDoc { self.item }
|
||||
}
|
||||
|
||||
impl moddoc: item {
|
||||
pure fn item() -> itemdoc { self.item }
|
||||
impl ModDoc: Item {
|
||||
pure fn item() -> ItemDoc { self.item }
|
||||
}
|
||||
|
||||
impl nmoddoc: item {
|
||||
pure fn item() -> itemdoc { self.item }
|
||||
impl NmodDoc: Item {
|
||||
pure fn item() -> ItemDoc { self.item }
|
||||
}
|
||||
|
||||
impl enumdoc: item {
|
||||
pure fn item() -> itemdoc { self.item }
|
||||
impl EnumDoc: Item {
|
||||
pure fn item() -> ItemDoc { self.item }
|
||||
}
|
||||
|
||||
impl traitdoc: item {
|
||||
pure fn item() -> itemdoc { self.item }
|
||||
impl TraitDoc: Item {
|
||||
pure fn item() -> ItemDoc { self.item }
|
||||
}
|
||||
|
||||
impl impldoc: item {
|
||||
pure fn item() -> itemdoc { self.item }
|
||||
impl ImplDoc: Item {
|
||||
pure fn item() -> ItemDoc { self.item }
|
||||
}
|
||||
|
||||
trait item_utils {
|
||||
pure fn id() -> ast_id;
|
||||
trait ItemUtils {
|
||||
pure fn id() -> AstId;
|
||||
pure fn name() -> ~str;
|
||||
pure fn path() -> ~[~str];
|
||||
pure fn brief() -> Option<~str>;
|
||||
pure fn desc() -> Option<~str>;
|
||||
pure fn sections() -> ~[section];
|
||||
pure fn sections() -> ~[Section];
|
||||
}
|
||||
|
||||
impl<A:item> A: item_utils {
|
||||
pure fn id() -> ast_id {
|
||||
impl<A:Item> A: ItemUtils {
|
||||
pure fn id() -> AstId {
|
||||
self.item().id
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ impl<A:item> A: item_utils {
|
|||
self.item().desc
|
||||
}
|
||||
|
||||
pure fn sections() -> ~[section] {
|
||||
pure fn sections() -> ~[Section] {
|
||||
self.item().sections
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
text_pass::mk_pass(~"escape", escape)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Converts the Rust AST to the rustdoc document model
|
||||
|
||||
use syntax::ast;
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export from_srv, extract, to_str, interner;
|
||||
|
||||
|
@ -26,9 +26,9 @@ fn interner() -> syntax::parse::token::ident_interner {
|
|||
}
|
||||
|
||||
fn from_srv(
|
||||
srv: astsrv::srv,
|
||||
srv: astsrv::Srv,
|
||||
default_name: ~str
|
||||
) -> doc::doc {
|
||||
) -> doc::Doc {
|
||||
|
||||
//! Use the AST service to create a document tree
|
||||
|
||||
|
@ -40,25 +40,25 @@ fn from_srv(
|
|||
fn extract(
|
||||
crate: @ast::crate,
|
||||
default_name: ~str
|
||||
) -> doc::doc {
|
||||
doc::doc_({
|
||||
) -> doc::Doc {
|
||||
doc::Doc_({
|
||||
pages: ~[
|
||||
doc::cratepage({
|
||||
topmod: top_moddoc_from_crate(crate, default_name),
|
||||
doc::CratePage({
|
||||
topmod: top_ModDoc_from_crate(crate, default_name),
|
||||
})
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
fn top_moddoc_from_crate(
|
||||
fn top_ModDoc_from_crate(
|
||||
crate: @ast::crate,
|
||||
default_name: ~str
|
||||
) -> doc::moddoc {
|
||||
moddoc_from_mod(mk_itemdoc(ast::crate_node_id, default_name),
|
||||
) -> doc::ModDoc {
|
||||
ModDoc_from_mod(mk_ItemDoc(ast::crate_node_id, default_name),
|
||||
crate.node.module)
|
||||
}
|
||||
|
||||
fn mk_itemdoc(id: ast::node_id, name: ~str) -> doc::itemdoc {
|
||||
fn mk_ItemDoc(id: ast::node_id, name: ~str) -> doc::ItemDoc {
|
||||
{
|
||||
id: id,
|
||||
name: name,
|
||||
|
@ -70,53 +70,53 @@ fn mk_itemdoc(id: ast::node_id, name: ~str) -> doc::itemdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn moddoc_from_mod(
|
||||
itemdoc: doc::itemdoc,
|
||||
fn ModDoc_from_mod(
|
||||
ItemDoc: doc::ItemDoc,
|
||||
module_: ast::_mod
|
||||
) -> doc::moddoc {
|
||||
doc::moddoc_({
|
||||
item: itemdoc,
|
||||
) -> doc::ModDoc {
|
||||
doc::ModDoc_({
|
||||
item: ItemDoc,
|
||||
items: do vec::filter_map(module_.items) |item| {
|
||||
let itemdoc = mk_itemdoc(item.id, to_str(item.ident));
|
||||
let ItemDoc = mk_ItemDoc(item.id, to_str(item.ident));
|
||||
match item.node {
|
||||
ast::item_mod(m) => {
|
||||
Some(doc::modtag(
|
||||
moddoc_from_mod(itemdoc, m)
|
||||
Some(doc::ModTag(
|
||||
ModDoc_from_mod(ItemDoc, m)
|
||||
))
|
||||
}
|
||||
ast::item_foreign_mod(nm) => {
|
||||
Some(doc::nmodtag(
|
||||
nmoddoc_from_mod(itemdoc, nm)
|
||||
Some(doc::NmodTag(
|
||||
nModDoc_from_mod(ItemDoc, nm)
|
||||
))
|
||||
}
|
||||
ast::item_fn(*) => {
|
||||
Some(doc::fntag(
|
||||
fndoc_from_fn(itemdoc)
|
||||
Some(doc::FnTag(
|
||||
FnDoc_from_fn(ItemDoc)
|
||||
))
|
||||
}
|
||||
ast::item_const(_, _) => {
|
||||
Some(doc::consttag(
|
||||
constdoc_from_const(itemdoc)
|
||||
Some(doc::ConstTag(
|
||||
ConstDoc_from_const(ItemDoc)
|
||||
))
|
||||
}
|
||||
ast::item_enum(enum_definition, _) => {
|
||||
Some(doc::enumtag(
|
||||
enumdoc_from_enum(itemdoc, enum_definition.variants)
|
||||
Some(doc::EnumTag(
|
||||
EnumDoc_from_enum(ItemDoc, enum_definition.variants)
|
||||
))
|
||||
}
|
||||
ast::item_trait(_, _, methods) => {
|
||||
Some(doc::traittag(
|
||||
traitdoc_from_trait(itemdoc, methods)
|
||||
Some(doc::TraitTag(
|
||||
TraitDoc_from_trait(ItemDoc, methods)
|
||||
))
|
||||
}
|
||||
ast::item_impl(_, _, _, methods) => {
|
||||
Some(doc::impltag(
|
||||
impldoc_from_impl(itemdoc, methods)
|
||||
Some(doc::ImplTag(
|
||||
ImplDoc_from_impl(ItemDoc, methods)
|
||||
))
|
||||
}
|
||||
ast::item_ty(_, _) => {
|
||||
Some(doc::tytag(
|
||||
tydoc_from_ty(itemdoc)
|
||||
Some(doc::TyTag(
|
||||
TyDoc_from_ty(ItemDoc)
|
||||
))
|
||||
}
|
||||
_ => None
|
||||
|
@ -126,37 +126,37 @@ fn moddoc_from_mod(
|
|||
})
|
||||
}
|
||||
|
||||
fn nmoddoc_from_mod(
|
||||
itemdoc: doc::itemdoc,
|
||||
fn nModDoc_from_mod(
|
||||
ItemDoc: doc::ItemDoc,
|
||||
module_: ast::foreign_mod
|
||||
) -> doc::nmoddoc {
|
||||
) -> doc::NmodDoc {
|
||||
let mut fns = ~[];
|
||||
for module_.items.each |item| {
|
||||
let itemdoc = mk_itemdoc(item.id, to_str(item.ident));
|
||||
let ItemDoc = mk_ItemDoc(item.id, to_str(item.ident));
|
||||
match item.node {
|
||||
ast::foreign_item_fn(*) => {
|
||||
vec::push(fns, fndoc_from_fn(itemdoc));
|
||||
vec::push(fns, FnDoc_from_fn(ItemDoc));
|
||||
}
|
||||
ast::foreign_item_const(*) => {} // XXX: Not implemented.
|
||||
}
|
||||
}
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
fns: fns,
|
||||
index: None
|
||||
}
|
||||
}
|
||||
|
||||
fn fndoc_from_fn(itemdoc: doc::itemdoc) -> doc::fndoc {
|
||||
fn FnDoc_from_fn(ItemDoc: doc::ItemDoc) -> doc::FnDoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
sig: None
|
||||
}
|
||||
}
|
||||
|
||||
fn constdoc_from_const(itemdoc: doc::itemdoc) -> doc::constdoc {
|
||||
fn ConstDoc_from_const(ItemDoc: doc::ItemDoc) -> doc::ConstDoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
sig: None
|
||||
}
|
||||
}
|
||||
|
@ -168,23 +168,23 @@ fn should_extract_const_name_and_id() {
|
|||
assert doc.cratemod().consts()[0].name() == ~"a";
|
||||
}
|
||||
|
||||
fn enumdoc_from_enum(
|
||||
itemdoc: doc::itemdoc,
|
||||
fn EnumDoc_from_enum(
|
||||
ItemDoc: doc::ItemDoc,
|
||||
variants: ~[ast::variant]
|
||||
) -> doc::enumdoc {
|
||||
) -> doc::EnumDoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
variants: variantdocs_from_variants(variants)
|
||||
}
|
||||
}
|
||||
|
||||
fn variantdocs_from_variants(
|
||||
variants: ~[ast::variant]
|
||||
) -> ~[doc::variantdoc] {
|
||||
) -> ~[doc::VariantDoc] {
|
||||
vec::map(variants, variantdoc_from_variant)
|
||||
}
|
||||
|
||||
fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc {
|
||||
fn variantdoc_from_variant(variant: ast::variant) -> doc::VariantDoc {
|
||||
|
||||
{
|
||||
name: to_str(variant.node.name),
|
||||
|
@ -206,12 +206,12 @@ fn should_extract_enum_variants() {
|
|||
assert doc.cratemod().enums()[0].variants[0].name == ~"v";
|
||||
}
|
||||
|
||||
fn traitdoc_from_trait(
|
||||
itemdoc: doc::itemdoc,
|
||||
fn TraitDoc_from_trait(
|
||||
ItemDoc: doc::ItemDoc,
|
||||
methods: ~[ast::trait_method]
|
||||
) -> doc::traitdoc {
|
||||
) -> doc::TraitDoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
methods: do vec::map(methods) |method| {
|
||||
match method {
|
||||
ast::required(ty_m) => {
|
||||
|
@ -221,7 +221,7 @@ fn traitdoc_from_trait(
|
|||
desc: None,
|
||||
sections: ~[],
|
||||
sig: None,
|
||||
implementation: doc::required,
|
||||
implementation: doc::Required,
|
||||
}
|
||||
}
|
||||
ast::provided(m) => {
|
||||
|
@ -231,7 +231,7 @@ fn traitdoc_from_trait(
|
|||
desc: None,
|
||||
sections: ~[],
|
||||
sig: None,
|
||||
implementation: doc::provided,
|
||||
implementation: doc::Provided,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,12 +251,12 @@ fn should_extract_trait_methods() {
|
|||
assert doc.cratemod().traits()[0].methods[0].name == ~"f";
|
||||
}
|
||||
|
||||
fn impldoc_from_impl(
|
||||
itemdoc: doc::itemdoc,
|
||||
fn ImplDoc_from_impl(
|
||||
ItemDoc: doc::ItemDoc,
|
||||
methods: ~[@ast::method]
|
||||
) -> doc::impldoc {
|
||||
) -> doc::ImplDoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
trait_types: ~[],
|
||||
self_ty: None,
|
||||
methods: do vec::map(methods) |method| {
|
||||
|
@ -266,7 +266,7 @@ fn impldoc_from_impl(
|
|||
desc: None,
|
||||
sections: ~[],
|
||||
sig: None,
|
||||
implementation: doc::provided,
|
||||
implementation: doc::Provided,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,11 +278,11 @@ fn should_extract_impl_methods() {
|
|||
assert doc.cratemod().impls()[0].methods[0].name == ~"f";
|
||||
}
|
||||
|
||||
fn tydoc_from_ty(
|
||||
itemdoc: doc::itemdoc
|
||||
) -> doc::tydoc {
|
||||
fn TyDoc_from_ty(
|
||||
ItemDoc: doc::ItemDoc
|
||||
) -> doc::TyDoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
item: ItemDoc,
|
||||
sig: None
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ fn should_extract_tys() {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
let ast = parse::from_str(source);
|
||||
extract(ast, ~"")
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export fold;
|
||||
export Fold;
|
||||
export default_seq_fold;
|
||||
export default_seq_fold_doc;
|
||||
export default_seq_fold_crate;
|
||||
|
@ -18,33 +18,33 @@ export default_any_fold;
|
|||
export default_any_fold_mod;
|
||||
export default_any_fold_nmod;
|
||||
|
||||
enum fold<T> = t<T>;
|
||||
enum Fold<T> = Fold_<T>;
|
||||
|
||||
type fold_doc<T> = fn~(fold: fold<T>, doc: doc::doc) -> doc::doc;
|
||||
type fold_crate<T> = fn~(fold: fold<T>, doc: doc::cratedoc) -> doc::cratedoc;
|
||||
type fold_item<T> = fn~(fold: fold<T>, doc: doc::itemdoc) -> doc::itemdoc;
|
||||
type fold_mod<T> = fn~(fold: fold<T>, doc: doc::moddoc) -> doc::moddoc;
|
||||
type fold_nmod<T> = fn~(fold: fold<T>, doc: doc::nmoddoc) -> doc::nmoddoc;
|
||||
type fold_fn<T> = fn~(fold: fold<T>, doc: doc::fndoc) -> doc::fndoc;
|
||||
type fold_const<T> = fn~(fold: fold<T>, doc: doc::constdoc) -> doc::constdoc;
|
||||
type fold_enum<T> = fn~(fold: fold<T>, doc: doc::enumdoc) -> doc::enumdoc;
|
||||
type fold_trait<T> = fn~(fold: fold<T>, doc: doc::traitdoc) -> doc::traitdoc;
|
||||
type fold_impl<T> = fn~(fold: fold<T>, doc: doc::impldoc) -> doc::impldoc;
|
||||
type fold_type<T> = fn~(fold: fold<T>, doc: doc::tydoc) -> doc::tydoc;
|
||||
type FoldDoc<T> = fn~(fold: Fold<T>, doc: doc::Doc) -> doc::Doc;
|
||||
type FoldCrate<T> = fn~(fold: Fold<T>, doc: doc::CrateDoc) -> doc::CrateDoc;
|
||||
type FoldItem<T> = fn~(fold: Fold<T>, doc: doc::ItemDoc) -> doc::ItemDoc;
|
||||
type FoldMod<T> = fn~(fold: Fold<T>, doc: doc::ModDoc) -> doc::ModDoc;
|
||||
type FoldNmod<T> = fn~(fold: Fold<T>, doc: doc::NmodDoc) -> doc::NmodDoc;
|
||||
type FoldFn<T> = fn~(fold: Fold<T>, doc: doc::FnDoc) -> doc::FnDoc;
|
||||
type FoldConst<T> = fn~(fold: Fold<T>, doc: doc::ConstDoc) -> doc::ConstDoc;
|
||||
type FoldEnum<T> = fn~(fold: Fold<T>, doc: doc::EnumDoc) -> doc::EnumDoc;
|
||||
type FoldTrait<T> = fn~(fold: Fold<T>, doc: doc::TraitDoc) -> doc::TraitDoc;
|
||||
type FoldImpl<T> = fn~(fold: Fold<T>, doc: doc::ImplDoc) -> doc::ImplDoc;
|
||||
type FoldType<T> = fn~(fold: Fold<T>, doc: doc::TyDoc) -> doc::TyDoc;
|
||||
|
||||
type t<T> = {
|
||||
type Fold_<T> = {
|
||||
ctxt: T,
|
||||
fold_doc: fold_doc<T>,
|
||||
fold_crate: fold_crate<T>,
|
||||
fold_item: fold_item<T>,
|
||||
fold_mod: fold_mod<T>,
|
||||
fold_nmod: fold_nmod<T>,
|
||||
fold_fn: fold_fn<T>,
|
||||
fold_const: fold_const<T>,
|
||||
fold_enum: fold_enum<T>,
|
||||
fold_trait: fold_trait<T>,
|
||||
fold_impl: fold_impl<T>,
|
||||
fold_type: fold_type<T>
|
||||
fold_doc: FoldDoc<T>,
|
||||
fold_crate: FoldCrate<T>,
|
||||
fold_item: FoldItem<T>,
|
||||
fold_mod: FoldMod<T>,
|
||||
fold_nmod: FoldNmod<T>,
|
||||
fold_fn: FoldFn<T>,
|
||||
fold_const: FoldConst<T>,
|
||||
fold_enum: FoldEnum<T>,
|
||||
fold_trait: FoldTrait<T>,
|
||||
fold_impl: FoldImpl<T>,
|
||||
fold_type: FoldType<T>
|
||||
};
|
||||
|
||||
|
||||
|
@ -52,19 +52,19 @@ type t<T> = {
|
|||
// initializers, but they do as function arguments
|
||||
fn mk_fold<T:Copy>(
|
||||
ctxt: T,
|
||||
+fold_doc: fold_doc<T>,
|
||||
+fold_crate: fold_crate<T>,
|
||||
+fold_item: fold_item<T>,
|
||||
+fold_mod: fold_mod<T>,
|
||||
+fold_nmod: fold_nmod<T>,
|
||||
+fold_fn: fold_fn<T>,
|
||||
+fold_const: fold_const<T>,
|
||||
+fold_enum: fold_enum<T>,
|
||||
+fold_trait: fold_trait<T>,
|
||||
+fold_impl: fold_impl<T>,
|
||||
+fold_type: fold_type<T>
|
||||
) -> fold<T> {
|
||||
fold({
|
||||
+fold_doc: FoldDoc<T>,
|
||||
+fold_crate: FoldCrate<T>,
|
||||
+fold_item: FoldItem<T>,
|
||||
+fold_mod: FoldMod<T>,
|
||||
+fold_nmod: FoldNmod<T>,
|
||||
+fold_fn: FoldFn<T>,
|
||||
+fold_const: FoldConst<T>,
|
||||
+fold_enum: FoldEnum<T>,
|
||||
+fold_trait: FoldTrait<T>,
|
||||
+fold_impl: FoldImpl<T>,
|
||||
+fold_type: FoldType<T>
|
||||
) -> Fold<T> {
|
||||
Fold({
|
||||
ctxt: ctxt,
|
||||
fold_doc: fold_doc,
|
||||
fold_crate: fold_crate,
|
||||
|
@ -80,7 +80,7 @@ fn mk_fold<T:Copy>(
|
|||
})
|
||||
}
|
||||
|
||||
fn default_any_fold<T:Send Copy>(ctxt: T) -> fold<T> {
|
||||
fn default_any_fold<T:Send Copy>(ctxt: T) -> Fold<T> {
|
||||
mk_fold(
|
||||
ctxt,
|
||||
|f, d| default_seq_fold_doc(f, d),
|
||||
|
@ -97,7 +97,7 @@ fn default_any_fold<T:Send Copy>(ctxt: T) -> fold<T> {
|
|||
)
|
||||
}
|
||||
|
||||
fn default_seq_fold<T:Copy>(ctxt: T) -> fold<T> {
|
||||
fn default_seq_fold<T:Copy>(ctxt: T) -> Fold<T> {
|
||||
mk_fold(
|
||||
ctxt,
|
||||
|f, d| default_seq_fold_doc(f, d),
|
||||
|
@ -114,7 +114,7 @@ fn default_seq_fold<T:Copy>(ctxt: T) -> fold<T> {
|
|||
)
|
||||
}
|
||||
|
||||
fn default_par_fold<T:Send Copy>(ctxt: T) -> fold<T> {
|
||||
fn default_par_fold<T:Send Copy>(ctxt: T) -> Fold<T> {
|
||||
mk_fold(
|
||||
ctxt,
|
||||
|f, d| default_seq_fold_doc(f, d),
|
||||
|
@ -131,15 +131,15 @@ fn default_par_fold<T:Send Copy>(ctxt: T) -> fold<T> {
|
|||
)
|
||||
}
|
||||
|
||||
fn default_seq_fold_doc<T>(fold: fold<T>, doc: doc::doc) -> doc::doc {
|
||||
doc::doc_({
|
||||
fn default_seq_fold_doc<T>(fold: Fold<T>, doc: doc::Doc) -> doc::Doc {
|
||||
doc::Doc_({
|
||||
pages: do vec::map(doc.pages) |page| {
|
||||
match page {
|
||||
doc::cratepage(doc) => {
|
||||
doc::cratepage(fold.fold_crate(fold, doc))
|
||||
doc::CratePage(doc) => {
|
||||
doc::CratePage(fold.fold_crate(fold, doc))
|
||||
}
|
||||
doc::itempage(doc) => {
|
||||
doc::itempage(fold_itemtag(fold, doc))
|
||||
doc::ItemPage(doc) => {
|
||||
doc::ItemPage(fold_ItemTag(fold, doc))
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -148,132 +148,132 @@ fn default_seq_fold_doc<T>(fold: fold<T>, doc: doc::doc) -> doc::doc {
|
|||
}
|
||||
|
||||
fn default_seq_fold_crate<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::cratedoc
|
||||
) -> doc::cratedoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::CrateDoc
|
||||
) -> doc::CrateDoc {
|
||||
{
|
||||
topmod: fold.fold_mod(fold, doc.topmod)
|
||||
}
|
||||
}
|
||||
|
||||
fn default_seq_fold_item<T>(
|
||||
_fold: fold<T>,
|
||||
doc: doc::itemdoc
|
||||
) -> doc::itemdoc {
|
||||
_fold: Fold<T>,
|
||||
doc: doc::ItemDoc
|
||||
) -> doc::ItemDoc {
|
||||
doc
|
||||
}
|
||||
|
||||
fn default_any_fold_mod<T:Send Copy>(
|
||||
fold: fold<T>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
doc::moddoc_({
|
||||
fold: Fold<T>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
doc::ModDoc_({
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: par::map(doc.items, |itemtag, copy fold| {
|
||||
fold_itemtag(fold, itemtag)
|
||||
items: par::map(doc.items, |ItemTag, copy fold| {
|
||||
fold_ItemTag(fold, ItemTag)
|
||||
}),
|
||||
.. *doc
|
||||
})
|
||||
}
|
||||
|
||||
fn default_seq_fold_mod<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
doc::moddoc_({
|
||||
fold: Fold<T>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
doc::ModDoc_({
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: vec::map(doc.items, |itemtag| {
|
||||
fold_itemtag(fold, itemtag)
|
||||
items: vec::map(doc.items, |ItemTag| {
|
||||
fold_ItemTag(fold, ItemTag)
|
||||
}),
|
||||
.. *doc
|
||||
})
|
||||
}
|
||||
|
||||
fn default_par_fold_mod<T:Send Copy>(
|
||||
fold: fold<T>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
doc::moddoc_({
|
||||
fold: Fold<T>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
doc::ModDoc_({
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: par::map(doc.items, |itemtag, copy fold| {
|
||||
fold_itemtag(fold, itemtag)
|
||||
items: par::map(doc.items, |ItemTag, copy fold| {
|
||||
fold_ItemTag(fold, ItemTag)
|
||||
}),
|
||||
.. *doc
|
||||
})
|
||||
}
|
||||
|
||||
fn default_any_fold_nmod<T:Send Copy>(
|
||||
fold: fold<T>,
|
||||
doc: doc::nmoddoc
|
||||
) -> doc::nmoddoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: par::map(doc.fns, |fndoc, copy fold| {
|
||||
fold.fold_fn(fold, fndoc)
|
||||
fns: par::map(doc.fns, |FnDoc, copy fold| {
|
||||
fold.fold_fn(fold, FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
|
||||
fn default_seq_fold_nmod<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::nmoddoc
|
||||
) -> doc::nmoddoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: vec::map(doc.fns, |fndoc| {
|
||||
fold.fold_fn(fold, fndoc)
|
||||
fns: vec::map(doc.fns, |FnDoc| {
|
||||
fold.fold_fn(fold, FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
|
||||
fn default_par_fold_nmod<T:Send Copy>(
|
||||
fold: fold<T>,
|
||||
doc: doc::nmoddoc
|
||||
) -> doc::nmoddoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: par::map(doc.fns, |fndoc, copy fold| {
|
||||
fold.fold_fn(fold, fndoc)
|
||||
fns: par::map(doc.fns, |FnDoc, copy fold| {
|
||||
fold.fold_fn(fold, FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_itemtag<T>(fold: fold<T>, doc: doc::itemtag) -> doc::itemtag {
|
||||
fn fold_ItemTag<T>(fold: Fold<T>, doc: doc::ItemTag) -> doc::ItemTag {
|
||||
match doc {
|
||||
doc::modtag(moddoc) => {
|
||||
doc::modtag(fold.fold_mod(fold, moddoc))
|
||||
doc::ModTag(ModDoc) => {
|
||||
doc::ModTag(fold.fold_mod(fold, ModDoc))
|
||||
}
|
||||
doc::nmodtag(nmoddoc) => {
|
||||
doc::nmodtag(fold.fold_nmod(fold, nmoddoc))
|
||||
doc::NmodTag(nModDoc) => {
|
||||
doc::NmodTag(fold.fold_nmod(fold, nModDoc))
|
||||
}
|
||||
doc::fntag(fndoc) => {
|
||||
doc::fntag(fold.fold_fn(fold, fndoc))
|
||||
doc::FnTag(FnDoc) => {
|
||||
doc::FnTag(fold.fold_fn(fold, FnDoc))
|
||||
}
|
||||
doc::consttag(constdoc) => {
|
||||
doc::consttag(fold.fold_const(fold, constdoc))
|
||||
doc::ConstTag(ConstDoc) => {
|
||||
doc::ConstTag(fold.fold_const(fold, ConstDoc))
|
||||
}
|
||||
doc::enumtag(enumdoc) => {
|
||||
doc::enumtag(fold.fold_enum(fold, enumdoc))
|
||||
doc::EnumTag(EnumDoc) => {
|
||||
doc::EnumTag(fold.fold_enum(fold, EnumDoc))
|
||||
}
|
||||
doc::traittag(traitdoc) => {
|
||||
doc::traittag(fold.fold_trait(fold, traitdoc))
|
||||
doc::TraitTag(TraitDoc) => {
|
||||
doc::TraitTag(fold.fold_trait(fold, TraitDoc))
|
||||
}
|
||||
doc::impltag(impldoc) => {
|
||||
doc::impltag(fold.fold_impl(fold, impldoc))
|
||||
doc::ImplTag(ImplDoc) => {
|
||||
doc::ImplTag(fold.fold_impl(fold, ImplDoc))
|
||||
}
|
||||
doc::tytag(tydoc) => {
|
||||
doc::tytag(fold.fold_type(fold, tydoc))
|
||||
doc::TyTag(TyDoc) => {
|
||||
doc::TyTag(fold.fold_type(fold, TyDoc))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_seq_fold_fn<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::fndoc
|
||||
) -> doc::fndoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::FnDoc
|
||||
) -> doc::FnDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. doc
|
||||
|
@ -281,9 +281,9 @@ fn default_seq_fold_fn<T>(
|
|||
}
|
||||
|
||||
fn default_seq_fold_const<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::constdoc
|
||||
) -> doc::constdoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::ConstDoc
|
||||
) -> doc::ConstDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. doc
|
||||
|
@ -291,9 +291,9 @@ fn default_seq_fold_const<T>(
|
|||
}
|
||||
|
||||
fn default_seq_fold_enum<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::enumdoc
|
||||
) -> doc::enumdoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::EnumDoc
|
||||
) -> doc::EnumDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. doc
|
||||
|
@ -301,9 +301,9 @@ fn default_seq_fold_enum<T>(
|
|||
}
|
||||
|
||||
fn default_seq_fold_trait<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::traitdoc
|
||||
) -> doc::traitdoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::TraitDoc
|
||||
) -> doc::TraitDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. doc
|
||||
|
@ -311,9 +311,9 @@ fn default_seq_fold_trait<T>(
|
|||
}
|
||||
|
||||
fn default_seq_fold_impl<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::impldoc
|
||||
) -> doc::impldoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::ImplDoc
|
||||
) -> doc::ImplDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. doc
|
||||
|
@ -321,9 +321,9 @@ fn default_seq_fold_impl<T>(
|
|||
}
|
||||
|
||||
fn default_seq_fold_type<T>(
|
||||
fold: fold<T>,
|
||||
doc: doc::tydoc
|
||||
) -> doc::tydoc {
|
||||
fold: Fold<T>,
|
||||
doc: doc::TyDoc
|
||||
) -> doc::TyDoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. doc
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
//! Build indexes as appropriate for the markdown pass
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass(config: config::config) -> pass {
|
||||
fn mk_pass(config: config::Config) -> Pass {
|
||||
{
|
||||
name: ~"markdown_index",
|
||||
f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
f: fn~(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc,
|
||||
config: config::config
|
||||
) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc,
|
||||
config: config::Config
|
||||
) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_mod: fold_mod,
|
||||
fold_nmod: fold_nmod,
|
||||
.. *fold::default_any_fold(config)
|
||||
|
@ -27,22 +27,22 @@ fn run(
|
|||
}
|
||||
|
||||
fn fold_mod(
|
||||
fold: fold::fold<config::config>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
fold: fold::Fold<config::Config>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
|
||||
doc::moddoc_({
|
||||
doc::ModDoc_({
|
||||
index: Some(build_mod_index(doc, fold.ctxt)),
|
||||
.. *doc
|
||||
})
|
||||
}
|
||||
|
||||
fn fold_nmod(
|
||||
fold: fold::fold<config::config>,
|
||||
doc: doc::nmoddoc
|
||||
) -> doc::nmoddoc {
|
||||
fold: fold::Fold<config::Config>,
|
||||
doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
|
||||
let doc = fold::default_any_fold_nmod(fold, doc);
|
||||
|
||||
|
@ -53,9 +53,9 @@ fn fold_nmod(
|
|||
}
|
||||
|
||||
fn build_mod_index(
|
||||
doc: doc::moddoc,
|
||||
config: config::config
|
||||
) -> doc::index {
|
||||
doc: doc::ModDoc,
|
||||
config: config::Config
|
||||
) -> doc::Index {
|
||||
{
|
||||
entries: par::map(doc.items, |doc| {
|
||||
item_to_entry(doc, config)
|
||||
|
@ -64,24 +64,24 @@ fn build_mod_index(
|
|||
}
|
||||
|
||||
fn build_nmod_index(
|
||||
doc: doc::nmoddoc,
|
||||
config: config::config
|
||||
) -> doc::index {
|
||||
doc: doc::NmodDoc,
|
||||
config: config::Config
|
||||
) -> doc::Index {
|
||||
{
|
||||
entries: par::map(doc.fns, |doc| {
|
||||
item_to_entry(doc::fntag(doc), config)
|
||||
item_to_entry(doc::FnTag(doc), config)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn item_to_entry(
|
||||
doc: doc::itemtag,
|
||||
config: config::config
|
||||
) -> doc::index_entry {
|
||||
doc: doc::ItemTag,
|
||||
config: config::Config
|
||||
) -> doc::IndexEntry {
|
||||
let link = match doc {
|
||||
doc::modtag(_) | doc::nmodtag(_)
|
||||
if config.output_style == config::doc_per_mod => {
|
||||
markdown_writer::make_filename(config, doc::itempage(doc)).to_str()
|
||||
doc::ModTag(_) | doc::NmodTag(_)
|
||||
if config.output_style == config::DocPerMod => {
|
||||
markdown_writer::make_filename(config, doc::ItemPage(doc)).to_str()
|
||||
}
|
||||
_ => {
|
||||
~"#" + pandoc_header_id(markdown_pass::header_text(doc))
|
||||
|
@ -149,7 +149,7 @@ fn should_remove_punctuation_from_headers() {
|
|||
#[test]
|
||||
fn should_index_mod_contents() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_crate,
|
||||
config::DocPerCrate,
|
||||
~"mod a { } fn b() { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
|
@ -169,7 +169,7 @@ fn should_index_mod_contents() {
|
|||
#[test]
|
||||
fn should_index_mod_contents_multi_page() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_mod,
|
||||
config::DocPerMod,
|
||||
~"mod a { } fn b() { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
|
@ -189,7 +189,7 @@ fn should_index_mod_contents_multi_page() {
|
|||
#[test]
|
||||
fn should_index_foreign_mod_pages() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_mod,
|
||||
config::DocPerMod,
|
||||
~"extern mod a { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
|
@ -203,7 +203,7 @@ fn should_index_foreign_mod_pages() {
|
|||
#[test]
|
||||
fn should_add_brief_desc_to_index() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_mod,
|
||||
config::DocPerMod,
|
||||
~"#[doc = \"test\"] mod a { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0].brief
|
||||
|
@ -213,7 +213,7 @@ fn should_add_brief_desc_to_index() {
|
|||
#[test]
|
||||
fn should_index_foreign_mod_contents() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_crate,
|
||||
config::DocPerCrate,
|
||||
~"extern mod a { fn b(); }"
|
||||
);
|
||||
assert option::get(doc.cratemod().nmods()[0].index).entries[0] == {
|
||||
|
@ -226,7 +226,7 @@ fn should_index_foreign_mod_contents() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(output_style: config::output_style, source: ~str) -> doc::doc {
|
||||
fn mk_doc(output_style: config::OutputStyle, source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let config = {
|
||||
output_style: output_style,
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
//! Generate markdown from a document tree
|
||||
|
||||
use doc::item_utils;
|
||||
use markdown_writer::writer;
|
||||
use markdown_writer::writer_utils;
|
||||
use markdown_writer::writer_factory;
|
||||
use doc::ItemUtils;
|
||||
use markdown_writer::Writer;
|
||||
use markdown_writer::WriterUtils;
|
||||
use markdown_writer::WriterFactory;
|
||||
|
||||
export mk_pass;
|
||||
export header_kind, header_name, header_text;
|
||||
|
||||
fn mk_pass(+writer_factory: writer_factory) -> pass {
|
||||
let f = fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
fn mk_pass(+writer_factory: WriterFactory) -> Pass {
|
||||
let f = fn~(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, copy writer_factory)
|
||||
};
|
||||
|
||||
|
@ -20,15 +20,15 @@ fn mk_pass(+writer_factory: writer_factory) -> pass {
|
|||
}
|
||||
|
||||
fn run(
|
||||
srv: astsrv::srv,
|
||||
doc: doc::doc,
|
||||
+writer_factory: writer_factory
|
||||
) -> doc::doc {
|
||||
srv: astsrv::Srv,
|
||||
doc: doc::Doc,
|
||||
+writer_factory: WriterFactory
|
||||
) -> doc::Doc {
|
||||
|
||||
pure fn mods_last(item1: &doc::itemtag, item2: &doc::itemtag) -> bool {
|
||||
pure fn is_mod(item: &doc::itemtag) -> bool {
|
||||
pure fn mods_last(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
|
||||
pure fn is_mod(item: &doc::ItemTag) -> bool {
|
||||
match *item {
|
||||
doc::modtag(_) => true,
|
||||
doc::ModTag(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ fn should_write_modules_last() {
|
|||
assert idx_a < idx_c;
|
||||
}
|
||||
|
||||
type ctxt = {
|
||||
w: writer
|
||||
type Ctxt = {
|
||||
w: Writer
|
||||
};
|
||||
|
||||
fn write_markdown(
|
||||
doc: doc::doc,
|
||||
+writer_factory: writer_factory
|
||||
doc: doc::Doc,
|
||||
+writer_factory: WriterFactory
|
||||
) {
|
||||
// FIXME #2484: There is easy parallelism to be had here but
|
||||
// we don't want to spawn too many pandoc processes
|
||||
|
@ -93,13 +93,13 @@ fn write_markdown(
|
|||
};
|
||||
}
|
||||
|
||||
fn write_page(ctxt: ctxt, page: doc::page) {
|
||||
fn write_page(ctxt: Ctxt, page: doc::Page) {
|
||||
write_title(ctxt, page);
|
||||
match page {
|
||||
doc::cratepage(doc) => {
|
||||
doc::CratePage(doc) => {
|
||||
write_crate(ctxt, doc);
|
||||
}
|
||||
doc::itempage(doc) => {
|
||||
doc::ItemPage(doc) => {
|
||||
// We don't write a header for item's pages because their
|
||||
// header in the html output is created by the page title
|
||||
write_item_no_header(ctxt, doc);
|
||||
|
@ -115,7 +115,7 @@ fn should_request_new_writer_for_each_page() {
|
|||
let (writer_factory, po) = markdown_writer::future_writer_factory();
|
||||
let (srv, doc) = test::create_doc_srv(~"mod a { }");
|
||||
// Split the document up into pages
|
||||
let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc);
|
||||
let doc = page_pass::mk_pass(config::DocPerMod).f(srv, doc);
|
||||
write_markdown(doc, writer_factory);
|
||||
// We expect two pages to have been written
|
||||
for iter::repeat(2u) {
|
||||
|
@ -123,18 +123,18 @@ fn should_request_new_writer_for_each_page() {
|
|||
}
|
||||
}
|
||||
|
||||
fn write_title(ctxt: ctxt, page: doc::page) {
|
||||
fn write_title(ctxt: Ctxt, page: doc::Page) {
|
||||
ctxt.w.write_line(fmt!("%% %s", make_title(page)));
|
||||
ctxt.w.write_line(~"");
|
||||
}
|
||||
|
||||
fn make_title(page: doc::page) -> ~str {
|
||||
fn make_title(page: doc::Page) -> ~str {
|
||||
let item = match page {
|
||||
doc::cratepage(cratedoc) => {
|
||||
doc::modtag(cratedoc.topmod)
|
||||
doc::CratePage(CrateDoc) => {
|
||||
doc::ModTag(CrateDoc.topmod)
|
||||
}
|
||||
doc::itempage(itemtag) => {
|
||||
itemtag
|
||||
doc::ItemPage(ItemTag) => {
|
||||
ItemTag
|
||||
}
|
||||
};
|
||||
let title = markdown_pass::header_text(item);
|
||||
|
@ -147,82 +147,82 @@ fn should_write_title_for_each_page() {
|
|||
let (writer_factory, po) = markdown_writer::future_writer_factory();
|
||||
let (srv, doc) = test::create_doc_srv(
|
||||
~"#[link(name = \"core\")]; mod a { }");
|
||||
let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc);
|
||||
let doc = page_pass::mk_pass(config::DocPerMod).f(srv, doc);
|
||||
write_markdown(doc, writer_factory);
|
||||
for iter::repeat(2u) {
|
||||
let (page, markdown) = comm::recv(po);
|
||||
match page {
|
||||
doc::cratepage(_) => {
|
||||
doc::CratePage(_) => {
|
||||
assert str::contains(markdown, ~"% Crate core");
|
||||
}
|
||||
doc::itempage(_) => {
|
||||
doc::ItemPage(_) => {
|
||||
assert str::contains(markdown, ~"% Module a");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum hlvl {
|
||||
h1 = 1,
|
||||
h2 = 2,
|
||||
h3 = 3,
|
||||
h4 = 4
|
||||
enum Hlvl {
|
||||
H1 = 1,
|
||||
H2 = 2,
|
||||
H3 = 3,
|
||||
H4 = 4
|
||||
}
|
||||
|
||||
fn write_header(ctxt: ctxt, lvl: hlvl, doc: doc::itemtag) {
|
||||
fn write_header(ctxt: Ctxt, lvl: Hlvl, doc: doc::ItemTag) {
|
||||
let text = header_text(doc);
|
||||
write_header_(ctxt, lvl, text);
|
||||
}
|
||||
|
||||
fn write_header_(ctxt: ctxt, lvl: hlvl, title: ~str) {
|
||||
fn write_header_(ctxt: Ctxt, lvl: Hlvl, title: ~str) {
|
||||
let hashes = str::from_chars(vec::from_elem(lvl as uint, '#'));
|
||||
ctxt.w.write_line(fmt!("%s %s", hashes, title));
|
||||
ctxt.w.write_line(~"");
|
||||
}
|
||||
|
||||
fn header_kind(doc: doc::itemtag) -> ~str {
|
||||
fn header_kind(doc: doc::ItemTag) -> ~str {
|
||||
match doc {
|
||||
doc::modtag(_) => {
|
||||
doc::ModTag(_) => {
|
||||
if doc.id() == syntax::ast::crate_node_id {
|
||||
~"Crate"
|
||||
} else {
|
||||
~"Module"
|
||||
}
|
||||
}
|
||||
doc::nmodtag(_) => {
|
||||
doc::NmodTag(_) => {
|
||||
~"Foreign module"
|
||||
}
|
||||
doc::fntag(_) => {
|
||||
doc::FnTag(_) => {
|
||||
~"Function"
|
||||
}
|
||||
doc::consttag(_) => {
|
||||
doc::ConstTag(_) => {
|
||||
~"Const"
|
||||
}
|
||||
doc::enumtag(_) => {
|
||||
doc::EnumTag(_) => {
|
||||
~"Enum"
|
||||
}
|
||||
doc::traittag(_) => {
|
||||
doc::TraitTag(_) => {
|
||||
~"Interface"
|
||||
}
|
||||
doc::impltag(_) => {
|
||||
doc::ImplTag(_) => {
|
||||
~"Implementation"
|
||||
}
|
||||
doc::tytag(_) => {
|
||||
doc::TyTag(_) => {
|
||||
~"Type"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn header_name(doc: doc::itemtag) -> ~str {
|
||||
fn header_name(doc: doc::ItemTag) -> ~str {
|
||||
let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::");
|
||||
match doc {
|
||||
doc::modtag(_) if doc.id() != syntax::ast::crate_node_id => {
|
||||
doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
|
||||
fullpath
|
||||
}
|
||||
doc::nmodtag(_) => {
|
||||
doc::NmodTag(_) => {
|
||||
fullpath
|
||||
}
|
||||
doc::impltag(doc) => {
|
||||
doc::ImplTag(doc) => {
|
||||
assert option::is_some(doc.self_ty);
|
||||
let self_ty = option::get(doc.self_ty);
|
||||
let mut trait_part = ~"";
|
||||
|
@ -242,15 +242,15 @@ fn header_name(doc: doc::itemtag) -> ~str {
|
|||
}
|
||||
}
|
||||
|
||||
fn header_text(doc: doc::itemtag) -> ~str {
|
||||
fn header_text(doc: doc::ItemTag) -> ~str {
|
||||
match doc {
|
||||
doc::impltag(impldoc) => {
|
||||
doc::ImplTag(ImplDoc) => {
|
||||
let header_kind = header_kind(doc);
|
||||
let desc = if impldoc.trait_types.is_empty() {
|
||||
fmt!("for `%s`", impldoc.self_ty.get())
|
||||
let desc = if ImplDoc.trait_types.is_empty() {
|
||||
fmt!("for `%s`", ImplDoc.self_ty.get())
|
||||
} else {
|
||||
fmt!("of `%s` for `%s`", impldoc.trait_types[0],
|
||||
impldoc.self_ty.get())
|
||||
fmt!("of `%s` for `%s`", ImplDoc.trait_types[0],
|
||||
ImplDoc.self_ty.get())
|
||||
};
|
||||
fmt!("%s %s", header_kind, desc)
|
||||
}
|
||||
|
@ -265,24 +265,24 @@ fn header_text_(kind: ~str, name: ~str) -> ~str {
|
|||
}
|
||||
|
||||
fn write_crate(
|
||||
ctxt: ctxt,
|
||||
doc: doc::cratedoc
|
||||
ctxt: Ctxt,
|
||||
doc: doc::CrateDoc
|
||||
) {
|
||||
write_top_module(ctxt, doc.topmod);
|
||||
}
|
||||
|
||||
fn write_top_module(
|
||||
ctxt: ctxt,
|
||||
moddoc: doc::moddoc
|
||||
ctxt: Ctxt,
|
||||
ModDoc: doc::ModDoc
|
||||
) {
|
||||
write_mod_contents(ctxt, moddoc);
|
||||
write_mod_contents(ctxt, ModDoc);
|
||||
}
|
||||
|
||||
fn write_mod(
|
||||
ctxt: ctxt,
|
||||
moddoc: doc::moddoc
|
||||
ctxt: Ctxt,
|
||||
ModDoc: doc::ModDoc
|
||||
) {
|
||||
write_mod_contents(ctxt, moddoc);
|
||||
write_mod_contents(ctxt, ModDoc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -292,16 +292,16 @@ fn should_write_full_path_to_mod() {
|
|||
}
|
||||
|
||||
fn write_common(
|
||||
ctxt: ctxt,
|
||||
ctxt: Ctxt,
|
||||
desc: Option<~str>,
|
||||
sections: ~[doc::section]
|
||||
sections: ~[doc::Section]
|
||||
) {
|
||||
write_desc(ctxt, desc);
|
||||
write_sections(ctxt, sections);
|
||||
}
|
||||
|
||||
fn write_desc(
|
||||
ctxt: ctxt,
|
||||
ctxt: Ctxt,
|
||||
desc: Option<~str>
|
||||
) {
|
||||
match desc {
|
||||
|
@ -313,14 +313,14 @@ fn write_desc(
|
|||
}
|
||||
}
|
||||
|
||||
fn write_sections(ctxt: ctxt, sections: ~[doc::section]) {
|
||||
fn write_sections(ctxt: Ctxt, sections: ~[doc::Section]) {
|
||||
do vec::iter(sections) |section| {
|
||||
write_section(ctxt, section);
|
||||
}
|
||||
}
|
||||
|
||||
fn write_section(ctxt: ctxt, section: doc::section) {
|
||||
write_header_(ctxt, h4, section.header);
|
||||
fn write_section(ctxt: Ctxt, section: doc::Section) {
|
||||
write_header_(ctxt, H4, section.header);
|
||||
ctxt.w.write_line(section.body);
|
||||
ctxt.w.write_line(~"");
|
||||
}
|
||||
|
@ -336,52 +336,52 @@ fn should_write_sections() {
|
|||
}
|
||||
|
||||
fn write_mod_contents(
|
||||
ctxt: ctxt,
|
||||
doc: doc::moddoc
|
||||
ctxt: Ctxt,
|
||||
doc: doc::ModDoc
|
||||
) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
if option::is_some(doc.index) {
|
||||
write_index(ctxt, option::get(doc.index));
|
||||
}
|
||||
|
||||
for doc.items.each |itemtag| {
|
||||
write_item(ctxt, itemtag);
|
||||
for doc.items.each |ItemTag| {
|
||||
write_item(ctxt, ItemTag);
|
||||
}
|
||||
}
|
||||
|
||||
fn write_item(ctxt: ctxt, doc: doc::itemtag) {
|
||||
fn write_item(ctxt: Ctxt, doc: doc::ItemTag) {
|
||||
write_item_(ctxt, doc, true);
|
||||
}
|
||||
|
||||
fn write_item_no_header(ctxt: ctxt, doc: doc::itemtag) {
|
||||
fn write_item_no_header(ctxt: Ctxt, doc: doc::ItemTag) {
|
||||
write_item_(ctxt, doc, false);
|
||||
}
|
||||
|
||||
fn write_item_(ctxt: ctxt, doc: doc::itemtag, write_header: bool) {
|
||||
fn write_item_(ctxt: Ctxt, doc: doc::ItemTag, write_header: bool) {
|
||||
if write_header {
|
||||
write_item_header(ctxt, doc);
|
||||
}
|
||||
|
||||
match doc {
|
||||
doc::modtag(moddoc) => write_mod(ctxt, moddoc),
|
||||
doc::nmodtag(nmoddoc) => write_nmod(ctxt, nmoddoc),
|
||||
doc::fntag(fndoc) => write_fn(ctxt, fndoc),
|
||||
doc::consttag(constdoc) => write_const(ctxt, constdoc),
|
||||
doc::enumtag(enumdoc) => write_enum(ctxt, enumdoc),
|
||||
doc::traittag(traitdoc) => write_trait(ctxt, traitdoc),
|
||||
doc::impltag(impldoc) => write_impl(ctxt, impldoc),
|
||||
doc::tytag(tydoc) => write_type(ctxt, tydoc)
|
||||
doc::ModTag(ModDoc) => write_mod(ctxt, ModDoc),
|
||||
doc::NmodTag(nModDoc) => write_nmod(ctxt, nModDoc),
|
||||
doc::FnTag(FnDoc) => write_fn(ctxt, FnDoc),
|
||||
doc::ConstTag(ConstDoc) => write_const(ctxt, ConstDoc),
|
||||
doc::EnumTag(EnumDoc) => write_enum(ctxt, EnumDoc),
|
||||
doc::TraitTag(TraitDoc) => write_trait(ctxt, TraitDoc),
|
||||
doc::ImplTag(ImplDoc) => write_impl(ctxt, ImplDoc),
|
||||
doc::TyTag(TyDoc) => write_type(ctxt, TyDoc)
|
||||
}
|
||||
}
|
||||
|
||||
fn write_item_header(ctxt: ctxt, doc: doc::itemtag) {
|
||||
fn write_item_header(ctxt: Ctxt, doc: doc::ItemTag) {
|
||||
write_header(ctxt, item_header_lvl(doc), doc);
|
||||
}
|
||||
|
||||
fn item_header_lvl(doc: doc::itemtag) -> hlvl {
|
||||
fn item_header_lvl(doc: doc::ItemTag) -> Hlvl {
|
||||
match doc {
|
||||
doc::modtag(_) | doc::nmodtag(_) => h1,
|
||||
_ => h2
|
||||
doc::ModTag(_) | doc::NmodTag(_) => H1,
|
||||
_ => H2
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ fn should_write_crate_description() {
|
|||
assert str::contains(markdown, ~"this is the crate");
|
||||
}
|
||||
|
||||
fn write_index(ctxt: ctxt, index: doc::index) {
|
||||
fn write_index(ctxt: Ctxt, index: doc::Index) {
|
||||
if vec::is_empty(index.entries) {
|
||||
return;
|
||||
}
|
||||
|
@ -440,15 +440,15 @@ fn should_write_index_for_foreign_mods() {
|
|||
);
|
||||
}
|
||||
|
||||
fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
|
||||
fn write_nmod(ctxt: Ctxt, doc: doc::NmodDoc) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
if option::is_some(doc.index) {
|
||||
write_index(ctxt, option::get(doc.index));
|
||||
}
|
||||
|
||||
for doc.fns.each |fndoc| {
|
||||
write_item_header(ctxt, doc::fntag(fndoc));
|
||||
write_fn(ctxt, fndoc);
|
||||
for doc.fns.each |FnDoc| {
|
||||
write_item_header(ctxt, doc::FnTag(FnDoc));
|
||||
write_fn(ctxt, FnDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,8 +474,8 @@ fn should_write_foreign_fn_headers() {
|
|||
}
|
||||
|
||||
fn write_fn(
|
||||
ctxt: ctxt,
|
||||
doc: doc::fndoc
|
||||
ctxt: Ctxt,
|
||||
doc: doc::FnDoc
|
||||
) {
|
||||
write_fnlike(
|
||||
ctxt,
|
||||
|
@ -486,16 +486,16 @@ fn write_fn(
|
|||
}
|
||||
|
||||
fn write_fnlike(
|
||||
ctxt: ctxt,
|
||||
ctxt: Ctxt,
|
||||
sig: Option<~str>,
|
||||
desc: Option<~str>,
|
||||
sections: ~[doc::section]
|
||||
sections: ~[doc::Section]
|
||||
) {
|
||||
write_sig(ctxt, sig);
|
||||
write_common(ctxt, desc, sections);
|
||||
}
|
||||
|
||||
fn write_sig(ctxt: ctxt, sig: Option<~str>) {
|
||||
fn write_sig(ctxt: Ctxt, sig: Option<~str>) {
|
||||
match sig {
|
||||
Some(sig) => {
|
||||
ctxt.w.write_line(code_block_indent(sig));
|
||||
|
@ -532,17 +532,17 @@ fn should_insert_blank_line_after_fn_signature() {
|
|||
#[test]
|
||||
fn should_correctly_indent_fn_signature() {
|
||||
let doc = test::create_doc(~"fn a() { }");
|
||||
let doc = doc::doc_({
|
||||
let doc = doc::Doc_({
|
||||
pages: ~[
|
||||
doc::cratepage({
|
||||
topmod: doc::moddoc_({
|
||||
items: ~[doc::fntag({
|
||||
doc::CratePage({
|
||||
topmod: doc::ModDoc_({
|
||||
items: ~[doc::FnTag({
|
||||
sig: Some(~"line 1\nline 2"),
|
||||
.. doc.cratemod().fns()[0]
|
||||
})],
|
||||
.. *doc.cratemod()
|
||||
}),
|
||||
.. doc.cratedoc()
|
||||
.. doc.CrateDoc()
|
||||
})
|
||||
]
|
||||
});
|
||||
|
@ -557,8 +557,8 @@ fn should_leave_blank_line_between_fn_header_and_sig() {
|
|||
}
|
||||
|
||||
fn write_const(
|
||||
ctxt: ctxt,
|
||||
doc: doc::constdoc
|
||||
ctxt: Ctxt,
|
||||
doc: doc::ConstDoc
|
||||
) {
|
||||
write_sig(ctxt, doc.sig);
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
|
@ -579,8 +579,8 @@ fn should_write_const_description() {
|
|||
}
|
||||
|
||||
fn write_enum(
|
||||
ctxt: ctxt,
|
||||
doc: doc::enumdoc
|
||||
ctxt: Ctxt,
|
||||
doc: doc::EnumDoc
|
||||
) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
write_variants(ctxt, doc.variants);
|
||||
|
@ -600,21 +600,21 @@ fn should_write_enum_description() {
|
|||
}
|
||||
|
||||
fn write_variants(
|
||||
ctxt: ctxt,
|
||||
docs: ~[doc::variantdoc]
|
||||
ctxt: Ctxt,
|
||||
docs: ~[doc::VariantDoc]
|
||||
) {
|
||||
if vec::is_empty(docs) {
|
||||
return;
|
||||
}
|
||||
|
||||
write_header_(ctxt, h4, ~"Variants");
|
||||
write_header_(ctxt, H4, ~"Variants");
|
||||
|
||||
vec::iter(docs, |variant| write_variant(ctxt, variant) );
|
||||
|
||||
ctxt.w.write_line(~"");
|
||||
}
|
||||
|
||||
fn write_variant(ctxt: ctxt, doc: doc::variantdoc) {
|
||||
fn write_variant(ctxt: Ctxt, doc: doc::VariantDoc) {
|
||||
assert option::is_some(doc.sig);
|
||||
let sig = option::get(doc.sig);
|
||||
match doc.desc {
|
||||
|
@ -660,17 +660,17 @@ fn should_write_variant_list_with_signatures() {
|
|||
\n* `c(int)` - a\n\n");
|
||||
}
|
||||
|
||||
fn write_trait(ctxt: ctxt, doc: doc::traitdoc) {
|
||||
fn write_trait(ctxt: Ctxt, doc: doc::TraitDoc) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
write_methods(ctxt, doc.methods);
|
||||
}
|
||||
|
||||
fn write_methods(ctxt: ctxt, docs: ~[doc::methoddoc]) {
|
||||
fn write_methods(ctxt: Ctxt, docs: ~[doc::MethodDoc]) {
|
||||
do vec::iter(docs) |doc| { write_method(ctxt, doc) }
|
||||
}
|
||||
|
||||
fn write_method(ctxt: ctxt, doc: doc::methoddoc) {
|
||||
write_header_(ctxt, h3, header_text_(~"Method", doc.name));
|
||||
fn write_method(ctxt: Ctxt, doc: doc::MethodDoc) {
|
||||
write_header_(ctxt, H3, header_text_(~"Method", doc.name));
|
||||
write_fnlike(
|
||||
ctxt,
|
||||
doc.sig,
|
||||
|
@ -706,7 +706,7 @@ fn should_write_trait_method_signature() {
|
|||
assert str::contains(markdown, ~"\n fn a()");
|
||||
}
|
||||
|
||||
fn write_impl(ctxt: ctxt, doc: doc::impldoc) {
|
||||
fn write_impl(ctxt: Ctxt, doc: doc::ImplDoc) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
write_methods(ctxt, doc.methods);
|
||||
}
|
||||
|
@ -745,8 +745,8 @@ fn should_write_impl_method_signature() {
|
|||
}
|
||||
|
||||
fn write_type(
|
||||
ctxt: ctxt,
|
||||
doc: doc::tydoc
|
||||
ctxt: Ctxt,
|
||||
doc: doc::TyDoc
|
||||
) {
|
||||
write_sig(ctxt, doc.sig);
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
|
@ -780,11 +780,11 @@ mod test {
|
|||
markdown
|
||||
}
|
||||
|
||||
fn create_doc_srv(source: ~str) -> (astsrv::srv, doc::doc) {
|
||||
fn create_doc_srv(source: ~str) -> (astsrv::Srv, doc::Doc) {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
|
||||
let config = {
|
||||
output_style: config::doc_per_crate,
|
||||
output_style: config::DocPerCrate,
|
||||
.. config::default_config(&Path("whatever"))
|
||||
};
|
||||
|
||||
|
@ -810,13 +810,13 @@ mod test {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_doc(source: ~str) -> doc::doc {
|
||||
fn create_doc(source: ~str) -> doc::Doc {
|
||||
let (_, doc) = create_doc_srv(source);
|
||||
doc
|
||||
}
|
||||
|
||||
fn write_markdown_str(
|
||||
doc: doc::doc
|
||||
doc: doc::Doc
|
||||
) -> ~str {
|
||||
let (writer_factory, po) = markdown_writer::future_writer_factory();
|
||||
write_markdown(doc, writer_factory);
|
||||
|
@ -824,8 +824,8 @@ mod test {
|
|||
}
|
||||
|
||||
fn write_markdown_str_srv(
|
||||
srv: astsrv::srv,
|
||||
doc: doc::doc
|
||||
srv: astsrv::Srv,
|
||||
doc: doc::Doc
|
||||
) -> ~str {
|
||||
let (writer_factory, po) = markdown_writer::future_writer_factory();
|
||||
let pass = mk_pass(writer_factory);
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
use io::ReaderUtil;
|
||||
|
||||
export writeinstr;
|
||||
export writer;
|
||||
export writer_factory;
|
||||
export writer_util;
|
||||
export writer_utils;
|
||||
export WriteInstr;
|
||||
export Writer;
|
||||
export WriterFactory;
|
||||
export WriterUtils;
|
||||
export make_writer_factory;
|
||||
export future_writer_factory;
|
||||
export make_filename;
|
||||
|
||||
enum writeinstr {
|
||||
write(~str),
|
||||
done
|
||||
enum WriteInstr {
|
||||
Write(~str),
|
||||
Done
|
||||
}
|
||||
|
||||
type writer = fn~(+writeinstr);
|
||||
type writer_factory = fn~(page: doc::page) -> writer;
|
||||
type Writer = fn~(+WriteInstr);
|
||||
type WriterFactory = fn~(page: doc::Page) -> Writer;
|
||||
|
||||
trait writer_utils {
|
||||
trait WriterUtils {
|
||||
fn write_str(str: ~str);
|
||||
fn write_line(str: ~str);
|
||||
fn write_done();
|
||||
}
|
||||
|
||||
impl writer: writer_utils {
|
||||
impl Writer: WriterUtils {
|
||||
fn write_str(str: ~str) {
|
||||
self(write(str));
|
||||
self(Write(str));
|
||||
}
|
||||
|
||||
fn write_line(str: ~str) {
|
||||
|
@ -34,37 +33,37 @@ impl writer: writer_utils {
|
|||
}
|
||||
|
||||
fn write_done() {
|
||||
self(done)
|
||||
self(Done)
|
||||
}
|
||||
}
|
||||
|
||||
fn make_writer_factory(config: config::config) -> writer_factory {
|
||||
fn make_writer_factory(config: config::Config) -> WriterFactory {
|
||||
match config.output_format {
|
||||
config::markdown => {
|
||||
config::Markdown => {
|
||||
markdown_writer_factory(config)
|
||||
}
|
||||
config::pandoc_html => {
|
||||
config::PandocHtml => {
|
||||
pandoc_writer_factory(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn markdown_writer_factory(config: config::config) -> writer_factory {
|
||||
fn~(page: doc::page) -> writer {
|
||||
fn markdown_writer_factory(config: config::Config) -> WriterFactory {
|
||||
fn~(page: doc::Page) -> Writer {
|
||||
markdown_writer(config, page)
|
||||
}
|
||||
}
|
||||
|
||||
fn pandoc_writer_factory(config: config::config) -> writer_factory {
|
||||
fn~(page: doc::page) -> writer {
|
||||
fn pandoc_writer_factory(config: config::Config) -> WriterFactory {
|
||||
fn~(page: doc::Page) -> Writer {
|
||||
pandoc_writer(config, page)
|
||||
}
|
||||
}
|
||||
|
||||
fn markdown_writer(
|
||||
config: config::config,
|
||||
page: doc::page
|
||||
) -> writer {
|
||||
config: config::Config,
|
||||
page: doc::Page
|
||||
) -> Writer {
|
||||
let filename = make_local_filename(config, page);
|
||||
do generic_writer |markdown| {
|
||||
write_file(&filename, markdown);
|
||||
|
@ -72,9 +71,9 @@ fn markdown_writer(
|
|||
}
|
||||
|
||||
fn pandoc_writer(
|
||||
config: config::config,
|
||||
page: doc::page
|
||||
) -> writer {
|
||||
config: config::Config,
|
||||
page: doc::Page
|
||||
) -> Writer {
|
||||
assert option::is_some(config.pandoc_cmd);
|
||||
let pandoc_cmd = option::get(config.pandoc_cmd);
|
||||
let filename = make_local_filename(config, page);
|
||||
|
@ -146,55 +145,55 @@ fn readclose(fd: libc::c_int) -> ~str {
|
|||
return buf;
|
||||
}
|
||||
|
||||
fn generic_writer(+process: fn~(markdown: ~str)) -> writer {
|
||||
let ch = do task::spawn_listener |po: comm::Port<writeinstr>| {
|
||||
fn generic_writer(+process: fn~(markdown: ~str)) -> Writer {
|
||||
let ch = do task::spawn_listener |po: comm::Port<WriteInstr>| {
|
||||
let mut markdown = ~"";
|
||||
let mut keep_going = true;
|
||||
while keep_going {
|
||||
match comm::recv(po) {
|
||||
write(s) => markdown += s,
|
||||
done => keep_going = false
|
||||
Write(s) => markdown += s,
|
||||
Done => keep_going = false
|
||||
}
|
||||
}
|
||||
process(markdown);
|
||||
};
|
||||
|
||||
fn~(+instr: writeinstr) {
|
||||
fn~(+instr: WriteInstr) {
|
||||
comm::send(ch, instr);
|
||||
}
|
||||
}
|
||||
|
||||
fn make_local_filename(
|
||||
config: config::config,
|
||||
page: doc::page
|
||||
config: config::Config,
|
||||
page: doc::Page
|
||||
) -> Path {
|
||||
let filename = make_filename(config, page);
|
||||
config.output_dir.push_rel(&filename)
|
||||
}
|
||||
|
||||
fn make_filename(
|
||||
config: config::config,
|
||||
page: doc::page
|
||||
config: config::Config,
|
||||
page: doc::Page
|
||||
) -> Path {
|
||||
let filename = {
|
||||
match page {
|
||||
doc::cratepage(doc) => {
|
||||
if config.output_format == config::pandoc_html &&
|
||||
config.output_style == config::doc_per_mod {
|
||||
doc::CratePage(doc) => {
|
||||
if config.output_format == config::PandocHtml &&
|
||||
config.output_style == config::DocPerMod {
|
||||
~"index"
|
||||
} else {
|
||||
assert doc.topmod.name() != ~"";
|
||||
doc.topmod.name()
|
||||
}
|
||||
}
|
||||
doc::itempage(doc) => {
|
||||
doc::ItemPage(doc) => {
|
||||
str::connect(doc.path() + ~[doc.name()], ~"_")
|
||||
}
|
||||
}
|
||||
};
|
||||
let ext = match config.output_format {
|
||||
config::markdown => ~"md",
|
||||
config::pandoc_html => ~"html"
|
||||
config::Markdown => ~"md",
|
||||
config::PandocHtml => ~"html"
|
||||
};
|
||||
|
||||
Path(filename).with_filetype(ext)
|
||||
|
@ -204,12 +203,12 @@ fn make_filename(
|
|||
fn should_use_markdown_file_name_based_off_crate() {
|
||||
let config = {
|
||||
output_dir: Path("output/dir"),
|
||||
output_format: config::markdown,
|
||||
output_style: config::doc_per_crate,
|
||||
output_format: config::Markdown,
|
||||
output_style: config::DocPerCrate,
|
||||
.. config::default_config(&Path("input/test.rc"))
|
||||
};
|
||||
let doc = test::mk_doc(~"test", ~"");
|
||||
let page = doc::cratepage(doc.cratedoc());
|
||||
let page = doc::CratePage(doc.CrateDoc());
|
||||
let filename = make_local_filename(config, page);
|
||||
assert filename.to_str() == ~"output/dir/test.md";
|
||||
}
|
||||
|
@ -218,12 +217,12 @@ fn should_use_markdown_file_name_based_off_crate() {
|
|||
fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
|
||||
let config = {
|
||||
output_dir: Path("output/dir"),
|
||||
output_format: config::pandoc_html,
|
||||
output_style: config::doc_per_mod,
|
||||
output_format: config::PandocHtml,
|
||||
output_style: config::DocPerMod,
|
||||
.. config::default_config(&Path("input/test.rc"))
|
||||
};
|
||||
let doc = test::mk_doc(~"", ~"");
|
||||
let page = doc::cratepage(doc.cratedoc());
|
||||
let page = doc::CratePage(doc.CrateDoc());
|
||||
let filename = make_local_filename(config, page);
|
||||
assert filename.to_str() == ~"output/dir/index.html";
|
||||
}
|
||||
|
@ -232,20 +231,20 @@ fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
|
|||
fn should_name_mod_file_names_by_path() {
|
||||
let config = {
|
||||
output_dir: Path("output/dir"),
|
||||
output_format: config::pandoc_html,
|
||||
output_style: config::doc_per_mod,
|
||||
output_format: config::PandocHtml,
|
||||
output_style: config::DocPerMod,
|
||||
.. config::default_config(&Path("input/test.rc"))
|
||||
};
|
||||
let doc = test::mk_doc(~"", ~"mod a { mod b { } }");
|
||||
let modb = doc.cratemod().mods()[0].mods()[0];
|
||||
let page = doc::itempage(doc::modtag(modb));
|
||||
let page = doc::ItemPage(doc::ModTag(modb));
|
||||
let filename = make_local_filename(config, page);
|
||||
assert filename == Path("output/dir/a_b.html");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(name: ~str, source: ~str) -> doc::doc {
|
||||
fn mk_doc(name: ~str, source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, name);
|
||||
let doc = path_pass::mk_pass().f(srv, doc);
|
||||
|
@ -266,10 +265,10 @@ fn write_file(path: &Path, s: ~str) {
|
|||
}
|
||||
|
||||
fn future_writer_factory(
|
||||
) -> (writer_factory, comm::Port<(doc::page, ~str)>) {
|
||||
) -> (WriterFactory, comm::Port<(doc::Page, ~str)>) {
|
||||
let markdown_po = comm::Port();
|
||||
let markdown_ch = comm::Chan(markdown_po);
|
||||
let writer_factory = fn~(page: doc::page) -> writer {
|
||||
let writer_factory = fn~(page: doc::Page) -> Writer {
|
||||
let writer_po = comm::Port();
|
||||
let writer_ch = comm::Chan(writer_po);
|
||||
do task::spawn {
|
||||
|
@ -284,17 +283,17 @@ fn future_writer_factory(
|
|||
(writer_factory, markdown_po)
|
||||
}
|
||||
|
||||
fn future_writer() -> (writer, future::Future<~str>) {
|
||||
fn future_writer() -> (Writer, future::Future<~str>) {
|
||||
let (chan, port) = pipes::stream();
|
||||
let writer = fn~(+instr: writeinstr) {
|
||||
let writer = fn~(+instr: WriteInstr) {
|
||||
chan.send(copy instr);
|
||||
};
|
||||
let future = do future::from_fn {
|
||||
let mut res = ~"";
|
||||
loop {
|
||||
match port.recv() {
|
||||
write(s) => res += s,
|
||||
done => break
|
||||
Write(s) => res += s,
|
||||
Done => break
|
||||
}
|
||||
}
|
||||
res
|
||||
|
|
|
@ -5,27 +5,27 @@
|
|||
* individual modules, pages for the crate, indexes, etc.
|
||||
*/
|
||||
|
||||
use doc::{item_utils, page_utils};
|
||||
use doc::{ItemUtils, PageUtils};
|
||||
use syntax::ast;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass(output_style: config::output_style) -> pass {
|
||||
fn mk_pass(output_style: config::OutputStyle) -> Pass {
|
||||
{
|
||||
name: ~"page",
|
||||
f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
f: fn~(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, output_style)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc,
|
||||
output_style: config::output_style
|
||||
) -> doc::doc {
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc,
|
||||
output_style: config::OutputStyle
|
||||
) -> doc::Doc {
|
||||
|
||||
if output_style == config::doc_per_crate {
|
||||
if output_style == config::DocPerCrate {
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ fn run(
|
|||
comm::recv(result_port)
|
||||
}
|
||||
|
||||
type page_port = comm::Port<Option<doc::page>>;
|
||||
type page_chan = comm::Chan<Option<doc::page>>;
|
||||
type PagePort = comm::Port<Option<doc::Page>>;
|
||||
type PageChan = comm::Chan<Option<doc::Page>>;
|
||||
|
||||
fn make_doc_from_pages(page_port: page_port) -> doc::doc {
|
||||
fn make_doc_from_pages(page_port: PagePort) -> doc::Doc {
|
||||
let mut pages = ~[];
|
||||
loop {
|
||||
let val = comm::recv(page_port);
|
||||
|
@ -51,13 +51,13 @@ fn make_doc_from_pages(page_port: page_port) -> doc::doc {
|
|||
break;
|
||||
}
|
||||
}
|
||||
doc::doc_({
|
||||
doc::Doc_({
|
||||
pages: pages
|
||||
})
|
||||
}
|
||||
|
||||
fn find_pages(doc: doc::doc, page_chan: page_chan) {
|
||||
let fold = fold::fold({
|
||||
fn find_pages(doc: doc::Doc, page_chan: PageChan) {
|
||||
let fold = fold::Fold({
|
||||
fold_crate: fold_crate,
|
||||
fold_mod: fold_mod,
|
||||
fold_nmod: fold_nmod,
|
||||
|
@ -69,13 +69,13 @@ fn find_pages(doc: doc::doc, page_chan: page_chan) {
|
|||
}
|
||||
|
||||
fn fold_crate(
|
||||
fold: fold::fold<page_chan>,
|
||||
doc: doc::cratedoc
|
||||
) -> doc::cratedoc {
|
||||
fold: fold::Fold<PageChan>,
|
||||
doc: doc::CrateDoc
|
||||
) -> doc::CrateDoc {
|
||||
|
||||
let doc = fold::default_seq_fold_crate(fold, doc);
|
||||
|
||||
let page = doc::cratepage({
|
||||
let page = doc::CratePage({
|
||||
topmod: strip_mod(doc.topmod),
|
||||
.. doc
|
||||
});
|
||||
|
@ -86,28 +86,28 @@ fn fold_crate(
|
|||
}
|
||||
|
||||
fn fold_mod(
|
||||
fold: fold::fold<page_chan>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
fold: fold::Fold<PageChan>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
|
||||
if doc.id() != ast::crate_node_id {
|
||||
|
||||
let doc = strip_mod(doc);
|
||||
let page = doc::itempage(doc::modtag(doc));
|
||||
let page = doc::ItemPage(doc::ModTag(doc));
|
||||
comm::send(fold.ctxt, Some(page));
|
||||
}
|
||||
|
||||
doc
|
||||
}
|
||||
|
||||
fn strip_mod(doc: doc::moddoc) -> doc::moddoc {
|
||||
doc::moddoc_({
|
||||
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
|
||||
doc::ModDoc_({
|
||||
items: do vec::filter(doc.items) |item| {
|
||||
match item {
|
||||
doc::modtag(_) => false,
|
||||
doc::nmodtag(_) => false,
|
||||
doc::ModTag(_) => false,
|
||||
doc::NmodTag(_) => false,
|
||||
_ => true
|
||||
}
|
||||
},
|
||||
|
@ -116,11 +116,11 @@ fn strip_mod(doc: doc::moddoc) -> doc::moddoc {
|
|||
}
|
||||
|
||||
fn fold_nmod(
|
||||
fold: fold::fold<page_chan>,
|
||||
doc: doc::nmoddoc
|
||||
) -> doc::nmoddoc {
|
||||
fold: fold::Fold<PageChan>,
|
||||
doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
let doc = fold::default_seq_fold_nmod(fold, doc);
|
||||
let page = doc::itempage(doc::nmodtag(doc));
|
||||
let page = doc::ItemPage(doc::NmodTag(doc));
|
||||
comm::send(fold.ctxt, Some(page));
|
||||
return doc;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ fn fold_nmod(
|
|||
#[test]
|
||||
fn should_not_split_the_doc_into_pages_for_doc_per_crate() {
|
||||
let doc = test::mk_doc_(
|
||||
config::doc_per_crate,
|
||||
config::DocPerCrate,
|
||||
~"mod a { } mod b { mod c { } }"
|
||||
);
|
||||
assert doc.pages.len() == 1u;
|
||||
|
@ -161,16 +161,16 @@ fn should_remove_foreign_mods_from_containing_mods() {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc_(
|
||||
output_style: config::output_style,
|
||||
output_style: config::OutputStyle,
|
||||
source: ~str
|
||||
) -> doc::doc {
|
||||
) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc, output_style)
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
mk_doc_(config::doc_per_mod, source)
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
mk_doc_(config::DocPerMod, source)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
//! Records the full path to items
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
use syntax::ast;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
{
|
||||
name: ~"path",
|
||||
f: run
|
||||
}
|
||||
}
|
||||
|
||||
type ctxt = {
|
||||
srv: astsrv::srv,
|
||||
type Ctxt = {
|
||||
srv: astsrv::Srv,
|
||||
mut path: ~[~str]
|
||||
};
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
let ctxt = {
|
||||
srv: srv,
|
||||
mut path: ~[]
|
||||
};
|
||||
let fold = fold::fold({
|
||||
let fold = fold::Fold({
|
||||
fold_item: fold_item,
|
||||
fold_mod: fold_mod,
|
||||
fold_nmod: fold_nmod,
|
||||
|
@ -32,7 +32,7 @@ fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
|||
fold.fold_doc(fold, doc)
|
||||
}
|
||||
|
||||
fn fold_item(fold: fold::fold<ctxt>, doc: doc::itemdoc) -> doc::itemdoc {
|
||||
fn fold_item(fold: fold::Fold<Ctxt>, doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||
{
|
||||
path: fold.ctxt.path,
|
||||
.. doc
|
||||
|
@ -40,20 +40,20 @@ fn fold_item(fold: fold::fold<ctxt>, doc: doc::itemdoc) -> doc::itemdoc {
|
|||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn fold_mod(fold: fold::fold<ctxt>, doc: doc::moddoc) -> doc::moddoc {
|
||||
fn fold_mod(fold: fold::Fold<Ctxt>, doc: doc::ModDoc) -> doc::ModDoc {
|
||||
let is_topmod = doc.id() == ast::crate_node_id;
|
||||
|
||||
if !is_topmod { vec::push(fold.ctxt.path, doc.name()); }
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
if !is_topmod { vec::pop(fold.ctxt.path); }
|
||||
|
||||
doc::moddoc_({
|
||||
doc::ModDoc_({
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
.. *doc
|
||||
})
|
||||
}
|
||||
|
||||
fn fold_nmod(fold: fold::fold<ctxt>, doc: doc::nmoddoc) -> doc::nmoddoc {
|
||||
fn fold_nmod(fold: fold::Fold<Ctxt>, doc: doc::NmodDoc) -> doc::NmodDoc {
|
||||
vec::push(fold.ctxt.path, doc.name());
|
||||
let doc = fold::default_seq_fold_nmod(fold, doc);
|
||||
vec::pop(fold.ctxt.path);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
//! Prunes things with the #[doc(hidden)] attribute
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
use std::map::HashMap;
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
{
|
||||
name: ~"prune_hidden",
|
||||
f: run
|
||||
}
|
||||
}
|
||||
|
||||
fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_mod: fold_mod,
|
||||
.. *fold::default_any_fold(srv)
|
||||
});
|
||||
|
@ -20,20 +20,20 @@ fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
|||
}
|
||||
|
||||
fn fold_mod(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
|
||||
doc::moddoc_({
|
||||
items: vec::filter(doc.items, |itemtag| {
|
||||
!is_hidden(fold.ctxt, itemtag.item())
|
||||
doc::ModDoc_({
|
||||
items: vec::filter(doc.items, |ItemTag| {
|
||||
!is_hidden(fold.ctxt, ItemTag.item())
|
||||
}),
|
||||
.. *doc
|
||||
})
|
||||
}
|
||||
|
||||
fn is_hidden(srv: astsrv::srv, doc: doc::itemdoc) -> bool {
|
||||
fn is_hidden(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool {
|
||||
use syntax::ast_map;
|
||||
|
||||
let id = doc.id;
|
||||
|
@ -54,7 +54,7 @@ fn should_prune_hidden_items() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#[allow(vecs_implicitly_copyable,
|
||||
non_implicitly_copyable_typarams)];
|
||||
#[allow(non_camel_case_types)];
|
||||
|
||||
extern mod core(vers = "0.4");
|
||||
extern mod std(vers = "0.4");
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
// Some utility interfaces
|
||||
use doc::item_utils;
|
||||
use doc::item;
|
||||
use doc::ItemUtils;
|
||||
use doc::Item;
|
||||
use doc::util;
|
||||
|
||||
/// A single operation on the document model
|
||||
type pass = {
|
||||
type Pass = {
|
||||
name: ~str,
|
||||
f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc
|
||||
f: fn~(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc
|
||||
};
|
||||
|
||||
fn run_passes(
|
||||
srv: astsrv::srv,
|
||||
doc: doc::doc,
|
||||
passes: ~[pass]
|
||||
) -> doc::doc {
|
||||
srv: astsrv::Srv,
|
||||
doc: doc::Doc,
|
||||
passes: ~[Pass]
|
||||
) -> doc::Doc {
|
||||
let mut passno = 0;
|
||||
do vec::foldl(doc, passes) |doc, pass| {
|
||||
log(debug, fmt!("pass #%d", passno));
|
||||
|
@ -28,13 +28,13 @@ fn run_passes(
|
|||
#[test]
|
||||
fn test_run_passes() {
|
||||
fn pass1(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc
|
||||
) -> doc::doc {
|
||||
doc::doc_({
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc
|
||||
) -> doc::Doc {
|
||||
doc::Doc_({
|
||||
pages: ~[
|
||||
doc::cratepage({
|
||||
topmod: doc::moddoc_({
|
||||
doc::CratePage({
|
||||
topmod: doc::ModDoc_({
|
||||
item: {
|
||||
name: doc.cratemod().name() + ~"two",
|
||||
.. doc.cratemod().item
|
||||
|
@ -47,13 +47,13 @@ fn test_run_passes() {
|
|||
})
|
||||
}
|
||||
fn pass2(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc
|
||||
) -> doc::doc {
|
||||
doc::doc_({
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc
|
||||
) -> doc::Doc {
|
||||
doc::Doc_({
|
||||
pages: ~[
|
||||
doc::cratepage({
|
||||
topmod: doc::moddoc_({
|
||||
doc::CratePage({
|
||||
topmod: doc::ModDoc_({
|
||||
item: {
|
||||
name: doc.cratemod().name() + ~"three",
|
||||
.. doc.cratemod().item
|
||||
|
@ -110,7 +110,7 @@ fn time<T>(what: ~str, f: fn() -> T) -> T {
|
|||
}
|
||||
|
||||
/// Runs rustdoc over the given file
|
||||
fn run(config: config::config) {
|
||||
fn run(config: config::Config) {
|
||||
|
||||
let source_file = config.input_crate;
|
||||
do astsrv::from_file(source_file.to_str()) |srv| {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
//! Breaks rustdocs into sections according to their headers
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
{
|
||||
name: ~"sectionalize",
|
||||
f: run
|
||||
}
|
||||
}
|
||||
|
||||
fn run(_srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
fn run(_srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_item: fold_item,
|
||||
fold_trait: fold_trait,
|
||||
fold_impl: fold_impl,
|
||||
|
@ -21,7 +21,7 @@ fn run(_srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
|||
fold.fold_doc(fold, doc)
|
||||
}
|
||||
|
||||
fn fold_item(fold: fold::fold<()>, doc: doc::itemdoc) -> doc::itemdoc {
|
||||
fn fold_item(fold: fold::Fold<()>, doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||
let doc = fold::default_seq_fold_item(fold, doc);
|
||||
let (desc, sections) = sectionalize(doc.desc);
|
||||
|
||||
|
@ -32,7 +32,7 @@ fn fold_item(fold: fold::fold<()>, doc: doc::itemdoc) -> doc::itemdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_trait(fold: fold::fold<()>, doc: doc::traitdoc) -> doc::traitdoc {
|
||||
fn fold_trait(fold: fold::Fold<()>, doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ fn fold_trait(fold: fold::fold<()>, doc: doc::traitdoc) -> doc::traitdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc {
|
||||
fn fold_impl(fold: fold::Fold<()>, doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::section]) {
|
||||
fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||
|
||||
/*!
|
||||
* Take a description of the form
|
||||
|
@ -227,7 +227,7 @@ fn should_sectionalize_impl_methods() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = attr_pass::mk_pass().f(srv, doc);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! Sorts items by name
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
pure fn by_item_name(item1: &doc::itemtag, item2: &doc::itemtag) -> bool {
|
||||
fn mk_pass() -> Pass {
|
||||
pure fn by_item_name(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
|
||||
(*item1).name() <= (*item2).name()
|
||||
}
|
||||
sort_pass::mk_pass(~"sort_item_name", by_item_name)
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
//! Sorts items by type
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
pure fn by_score(item1: &doc::itemtag, item2: &doc::itemtag) -> bool {
|
||||
pure fn score(item: &doc::itemtag) -> int {
|
||||
fn mk_pass() -> Pass {
|
||||
pure fn by_score(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
|
||||
pure fn score(item: &doc::ItemTag) -> int {
|
||||
match *item {
|
||||
doc::consttag(_) => 0,
|
||||
doc::tytag(_) => 1,
|
||||
doc::enumtag(_) => 2,
|
||||
doc::traittag(_) => 3,
|
||||
doc::impltag(_) => 4,
|
||||
doc::fntag(_) => 5,
|
||||
doc::modtag(_) => 6,
|
||||
doc::nmodtag(_) => 7
|
||||
doc::ConstTag(_) => 0,
|
||||
doc::TyTag(_) => 1,
|
||||
doc::EnumTag(_) => 2,
|
||||
doc::TraitTag(_) => 3,
|
||||
doc::ImplTag(_) => 4,
|
||||
doc::FnTag(_) => 5,
|
||||
doc::ModTag(_) => 6,
|
||||
doc::NmodTag(_) => 7
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
//! A general sorting pass
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
use std::sort;
|
||||
|
||||
export item_lteq, mk_pass;
|
||||
|
||||
type item_lteq = pure fn~(v1: &doc::itemtag, v2: &doc::itemtag) -> bool;
|
||||
type ItemLtEq = pure fn~(v1: &doc::ItemTag, v2: &doc::ItemTag) -> bool;
|
||||
|
||||
fn mk_pass(name: ~str, +lteq: item_lteq) -> pass {
|
||||
fn mk_pass(name: ~str, +lteq: ItemLtEq) -> Pass {
|
||||
{
|
||||
name: name,
|
||||
f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
f: fn~(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, lteq)
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ fn mk_pass(name: ~str, +lteq: item_lteq) -> pass {
|
|||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn run(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc,
|
||||
lteq: item_lteq
|
||||
) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc,
|
||||
lteq: ItemLtEq
|
||||
) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_mod: fold_mod,
|
||||
.. *fold::default_any_fold(lteq)
|
||||
});
|
||||
|
@ -31,11 +31,11 @@ fn run(
|
|||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn fold_mod(
|
||||
fold: fold::fold<item_lteq>,
|
||||
doc: doc::moddoc
|
||||
) -> doc::moddoc {
|
||||
fold: fold::Fold<ItemLtEq>,
|
||||
doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
doc::moddoc_({
|
||||
doc::ModDoc_({
|
||||
items: sort::merge_sort(fold.ctxt, doc.items),
|
||||
.. *doc
|
||||
})
|
||||
|
@ -43,7 +43,7 @@ fn fold_mod(
|
|||
|
||||
#[test]
|
||||
fn test() {
|
||||
pure fn name_lteq(item1: &doc::itemtag, item2: &doc::itemtag) -> bool {
|
||||
pure fn name_lteq(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
|
||||
(*item1).name() <= (*item2).name()
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ fn test() {
|
|||
|
||||
#[test]
|
||||
fn should_be_stable() {
|
||||
pure fn always_eq(_item1: &doc::itemtag, _item2: &doc::itemtag) -> bool {
|
||||
pure fn always_eq(_item1: &doc::ItemTag, _item2: &doc::ItemTag) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
//! Generic pass for performing an operation on all descriptions
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass(name: ~str, +op: fn~(~str) -> ~str) -> pass {
|
||||
fn mk_pass(name: ~str, +op: fn~(~str) -> ~str) -> Pass {
|
||||
{
|
||||
name: name,
|
||||
f: fn~(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||
f: fn~(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, op)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type op = fn~(~str) -> ~str;
|
||||
type Op = fn~(~str) -> ~str;
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn run(
|
||||
_srv: astsrv::srv,
|
||||
doc: doc::doc,
|
||||
op: op
|
||||
) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
_srv: astsrv::Srv,
|
||||
doc: doc::Doc,
|
||||
op: Op
|
||||
) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_item: fold_item,
|
||||
fold_enum: fold_enum,
|
||||
fold_trait: fold_trait,
|
||||
|
@ -31,11 +31,11 @@ fn run(
|
|||
fold.fold_doc(fold, doc)
|
||||
}
|
||||
|
||||
fn maybe_apply_op(op: op, s: Option<~str>) -> Option<~str> {
|
||||
fn maybe_apply_op(op: Op, s: Option<~str>) -> Option<~str> {
|
||||
option::map(s, |s| op(s) )
|
||||
}
|
||||
|
||||
fn fold_item(fold: fold::fold<op>, doc: doc::itemdoc) -> doc::itemdoc {
|
||||
fn fold_item(fold: fold::Fold<Op>, doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||
let doc = fold::default_seq_fold_item(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -46,14 +46,14 @@ fn fold_item(fold: fold::fold<op>, doc: doc::itemdoc) -> doc::itemdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn apply_to_sections(op: op, sections: ~[doc::section]) -> ~[doc::section] {
|
||||
fn apply_to_sections(op: Op, sections: ~[doc::Section]) -> ~[doc::Section] {
|
||||
par::map(sections, |section, copy op| {
|
||||
header: op(section.header),
|
||||
body: op(section.body)
|
||||
})
|
||||
}
|
||||
|
||||
fn fold_enum(fold: fold::fold<op>, doc: doc::enumdoc) -> doc::enumdoc {
|
||||
fn fold_enum(fold: fold::Fold<Op>, doc: doc::EnumDoc) -> doc::EnumDoc {
|
||||
let doc = fold::default_seq_fold_enum(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ fn fold_enum(fold: fold::fold<op>, doc: doc::enumdoc) -> doc::enumdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_trait(fold: fold::fold<op>, doc: doc::traitdoc) -> doc::traitdoc {
|
||||
fn fold_trait(fold: fold::Fold<Op>, doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ fn fold_trait(fold: fold::fold<op>, doc: doc::traitdoc) -> doc::traitdoc {
|
|||
}
|
||||
}
|
||||
|
||||
fn apply_to_methods(op: op, docs: ~[doc::methoddoc]) -> ~[doc::methoddoc] {
|
||||
fn apply_to_methods(op: Op, docs: ~[doc::MethodDoc]) -> ~[doc::MethodDoc] {
|
||||
do par::map(docs) |doc, copy op| {
|
||||
{
|
||||
brief: maybe_apply_op(op, doc.brief),
|
||||
|
@ -87,7 +87,7 @@ fn apply_to_methods(op: op, docs: ~[doc::methoddoc]) -> ~[doc::methoddoc] {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_impl(fold: fold::fold<op>, doc: doc::impldoc) -> doc::impldoc {
|
||||
fn fold_impl(fold: fold::Fold<Op>, doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ fn should_execute_on_impl_method_section_bodies() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = attr_pass::mk_pass().f(srv, doc);
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
* is interpreted as the brief description.
|
||||
*/
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
text_pass::mk_pass(~"trim", |s| str::trim(s) )
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn should_trim_text() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = attr_pass::mk_pass().f(srv, doc);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Pulls type information out of the AST and attaches it to the document
|
||||
|
||||
use doc::item_utils;
|
||||
use doc::ItemUtils;
|
||||
use syntax::ast;
|
||||
use syntax::print::pprust;
|
||||
use syntax::ast_map;
|
||||
|
@ -9,7 +9,7 @@ use extract::to_str;
|
|||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
{
|
||||
name: ~"tystr",
|
||||
f: run
|
||||
|
@ -17,10 +17,10 @@ fn mk_pass() -> pass {
|
|||
}
|
||||
|
||||
fn run(
|
||||
srv: astsrv::srv,
|
||||
doc: doc::doc
|
||||
) -> doc::doc {
|
||||
let fold = fold::fold({
|
||||
srv: astsrv::Srv,
|
||||
doc: doc::Doc
|
||||
) -> doc::Doc {
|
||||
let fold = fold::Fold({
|
||||
fold_fn: fold_fn,
|
||||
fold_const: fold_const,
|
||||
fold_enum: fold_enum,
|
||||
|
@ -33,9 +33,9 @@ fn run(
|
|||
}
|
||||
|
||||
fn fold_fn(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::fndoc
|
||||
) -> doc::fndoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::FnDoc
|
||||
) -> doc::FnDoc {
|
||||
|
||||
let srv = fold.ctxt;
|
||||
|
||||
|
@ -45,7 +45,7 @@ fn fold_fn(
|
|||
}
|
||||
}
|
||||
|
||||
fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> Option<~str> {
|
||||
fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
match ctxt.ast_map.get(fn_id) {
|
||||
ast_map::node_item(@{
|
||||
|
@ -76,9 +76,9 @@ fn should_add_foreign_fn_sig() {
|
|||
}
|
||||
|
||||
fn fold_const(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::constdoc
|
||||
) -> doc::constdoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::ConstDoc
|
||||
) -> doc::ConstDoc {
|
||||
let srv = fold.ctxt;
|
||||
|
||||
{
|
||||
|
@ -103,9 +103,9 @@ fn should_add_const_types() {
|
|||
}
|
||||
|
||||
fn fold_enum(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::enumdoc
|
||||
) -> doc::enumdoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::EnumDoc
|
||||
) -> doc::EnumDoc {
|
||||
let doc_id = doc.id();
|
||||
let srv = fold.ctxt;
|
||||
|
||||
|
@ -143,9 +143,9 @@ fn should_add_variant_sigs() {
|
|||
}
|
||||
|
||||
fn fold_trait(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::traitdoc
|
||||
) -> doc::traitdoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::TraitDoc
|
||||
) -> doc::TraitDoc {
|
||||
{
|
||||
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
||||
.. doc
|
||||
|
@ -153,10 +153,10 @@ fn fold_trait(
|
|||
}
|
||||
|
||||
fn merge_methods(
|
||||
srv: astsrv::srv,
|
||||
item_id: doc::ast_id,
|
||||
docs: ~[doc::methoddoc]
|
||||
) -> ~[doc::methoddoc] {
|
||||
srv: astsrv::Srv,
|
||||
item_id: doc::AstId,
|
||||
docs: ~[doc::MethodDoc]
|
||||
) -> ~[doc::MethodDoc] {
|
||||
do par::map(docs) |doc| {
|
||||
{
|
||||
sig: get_method_sig(srv, item_id, doc.name),
|
||||
|
@ -166,8 +166,8 @@ fn merge_methods(
|
|||
}
|
||||
|
||||
fn get_method_sig(
|
||||
srv: astsrv::srv,
|
||||
item_id: doc::ast_id,
|
||||
srv: astsrv::Srv,
|
||||
item_id: doc::AstId,
|
||||
method_name: ~str
|
||||
) -> Option<~str> {
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
|
@ -234,9 +234,9 @@ fn should_add_trait_method_sigs() {
|
|||
}
|
||||
|
||||
fn fold_impl(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::impldoc
|
||||
) -> doc::impldoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::ImplDoc
|
||||
) -> doc::ImplDoc {
|
||||
|
||||
let srv = fold.ctxt;
|
||||
|
||||
|
@ -289,9 +289,9 @@ fn should_add_impl_method_sigs() {
|
|||
}
|
||||
|
||||
fn fold_type(
|
||||
fold: fold::fold<astsrv::srv>,
|
||||
doc: doc::tydoc
|
||||
) -> doc::tydoc {
|
||||
fold: fold::Fold<astsrv::Srv>,
|
||||
doc: doc::TyDoc
|
||||
) -> doc::TyDoc {
|
||||
|
||||
let srv = fold.ctxt;
|
||||
|
||||
|
@ -324,7 +324,7 @@ fn should_add_type_signatures() {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
fn mk_doc(source: ~str) -> doc::doc {
|
||||
fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
export mk_pass;
|
||||
|
||||
fn mk_pass() -> pass {
|
||||
fn mk_pass() -> Pass {
|
||||
text_pass::mk_pass(~"unindent", unindent)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue