Skip to content

Commit

Permalink
Add test for PR rust-lang#126057
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunshine40 authored and Oneirical committed Jun 9, 2024
1 parent 07d39c3 commit 7e4e26d
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/js/externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ let ParserState;
* foundElems: number,
* totalElems: number,
* literalSearch: boolean,
* corrections: Array<{from: string, to: integer}>,
* corrections: Array<{from: string, to: integer}> | null,
* typeFingerprint: Uint32Array,
* error: Array<string> | null,
* }}
*/
let ParsedQuery;
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-js/basic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const EXPECTED = {
'query': 'Fo',
'others': [
{ 'path': 'basic', 'name': 'Foo' },
{ 'path': 'basic', 'name': 'Foo', 'desc': 'Docs for Foo' },
],
};
22 changes: 22 additions & 0 deletions tests/rustdoc-js/doc-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Struct',
'desc': 'Doc for <code>Struct</code>',
'alias': 'StructItem',
'href': '../doc_alias/struct.Struct.html',
'is_alias': true
Expand All @@ -17,6 +18,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Struct',
'name': 'field',
'desc': 'Doc for <code>Struct</code>’s <code>field</code>',
'alias': 'StructFieldItem',
'href': '../doc_alias/struct.Struct.html#structfield.field',
'is_alias': true
Expand All @@ -29,6 +31,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Struct',
'name': 'method',
'desc': 'Doc for <code>Struct::method</code>',
'alias': 'StructMethodItem',
'href': '../doc_alias/struct.Struct.html#method.method',
'is_alias': true
Expand All @@ -45,6 +48,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Struct',
'name': 'ImplConstItem',
'desc': 'Doc for <code>Struct::ImplConstItem</code>',
'alias': 'StructImplConstItem',
'href': '../doc_alias/struct.Struct.html#associatedconstant.ImplConstItem',
'is_alias': true
Expand All @@ -57,6 +61,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Struct',
'name': 'function',
'desc': 'Doc for <code>Trait::function</code> implemented for Struct',
'alias': 'ImplTraitFunction',
'href': '../doc_alias/struct.Struct.html#method.function',
'is_alias': true
Expand All @@ -69,6 +74,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Enum',
'desc': 'Doc for <code>Enum</code>',
'alias': 'EnumItem',
'href': '../doc_alias/enum.Enum.html',
'is_alias': true
Expand All @@ -81,6 +87,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Enum',
'name': 'Variant',
'desc': 'Doc for <code>Enum::Variant</code>',
'alias': 'VariantItem',
'href': '../doc_alias/enum.Enum.html#variant.Variant',
'is_alias': true
Expand All @@ -93,6 +100,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Enum',
'name': 'method',
'desc': 'Doc for <code>Enum::method</code>',
'alias': 'EnumMethodItem',
'href': '../doc_alias/enum.Enum.html#method.method',
'is_alias': true
Expand All @@ -105,6 +113,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Typedef',
'desc': 'Doc for type alias <code>Typedef</code>',
'alias': 'TypedefItem',
'href': '../doc_alias/type.Typedef.html',
'is_alias': true
Expand All @@ -117,6 +126,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Trait',
'desc': 'Doc for <code>Trait</code>',
'alias': 'TraitItem',
'href': '../doc_alias/trait.Trait.html',
'is_alias': true
Expand All @@ -129,6 +139,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Trait',
'name': 'Target',
'desc': 'Doc for <code>Trait::Target</code>',
'alias': 'TraitTypeItem',
'href': '../doc_alias/trait.Trait.html#associatedtype.Target',
'is_alias': true
Expand All @@ -141,6 +152,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Trait',
'name': 'AssociatedConst',
'desc': 'Doc for <code>Trait::AssociatedConst</code>',
'alias': 'AssociatedConstItem',
'href': '../doc_alias/trait.Trait.html#associatedconstant.AssociatedConst',
'is_alias': true
Expand All @@ -153,6 +165,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Trait',
'name': 'function',
'desc': 'Doc for <code>Trait::function</code>',
'alias': 'TraitFunctionItem',
'href': '../doc_alias/trait.Trait.html#tymethod.function',
'is_alias': true
Expand All @@ -165,6 +178,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'function',
'desc': 'Doc for <code>function</code>',
'alias': 'FunctionItem',
'href': '../doc_alias/fn.function.html',
'is_alias': true
Expand All @@ -177,6 +191,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Module',
'desc': 'Doc for <code>Module</code>',
'alias': 'ModuleItem',
'href': '../doc_alias/Module/index.html',
'is_alias': true
Expand All @@ -189,6 +204,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Const',
'desc': 'Doc for <code>Const</code>',
'alias': 'ConstItem',
'href': '../doc_alias/constant.Const.html',
'is_alias': true
Expand All @@ -205,6 +221,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Static',
'desc': 'Doc for <code>Static</code>',
'alias': 'StaticItem',
'href': '../doc_alias/static.Static.html',
'is_alias': true
Expand All @@ -217,6 +234,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Union',
'desc': 'Doc for <code>Union</code>',
'alias': 'UnionItem',
'href': '../doc_alias/union.Union.html',
'is_alias': true
Expand All @@ -225,6 +243,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Union',
'name': 'union_item',
'desc': 'Doc for <code>Union::union_item</code>',
'href': '../doc_alias/union.Union.html#structfield.union_item'
},
],
Expand All @@ -235,6 +254,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Union',
'name': 'union_item',
'desc': 'Doc for <code>Union::union_item</code>',
'alias': 'UnionFieldItem',
'href': '../doc_alias/union.Union.html#structfield.union_item',
'is_alias': true
Expand All @@ -247,6 +267,7 @@ const EXPECTED = [
{
'path': 'doc_alias::Union',
'name': 'method',
'desc': 'Doc for <code>Union::method</code>',
'alias': 'UnionMethodItem',
'href': '../doc_alias/union.Union.html#method.method',
'is_alias': true
Expand All @@ -259,6 +280,7 @@ const EXPECTED = [
{
'path': 'doc_alias',
'name': 'Macro',
'desc': 'Doc for <code>Macro</code>',
'alias': 'MacroItem',
'href': '../doc_alias/macro.Macro.html',
'is_alias': true
Expand Down
21 changes: 21 additions & 0 deletions tests/rustdoc-js/doc-alias.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/// Doc for `Struct`
#[doc(alias = "StructItem")]
pub struct Struct {
/// Doc for `Struct`'s `field`
#[doc(alias = "StructFieldItem")]
pub field: u32,
}

impl Struct {
/// Doc for `Struct::ImplConstItem`
#[doc(alias = "StructImplConstItem")]
pub const ImplConstItem: i32 = 0;
/// Doc for `Struct::method`
#[doc(alias = "StructMethodItem")]
pub fn method(&self) {}
}
Expand All @@ -15,61 +19,78 @@ impl Trait for Struct {
type Target = u32;
const AssociatedConst: i32 = 12;

/// Doc for `Trait::function` implemented for Struct
#[doc(alias = "ImplTraitFunction")]
fn function() -> Self::Target {
0
}
}

/// Doc for `Enum`
#[doc(alias = "EnumItem")]
pub enum Enum {
/// Doc for `Enum::Variant`
#[doc(alias = "VariantItem")]
Variant,
}

impl Enum {
/// Doc for `Enum::method`
#[doc(alias = "EnumMethodItem")]
pub fn method(&self) {}
}

/// Doc for type alias `Typedef`
#[doc(alias = "TypedefItem")]
pub type Typedef = i32;

/// Doc for `Trait`
#[doc(alias = "TraitItem")]
pub trait Trait {
/// Doc for `Trait::Target`
#[doc(alias = "TraitTypeItem")]
type Target;
/// Doc for `Trait::AssociatedConst`
#[doc(alias = "AssociatedConstItem")]
const AssociatedConst: i32;

/// Doc for `Trait::function`
#[doc(alias = "TraitFunctionItem")]
fn function() -> Self::Target;
}

/// Doc for `function`
#[doc(alias = "FunctionItem")]
pub fn function() {}

/// Doc for `Module`
#[doc(alias = "ModuleItem")]
pub mod Module {}

/// Doc for `Const`
#[doc(alias = "ConstItem")]
pub const Const: u32 = 0;

/// Doc for `Static`
#[doc(alias = "StaticItem")]
pub static Static: u32 = 0;

/// Doc for `Union`
#[doc(alias = "UnionItem")]
pub union Union {
/// Doc for `Union::union_item`
#[doc(alias = "UnionFieldItem")]
pub union_item: u32,
pub y: f32,
}

impl Union {
/// Doc for `Union::method`
#[doc(alias = "UnionMethodItem")]
pub fn method(&self) {}
}

/// Doc for `Macro`
#[doc(alias = "MacroItem")]
#[macro_export]
macro_rules! Macro {
Expand Down
Loading

0 comments on commit 7e4e26d

Please sign in to comment.