parent
f93a4928c2
commit
2792b56a92
5 changed files with 67 additions and 3 deletions
|
@ -77,6 +77,11 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name)
|
||||||
ret.extend(build_impls(cx, did));
|
ret.extend(build_impls(cx, did));
|
||||||
clean::EnumItem(build_enum(cx, did))
|
clean::EnumItem(build_enum(cx, did))
|
||||||
}
|
}
|
||||||
|
Def::TyForeign(did) => {
|
||||||
|
record_extern_fqn(cx, did, clean::TypeKind::Foreign);
|
||||||
|
ret.extend(build_impls(cx, did));
|
||||||
|
clean::ForeignTypeItem
|
||||||
|
}
|
||||||
// Never inline enum variants but leave them shown as reexports.
|
// Never inline enum variants but leave them shown as reexports.
|
||||||
Def::Variant(..) => return None,
|
Def::Variant(..) => return None,
|
||||||
// Assume that enum variants and struct types are reexported next to
|
// Assume that enum variants and struct types are reexported next to
|
||||||
|
|
|
@ -1257,7 +1257,7 @@ impl DocFolder for Cache {
|
||||||
clean::FunctionItem(..) | clean::ModuleItem(..) |
|
clean::FunctionItem(..) | clean::ModuleItem(..) |
|
||||||
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
|
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
|
||||||
clean::ConstantItem(..) | clean::StaticItem(..) |
|
clean::ConstantItem(..) | clean::StaticItem(..) |
|
||||||
clean::UnionItem(..)
|
clean::UnionItem(..) | clean::ForeignTypeItem
|
||||||
if !self.stripped_mod => {
|
if !self.stripped_mod => {
|
||||||
// Reexported items mean that the same id can show up twice
|
// Reexported items mean that the same id can show up twice
|
||||||
// in the rustdoc ast that we're looking at. We know,
|
// in the rustdoc ast that we're looking at. We know,
|
||||||
|
@ -1292,7 +1292,7 @@ impl DocFolder for Cache {
|
||||||
// Maintain the parent stack
|
// Maintain the parent stack
|
||||||
let orig_parent_is_trait_impl = self.parent_is_trait_impl;
|
let orig_parent_is_trait_impl = self.parent_is_trait_impl;
|
||||||
let parent_pushed = match item.inner {
|
let parent_pushed = match item.inner {
|
||||||
clean::TraitItem(..) | clean::EnumItem(..) |
|
clean::TraitItem(..) | clean::EnumItem(..) | clean::ForeignTypeItem |
|
||||||
clean::StructItem(..) | clean::UnionItem(..) => {
|
clean::StructItem(..) | clean::UnionItem(..) => {
|
||||||
self.parent_stack.push(item.def_id);
|
self.parent_stack.push(item.def_id);
|
||||||
self.parent_is_trait_impl = false;
|
self.parent_is_trait_impl = false;
|
||||||
|
@ -1711,6 +1711,7 @@ impl<'a> fmt::Display for Item<'a> {
|
||||||
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
|
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
|
||||||
clean::StaticItem(..) | clean::ForeignStaticItem(..) => write!(fmt, "Static ")?,
|
clean::StaticItem(..) | clean::ForeignStaticItem(..) => write!(fmt, "Static ")?,
|
||||||
clean::ConstantItem(..) => write!(fmt, "Constant ")?,
|
clean::ConstantItem(..) => write!(fmt, "Constant ")?,
|
||||||
|
clean::ForeignTypeItem => write!(fmt, "Foreign Type ")?,
|
||||||
_ => {
|
_ => {
|
||||||
// We don't generate pages for any other type.
|
// We don't generate pages for any other type.
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
@ -1775,6 +1776,7 @@ impl<'a> fmt::Display for Item<'a> {
|
||||||
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) =>
|
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) =>
|
||||||
item_static(fmt, self.cx, self.item, i),
|
item_static(fmt, self.cx, self.item, i),
|
||||||
clean::ConstantItem(ref c) => item_constant(fmt, self.cx, self.item, c),
|
clean::ConstantItem(ref c) => item_constant(fmt, self.cx, self.item, c),
|
||||||
|
clean::ForeignTypeItem => item_foreign_type(fmt, self.cx, self.item),
|
||||||
_ => {
|
_ => {
|
||||||
// We don't generate pages for any other type.
|
// We don't generate pages for any other type.
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
@ -3429,6 +3431,21 @@ fn item_typedef(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn item_foreign_type(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item) -> fmt::Result {
|
||||||
|
writeln!(w, "<pre class='rust foreigntype'>extern {{")?;
|
||||||
|
render_attributes(w, it)?;
|
||||||
|
write!(
|
||||||
|
w,
|
||||||
|
" {}type {};\n}}</pre>",
|
||||||
|
VisSpace(&it.visibility),
|
||||||
|
it.name.as_ref().unwrap(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
document(w, cx, it)?;
|
||||||
|
|
||||||
|
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for Sidebar<'a> {
|
impl<'a> fmt::Display for Sidebar<'a> {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let cx = self.cx;
|
let cx = self.cx;
|
||||||
|
@ -3446,6 +3463,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
|
||||||
clean::UnionItem(..) => write!(fmt, "Union ")?,
|
clean::UnionItem(..) => write!(fmt, "Union ")?,
|
||||||
clean::EnumItem(..) => write!(fmt, "Enum ")?,
|
clean::EnumItem(..) => write!(fmt, "Enum ")?,
|
||||||
clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
|
clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
|
||||||
|
clean::ForeignTypeItem => write!(fmt, "Foreign Type ")?,
|
||||||
clean::ModuleItem(..) => if it.is_crate() {
|
clean::ModuleItem(..) => if it.is_crate() {
|
||||||
write!(fmt, "Crate ")?;
|
write!(fmt, "Crate ")?;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3474,6 +3492,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
|
||||||
clean::EnumItem(ref e) => sidebar_enum(fmt, it, e)?,
|
clean::EnumItem(ref e) => sidebar_enum(fmt, it, e)?,
|
||||||
clean::TypedefItem(ref t, _) => sidebar_typedef(fmt, it, t)?,
|
clean::TypedefItem(ref t, _) => sidebar_typedef(fmt, it, t)?,
|
||||||
clean::ModuleItem(ref m) => sidebar_module(fmt, it, &m.items)?,
|
clean::ModuleItem(ref m) => sidebar_module(fmt, it, &m.items)?,
|
||||||
|
clean::ForeignTypeItem => sidebar_foreign_type(fmt, it)?,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3897,6 +3916,14 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sidebar_foreign_type(fmt: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
||||||
|
let sidebar = sidebar_assoc_items(it);
|
||||||
|
if !sidebar.is_empty() {
|
||||||
|
write!(fmt, "<div class=\"block items\">{}</div>", sidebar)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for Source<'a> {
|
impl<'a> fmt::Display for Source<'a> {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let Source(s) = *self;
|
let Source(s) = *self;
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
"associatedtype",
|
"associatedtype",
|
||||||
"constant",
|
"constant",
|
||||||
"associatedconstant",
|
"associatedconstant",
|
||||||
"union"];
|
"union",
|
||||||
|
"foreigntype"];
|
||||||
|
|
||||||
// On the search screen, so you remain on the last tab you opened.
|
// On the search screen, so you remain on the last tab you opened.
|
||||||
//
|
//
|
||||||
|
@ -1445,6 +1446,7 @@
|
||||||
block("trait", "Traits");
|
block("trait", "Traits");
|
||||||
block("fn", "Functions");
|
block("fn", "Functions");
|
||||||
block("type", "Type Definitions");
|
block("type", "Type Definitions");
|
||||||
|
block("foreigntype", "Foreign Types");
|
||||||
}
|
}
|
||||||
|
|
||||||
window.initSidebarItems = initSidebarItems;
|
window.initSidebarItems = initSidebarItems;
|
||||||
|
|
|
@ -104,6 +104,7 @@ pre {
|
||||||
.content .highlighted.method,
|
.content .highlighted.method,
|
||||||
.content .highlighted.tymethod { background-color: #c6afb3; }
|
.content .highlighted.tymethod { background-color: #c6afb3; }
|
||||||
.content .highlighted.type { background-color: #ffc891; }
|
.content .highlighted.type { background-color: #ffc891; }
|
||||||
|
.content .highlighted.foreigntype { background-color: #f5c4ff; }
|
||||||
.content .highlighted.macro { background-color: #8ce488; }
|
.content .highlighted.macro { background-color: #8ce488; }
|
||||||
.content .highlighted.constant,
|
.content .highlighted.constant,
|
||||||
.content .highlighted.static { background-color: #c3e0ff; }
|
.content .highlighted.static { background-color: #c3e0ff; }
|
||||||
|
@ -112,6 +113,7 @@ pre {
|
||||||
.content span.enum, .content a.enum, .block a.current.enum { color: #508157; }
|
.content span.enum, .content a.enum, .block a.current.enum { color: #508157; }
|
||||||
.content span.struct, .content a.struct, .block a.current.struct { color: #df3600; }
|
.content span.struct, .content a.struct, .block a.current.struct { color: #df3600; }
|
||||||
.content span.type, .content a.type, .block a.current.type { color: #ba5d00; }
|
.content span.type, .content a.type, .block a.current.type { color: #ba5d00; }
|
||||||
|
.content span.foreigntype, .content a.foreigntype, .block a.current.foreigntype { color: #cd00e2; }
|
||||||
.content span.macro, .content a.macro, .block a.current.macro { color: #068000; }
|
.content span.macro, .content a.macro, .block a.current.macro { color: #068000; }
|
||||||
.content span.union, .content a.union, .block a.current.union { color: #767b27; }
|
.content span.union, .content a.union, .block a.current.union { color: #767b27; }
|
||||||
.content span.constant, .content a.constant, .block a.current.constant,
|
.content span.constant, .content a.constant, .block a.current.constant,
|
||||||
|
|
28
src/test/rustdoc/foreigntype.rs
Normal file
28
src/test/rustdoc/foreigntype.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(extern_types)]
|
||||||
|
|
||||||
|
extern {
|
||||||
|
// @has foreigntype/foreigntype.ExtType.html
|
||||||
|
pub type ExtType;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExtType {
|
||||||
|
// @has - '//a[@class="fnname"]' 'do_something'
|
||||||
|
pub fn do_something(&self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Trait {}
|
||||||
|
|
||||||
|
// @has foreigntype/trait.Trait.html '//a[@class="foreigntype"]' 'ExtType'
|
||||||
|
impl Trait for ExtType {}
|
||||||
|
|
||||||
|
// @has foreigntype/index.html '//a[@class="foreigntype"]' 'ExtType'
|
Loading…
Add table
Add a link
Reference in a new issue