From 04294e437bdd000d8a4bd4c9d47dfa4a2e6da624 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 16 Jan 2012 15:44:10 -0800 Subject: [PATCH] rustdoc: Cleanup --- src/rustdoc/doc.rs | 2 +- src/rustdoc/extract.rs | 1 - src/rustdoc/gen.rs | 28 ++++++---------------------- src/rustdoc/tystr_pass.rs | 5 ++++- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 51db29d3526..6ca7cf1d52f 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -14,7 +14,7 @@ type fndoc = ~{ id: ast_id, name: str, brief: str, - desc: option::t, + desc: option, return: option, args: [(str, str)] }; diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index faaabd65460..5caa0d59913 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -24,7 +24,6 @@ fn moddoc_from_mod( module: ast::_mod, name: ast::ident, _attrs: [ast::attribute] - ) -> doc::moddoc { ~{ name: name, diff --git a/src/rustdoc/gen.rs b/src/rustdoc/gen.rs index b1f511e1f6a..ec2083bea25 100644 --- a/src/rustdoc/gen.rs +++ b/src/rustdoc/gen.rs @@ -19,6 +19,10 @@ fn write_markdown( write_top_module(ctxt, doc.topmod); } +fn write_header(ctxt: ctxt, name: str) { + ctxt.w.write_line("# Crate " + name); +} + fn write_top_module( ctxt: ctxt, moddoc: doc::moddoc @@ -48,29 +52,9 @@ fn write_mod_contents( fn write_fn( ctxt: ctxt, - fndoc: doc::fndoc + doc: doc::fndoc ) { - write_fndoc(ctxt, fndoc.name, fndoc); -} - -#[doc( - brief = "Generate a crate document header.", - args(rd = "Rustdoc context", - name = "Crate name") -)] -fn write_header(ctxt: ctxt, name: str) { - ctxt.w.write_line("# Crate " + name); -} - -#[doc( - brief = "Documents a single function.", - args(rd = "Rustdoc context", - ident = "Identifier for this function", - doc = "Function docs extracted from attributes", - _fn = "AST object representing this function") -)] -fn write_fndoc(ctxt: ctxt, ident: str, doc: doc::fndoc) { - ctxt.w.write_line("## Function `" + ident + "`"); + ctxt.w.write_line("## Function `" + doc.name + "`"); ctxt.w.write_line(doc.brief); alt doc.desc { some(_d) { diff --git a/src/rustdoc/tystr_pass.rs b/src/rustdoc/tystr_pass.rs index 8894fe88ca8..18a9941ec47 100644 --- a/src/rustdoc/tystr_pass.rs +++ b/src/rustdoc/tystr_pass.rs @@ -2,7 +2,10 @@ import rustc::syntax::ast; export run; -fn run(doc: doc::cratedoc, crate: @ast::crate) -> doc::cratedoc { +fn run( + doc: doc::cratedoc, + crate: @ast::crate +) -> doc::cratedoc { let fold = fold::fold({ fold_fn: fn~( f: fold::fold<@ast::crate>,