Add more tests for doc aliases
This commit is contained in:
parent
cf41b1d3a5
commit
3a0727e84e
2 changed files with 317 additions and 0 deletions
237
src/test/rustdoc-js/doc-alias.js
Normal file
237
src/test/rustdoc-js/doc-alias.js
Normal file
|
@ -0,0 +1,237 @@
|
|||
// exact-check
|
||||
|
||||
const QUERY = [
|
||||
'StructItem',
|
||||
'StructFieldItem',
|
||||
'StructMethodItem',
|
||||
'ImplTraitItem',
|
||||
'ImplAssociatedConstItem',
|
||||
'ImplTraitFunction',
|
||||
'EnumItem',
|
||||
'VariantItem',
|
||||
'EnumMethodItem',
|
||||
'TypedefItem',
|
||||
'TraitItem',
|
||||
'TraitTypeItem',
|
||||
'AssociatedConstItem',
|
||||
'TraitFunctionItem',
|
||||
'FunctionItem',
|
||||
'ModuleItem',
|
||||
'ConstItem',
|
||||
'StaticItem',
|
||||
'UnionItem',
|
||||
'UnionFieldItem',
|
||||
'UnionMethodItem',
|
||||
'MacroItem',
|
||||
];
|
||||
|
||||
const EXPECTED = [
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Struct',
|
||||
'alias': 'StructItem',
|
||||
'href': '../doc_alias/struct.Struct.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Struct',
|
||||
'name': 'field',
|
||||
'alias': 'StructFieldItem',
|
||||
'href': '../doc_alias/struct.Struct.html#structfield.field'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Struct',
|
||||
'name': 'method',
|
||||
'alias': 'StructMethodItem',
|
||||
'href': '../doc_alias/struct.Struct.html#method.method'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// ImplTraitItem
|
||||
'others': [],
|
||||
},
|
||||
{
|
||||
// ImplAssociatedConstItem
|
||||
'others': [],
|
||||
},
|
||||
{
|
||||
// ImplTraitFunction
|
||||
'others': [],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Enum',
|
||||
'alias': 'EnumItem',
|
||||
'href': '../doc_alias/enum.Enum.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Enum',
|
||||
'name': 'Variant',
|
||||
'alias': 'VariantItem',
|
||||
'href': '../doc_alias/enum.Enum.html#variant.Variant'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Enum',
|
||||
'name': 'method',
|
||||
'alias': 'EnumMethodItem',
|
||||
'href': '../doc_alias/enum.Enum.html#method.method'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Typedef',
|
||||
'alias': 'TypedefItem',
|
||||
'href': '../doc_alias/type.Typedef.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Trait',
|
||||
'alias': 'TraitItem',
|
||||
'href': '../doc_alias/trait.Trait.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Trait',
|
||||
'name': 'Target',
|
||||
'alias': 'TraitTypeItem',
|
||||
'href': '../doc_alias/trait.Trait.html#associatedtype.Target'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Trait',
|
||||
'name': 'AssociatedConst',
|
||||
'alias': 'AssociatedConstItem',
|
||||
'href': '../doc_alias/trait.Trait.html#associatedconstant.AssociatedConst'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Trait',
|
||||
'name': 'function',
|
||||
'alias': 'TraitFunctionItem',
|
||||
'href': '../doc_alias/trait.Trait.html#tymethod.function'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'function',
|
||||
'alias': 'FunctionItem',
|
||||
'href': '../doc_alias/fn.function.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Module',
|
||||
'alias': 'ModuleItem',
|
||||
'href': '../doc_alias/Module/index.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Const',
|
||||
'alias': 'ConstItem',
|
||||
'href': '../doc_alias/constant.Const.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Static',
|
||||
'alias': 'StaticItem',
|
||||
'href': '../doc_alias/static.Static.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Union',
|
||||
'alias': 'UnionItem',
|
||||
'href': '../doc_alias/union.Union.html'
|
||||
},
|
||||
// Not an alias!
|
||||
{
|
||||
'path': 'doc_alias::Union',
|
||||
'name': 'union_item',
|
||||
'href': '../doc_alias/union.Union.html#structfield.union_item'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Union',
|
||||
'name': 'union_item',
|
||||
'alias': 'UnionFieldItem',
|
||||
'href': '../doc_alias/union.Union.html#structfield.union_item'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias::Union',
|
||||
'name': 'method',
|
||||
'alias': 'UnionMethodItem',
|
||||
'href': '../doc_alias/union.Union.html#method.method'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias',
|
||||
'name': 'Macro',
|
||||
'alias': 'MacroItem',
|
||||
'href': '../doc_alias/macro.Macro.html'
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
80
src/test/rustdoc-js/doc-alias.rs
Normal file
80
src/test/rustdoc-js/doc-alias.rs
Normal file
|
@ -0,0 +1,80 @@
|
|||
#![feature(doc_alias)]
|
||||
|
||||
#[doc(alias = "StructItem")]
|
||||
pub struct Struct {
|
||||
#[doc(alias = "StructFieldItem")]
|
||||
pub field: u32,
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
#[doc(alias = "StructMethodItem")]
|
||||
pub fn method(&self) {}
|
||||
}
|
||||
|
||||
impl Trait for Struct {
|
||||
// Shouldn't be listed in aliases!
|
||||
#[doc(alias = "ImplTraitItem")]
|
||||
type Target = u32;
|
||||
// Shouldn't be listed in aliases!
|
||||
#[doc(alias = "ImplAssociatedConstItem")]
|
||||
const AssociatedConst: i32 = 12;
|
||||
|
||||
// Shouldn't be listed in aliases!
|
||||
#[doc(alias = "ImplTraitFunction")]
|
||||
fn function() -> Self::Target { 0 }
|
||||
}
|
||||
|
||||
#[doc(alias = "EnumItem")]
|
||||
pub enum Enum {
|
||||
#[doc(alias = "VariantItem")]
|
||||
Variant,
|
||||
}
|
||||
|
||||
impl Enum {
|
||||
#[doc(alias = "EnumMethodItem")]
|
||||
pub fn method(&self) {}
|
||||
}
|
||||
|
||||
#[doc(alias = "TypedefItem")]
|
||||
pub type Typedef = i32;
|
||||
|
||||
#[doc(alias = "TraitItem")]
|
||||
pub trait Trait {
|
||||
#[doc(alias = "TraitTypeItem")]
|
||||
type Target;
|
||||
#[doc(alias = "AssociatedConstItem")]
|
||||
const AssociatedConst: i32;
|
||||
|
||||
#[doc(alias = "TraitFunctionItem")]
|
||||
fn function() -> Self::Target;
|
||||
}
|
||||
|
||||
#[doc(alias = "FunctionItem")]
|
||||
pub fn function() {}
|
||||
|
||||
#[doc(alias = "ModuleItem")]
|
||||
pub mod Module {}
|
||||
|
||||
#[doc(alias = "ConstItem")]
|
||||
pub const Const: u32 = 0;
|
||||
|
||||
#[doc(alias = "StaticItem")]
|
||||
pub static Static: u32 = 0;
|
||||
|
||||
#[doc(alias = "UnionItem")]
|
||||
pub union Union {
|
||||
#[doc(alias = "UnionFieldItem")]
|
||||
pub union_item: u32,
|
||||
pub y: f32,
|
||||
}
|
||||
|
||||
impl Union {
|
||||
#[doc(alias = "UnionMethodItem")]
|
||||
pub fn method(&self) {}
|
||||
}
|
||||
|
||||
#[doc(alias = "MacroItem")]
|
||||
#[macro_export]
|
||||
macro_rules! Macro {
|
||||
() => {}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue