auto merge of #12961 : cmr/rust/rustdoc-impls, r=alexcrichton
Rendered form available at http://docs.octayn.net/doc/ This moves derived impls to the bottom of the list, separate from the rest, and collapses default methods that aren't overridden into an expandible accordion.
This commit is contained in:
commit
d130d8798d
3 changed files with 65 additions and 32 deletions
|
@ -174,12 +174,18 @@ pub enum ItemEnum {
|
||||||
StaticItem(Static),
|
StaticItem(Static),
|
||||||
TraitItem(Trait),
|
TraitItem(Trait),
|
||||||
ImplItem(Impl),
|
ImplItem(Impl),
|
||||||
|
/// `use` and `extern crate`
|
||||||
ViewItemItem(ViewItem),
|
ViewItemItem(ViewItem),
|
||||||
|
/// A method signature only. Used for required methods in traits (ie,
|
||||||
|
/// non-default-methods).
|
||||||
TyMethodItem(TyMethod),
|
TyMethodItem(TyMethod),
|
||||||
|
/// A method with a body.
|
||||||
MethodItem(Method),
|
MethodItem(Method),
|
||||||
StructFieldItem(StructField),
|
StructFieldItem(StructField),
|
||||||
VariantItem(Variant),
|
VariantItem(Variant),
|
||||||
|
/// `fn`s from an extern block
|
||||||
ForeignFunctionItem(Function),
|
ForeignFunctionItem(Function),
|
||||||
|
/// `static`s from an extern block
|
||||||
ForeignStaticItem(Static),
|
ForeignStaticItem(Static),
|
||||||
MacroItem(Macro),
|
MacroItem(Macro),
|
||||||
}
|
}
|
||||||
|
@ -1014,11 +1020,23 @@ pub struct Impl {
|
||||||
generics: Generics,
|
generics: Generics,
|
||||||
trait_: Option<Type>,
|
trait_: Option<Type>,
|
||||||
for_: Type,
|
for_: Type,
|
||||||
methods: Vec<Item> ,
|
methods: Vec<Item>,
|
||||||
|
derived: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Item> for doctree::Impl {
|
impl Clean<Item> for doctree::Impl {
|
||||||
fn clean(&self) -> Item {
|
fn clean(&self) -> Item {
|
||||||
|
let mut derived = false;
|
||||||
|
for attr in self.attrs.iter() {
|
||||||
|
match attr.node.value.node {
|
||||||
|
ast::MetaWord(ref s) => {
|
||||||
|
if s.get() == "automatically_derived" {
|
||||||
|
derived = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Item {
|
Item {
|
||||||
name: None,
|
name: None,
|
||||||
attrs: self.attrs.clean(),
|
attrs: self.attrs.clean(),
|
||||||
|
@ -1030,6 +1048,7 @@ impl Clean<Item> for doctree::Impl {
|
||||||
trait_: self.trait_.clean(),
|
trait_: self.trait_.clean(),
|
||||||
for_: self.for_.clean(),
|
for_: self.for_.clean(),
|
||||||
methods: self.methods.clean(),
|
methods: self.methods.clean(),
|
||||||
|
derived: derived,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,53 +29,53 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
|
||||||
-> fmt::Result
|
-> fmt::Result
|
||||||
{
|
{
|
||||||
write!(dst,
|
write!(dst,
|
||||||
"<!DOCTYPE html>
|
r##"<!DOCTYPE html>
|
||||||
<html lang=\"en\">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset=\"utf-8\" />
|
<meta charset="utf-8" />
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
|
|
||||||
<link href='http://fonts.googleapis.com/css?family=Oswald:700|Inconsolata:400,700'
|
<link href='http://fonts.googleapis.com/css?family=Oswald:700|Inconsolata:400,700'
|
||||||
rel='stylesheet' type='text/css'>
|
rel='stylesheet' type='text/css'>
|
||||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}main.css\">
|
<link rel="stylesheet" type="text/css" href="{root_path}main.css">
|
||||||
|
|
||||||
{favicon, select, none{} other{<link rel=\"shortcut icon\" href=\"#\" />}}
|
{favicon, select, none{} other{<link rel="shortcut icon" href="\#" />}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!--[if lte IE 8]>
|
<!--[if lte IE 8]>
|
||||||
<div class=\"warning\">
|
<div class="warning">
|
||||||
This old browser is unsupported and will most likely display funky
|
This old browser is unsupported and will most likely display funky
|
||||||
things.
|
things.
|
||||||
</div>
|
</div>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<section class=\"sidebar\">
|
<section class="sidebar">
|
||||||
{logo, select, none{} other{
|
{logo, select, none{} other{
|
||||||
<a href='{root_path}{krate}/index.html'><img src='#' alt=''/></a>
|
<a href='{root_path}{krate}/index.html'><img src='\#' alt=''/></a>
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{sidebar}
|
{sidebar}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<nav class=\"sub\">
|
<nav class="sub">
|
||||||
<form class=\"search-form js-only\">
|
<form class="search-form js-only">
|
||||||
<button class=\"do-search\">Search</button>
|
<button class="do-search">Search</button>
|
||||||
<div class=\"search-container\">
|
<div class="search-container">
|
||||||
<input class=\"search-input\" name=\"search\"
|
<input class="search-input" name="search"
|
||||||
autocomplete=\"off\"
|
autocomplete="off"
|
||||||
placeholder=\"Search documentation...\"
|
placeholder="Search documentation..."
|
||||||
type=\"search\" />
|
type="search" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<section id='main' class=\"content {ty}\">{content}</section>
|
<section id='main' class="content {ty}">{content}</section>
|
||||||
<section id='search' class=\"content hidden\"></section>
|
<section id='search' class="content hidden"></section>
|
||||||
|
|
||||||
<section class=\"footer\"></section>
|
<section class="footer"></section>
|
||||||
|
|
||||||
<div id=\"help\" class=\"hidden\">
|
<div id="help" class="hidden">
|
||||||
<div class=\"shortcuts\">
|
<div class="shortcuts">
|
||||||
<h1>Keyboard shortcuts</h1>
|
<h1>Keyboard shortcuts</h1>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>?</dt>
|
<dt>?</dt>
|
||||||
|
@ -86,11 +86,11 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
|
||||||
<dd>Move up in search results</dd>
|
<dd>Move up in search results</dd>
|
||||||
<dt>↓</dt>
|
<dt>↓</dt>
|
||||||
<dd>Move down in search results</dd>
|
<dd>Move down in search results</dd>
|
||||||
<dt>&\\#9166;</dt>
|
<dt>&\#9166;</dt>
|
||||||
<dd>Go to active search result</dd>
|
<dd>Go to active search result</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class=\"infos\">
|
<div class="infos">
|
||||||
<h1>Search tricks</h1>
|
<h1>Search tricks</h1>
|
||||||
<p>
|
<p>
|
||||||
Prefix searches with a type followed by a colon (e.g.
|
Prefix searches with a type followed by a colon (e.g.
|
||||||
|
@ -106,15 +106,15 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var rootPath = \"{root_path}\";
|
var rootPath = "{root_path}";
|
||||||
var currentCrate = \"{krate}\";
|
var currentCrate = "{krate}";
|
||||||
</script>
|
</script>
|
||||||
<script src=\"{root_path}jquery.js\"></script>
|
<script src="{root_path}jquery.js"></script>
|
||||||
<script src=\"{root_path}main.js\"></script>
|
<script src="{root_path}main.js"></script>
|
||||||
<script async src=\"{root_path}search-index.js\"></script>
|
<script async src="{root_path}search-index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
",
|
"##,
|
||||||
content = *t,
|
content = *t,
|
||||||
root_path = page.root_path,
|
root_path = page.root_path,
|
||||||
ty = page.ty,
|
ty = page.ty,
|
||||||
|
|
|
@ -1517,8 +1517,22 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
|
||||||
if traits.len() > 0 {
|
if traits.len() > 0 {
|
||||||
try!(write!(w, "<h2 id='implementations'>Trait \
|
try!(write!(w, "<h2 id='implementations'>Trait \
|
||||||
Implementations</h2>"));
|
Implementations</h2>"));
|
||||||
for &(ref i, ref dox) in traits.move_iter() {
|
let mut any_derived = false;
|
||||||
try!(render_impl(w, i, dox));
|
for & &(ref i, ref dox) in traits.iter() {
|
||||||
|
if !i.derived {
|
||||||
|
try!(render_impl(w, i, dox));
|
||||||
|
} else {
|
||||||
|
any_derived = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if any_derived {
|
||||||
|
try!(write!(w, "<h3 id='derived_implementations'>Derived Implementations \
|
||||||
|
</h3>"));
|
||||||
|
for &(ref i, ref dox) in traits.move_iter() {
|
||||||
|
if i.derived {
|
||||||
|
try!(render_impl(w, i, dox));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue