Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
89276ff7
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
89276ff7
编写于
10月 22, 2021
作者:
J
Jacob Hoffman-Andrews
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix documentation header sizes
And add a rustdoc-gui test confirming various header sizes.
上级
29b12480
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
232 addition
and
6 deletion
+232
-6
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/mod.rs
+1
-1
src/librustdoc/html/render/print_item.rs
src/librustdoc/html/render/print_item.rs
+4
-4
src/test/rustdoc-gui/header-size.goml
src/test/rustdoc-gui/header-size.goml
+99
-0
src/test/rustdoc-gui/sidebar.goml
src/test/rustdoc-gui/sidebar.goml
+2
-1
src/test/rustdoc-gui/src/test_docs/lib.rs
src/test/rustdoc-gui/src/test_docs/lib.rs
+126
-0
未找到文件。
src/librustdoc/html/render/mod.rs
浏览文件 @
89276ff7
...
@@ -1612,7 +1612,7 @@ fn render_default_items(
...
@@ -1612,7 +1612,7 @@ fn render_default_items(
error_codes
:
cx
.shared.codes
,
error_codes
:
cx
.shared.codes
,
edition
:
cx
.shared
.edition
(),
edition
:
cx
.shared
.edition
(),
playground
:
&
cx
.shared.playground
,
playground
:
&
cx
.shared.playground
,
heading_offset
:
HeadingOffset
::
H
2
heading_offset
:
HeadingOffset
::
H
4
}
}
.into_string
()
.into_string
()
);
);
...
...
src/librustdoc/html/render/print_item.rs
浏览文件 @
89276ff7
...
@@ -983,7 +983,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
...
@@ -983,7 +983,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
if
let
Some
(
stability_class
)
=
field
.stability_class
(
cx
.tcx
())
{
if
let
Some
(
stability_class
)
=
field
.stability_class
(
cx
.tcx
())
{
write!
(
w
,
"<span class=
\"
stab {stab}
\"
></span>"
,
stab
=
stability_class
);
write!
(
w
,
"<span class=
\"
stab {stab}
\"
></span>"
,
stab
=
stability_class
);
}
}
document
(
w
,
cx
,
field
,
Some
(
it
),
HeadingOffset
::
H
2
);
document
(
w
,
cx
,
field
,
Some
(
it
),
HeadingOffset
::
H
3
);
}
}
}
}
let
def_id
=
it
.def_id
.expect_def_id
();
let
def_id
=
it
.def_id
.expect_def_id
();
...
@@ -1094,7 +1094,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
...
@@ -1094,7 +1094,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
w
.write_str
(
"</code>"
);
w
.write_str
(
"</code>"
);
render_stability_since
(
w
,
variant
,
it
,
cx
.tcx
());
render_stability_since
(
w
,
variant
,
it
,
cx
.tcx
());
w
.write_str
(
"</div>"
);
w
.write_str
(
"</div>"
);
document
(
w
,
cx
,
variant
,
Some
(
it
),
HeadingOffset
::
H
2
);
document
(
w
,
cx
,
variant
,
Some
(
it
),
HeadingOffset
::
H
3
);
document_non_exhaustive
(
w
,
variant
);
document_non_exhaustive
(
w
,
variant
);
use
crate
::
clean
::
Variant
;
use
crate
::
clean
::
Variant
;
...
@@ -1134,7 +1134,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
...
@@ -1134,7 +1134,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
f
=
field
.name
.as_ref
()
.unwrap
(),
f
=
field
.name
.as_ref
()
.unwrap
(),
t
=
ty
.print
(
cx
)
t
=
ty
.print
(
cx
)
);
);
document
(
w
,
cx
,
field
,
Some
(
variant
),
HeadingOffset
::
H
2
);
document
(
w
,
cx
,
field
,
Some
(
variant
),
HeadingOffset
::
H
4
);
}
}
_
=>
unreachable!
(),
_
=>
unreachable!
(),
}
}
...
@@ -1286,7 +1286,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
...
@@ -1286,7 +1286,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
name
=
field_name
,
name
=
field_name
,
ty
=
ty
.print
(
cx
)
ty
=
ty
.print
(
cx
)
);
);
document
(
w
,
cx
,
field
,
Some
(
it
),
HeadingOffset
::
H
2
);
document
(
w
,
cx
,
field
,
Some
(
it
),
HeadingOffset
::
H
3
);
}
}
}
}
}
}
...
...
src/test/rustdoc-gui/header-size.goml
0 → 100644
浏览文件 @
89276ff7
// This test check that headers (a) have the correct heading level, and (b) are the right size.
// The sizes may change as design changes, but try to make sure a lower header is never bigger than
// its parent headers.
// Most of these sizes are set in CSS in `em` units, so here's a conversion chart based on our
// default 16px font size:
// 24px 1.5em
// 22.4px 1.4em
// 20.8px 1.3em
// 18.4px 1.15em
// 17.6px 1.1em
// 16px 1em
// 15.2px 0.95em
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "17.6px"})
assert-css: ("h2#fields", {"font-size": "22.4px"})
assert-css: ("h3#title-for-field", {"font-size": "20.8px"})
assert-css: ("h4#sub-heading-for-field", {"font-size": "16px"})
assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"})
assert-css: ("h4#title-for-struct-impl-doc", {"font-size": "16px"})
assert-css: ("h5#sub-heading-for-struct-impl-doc", {"font-size": "16px"})
assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"font-size": "15.2px"})
assert-css: ("h5#title-for-struct-impl-item-doc", {"font-size": "16px"})
assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "15.2px"})
goto: file://|DOC_PATH|/test_docs/enum.HeavilyDocumentedEnum.html
assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "17.6px"})
assert-css: ("h2#variants", {"font-size": "22.4px"})
assert-css: ("h3#none-prose-title", {"font-size": "20.8px"})
assert-css: ("h4#none-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h3#wrapped-prose-title", {"font-size": "20.8px"})
assert-css: ("h4#wrapped-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h4#wrapped0-prose-title", {"font-size": "16px"})
assert-css: ("h5#wrapped0-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h4#structy-prose-title", {"font-size": "16px"})
assert-css: ("h5#structy-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"})
assert-css: ("h4#title-for-enum-impl-doc", {"font-size": "16px"})
assert-css: ("h5#sub-heading-for-enum-impl-doc", {"font-size": "16px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"font-size": "15.2px"})
assert-css: ("h5#title-for-enum-impl-item-doc", {"font-size": "16px"})
assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"font-size": "15.2px"})
goto: file://|DOC_PATH|/test_docs/union.HeavilyDocumentedUnion.html
assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h2#fields", {"font-size": "22.4px"})
assert-css: ("h3#title-for-union-variant", {"font-size": "20.8px"})
assert-css: ("h4#sub-heading-for-union-variant", {"font-size": "16px"})
assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
assert-css: ("h4#title-for-union-impl-doc", {"font-size": "16px"})
assert-css: ("h5#sub-heading-for-union-impl-doc", {"font-size": "16px"})
assert-css: ("h5#title-for-union-impl-item-doc", {"font-size": "16px"})
assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"font-size": "15.2px"})
goto: file://|DOC_PATH|/test_docs/macro.heavily_documented_macro.html
assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
src/test/rustdoc-gui/sidebar.goml
浏览文件 @
89276ff7
...
@@ -13,7 +13,8 @@ assert-text: (".sidebar-elems > .items > ul > li:nth-child(4)", "Enums")
...
@@ -13,7 +13,8 @@ assert-text: (".sidebar-elems > .items > ul > li:nth-child(4)", "Enums")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(5)", "Traits")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(5)", "Traits")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(6)", "Functions")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(6)", "Functions")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(7)", "Type Definitions")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(7)", "Type Definitions")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(8)", "Keywords")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(8)", "Unions")
assert-text: (".sidebar-elems > .items > ul > li:nth-child(9)", "Keywords")
assert-text: ("#structs + .item-table .item-left > a", "Foo")
assert-text: ("#structs + .item-table .item-left > a", "Foo")
click: "#structs + .item-table .item-left > a"
click: "#structs + .item-table .item-left > a"
...
...
src/test/rustdoc-gui/src/test_docs/lib.rs
浏览文件 @
89276ff7
...
@@ -131,3 +131,129 @@ pub mod long_code_block {}
...
@@ -131,3 +131,129 @@ pub mod long_code_block {}
}
}
pub
use
crate
::
repro
as
repro2
;
pub
use
crate
::
repro
as
repro2
;
/// # Top-doc Prose title
///
/// Text below title.
///
/// ## Top-doc Prose sub-heading
///
/// Text below sub-heading.
///
/// ### Top-doc Prose sub-sub-heading
///
/// Text below sub-sub-heading
pub
struct
HeavilyDocumentedStruct
{
/// # Title for field
/// ## Sub-heading for field
pub
nothing
:
(),
}
/// # Title for struct impl doc
///
/// Text below heading.
///
/// ## Sub-heading for struct impl doc
///
/// Text below sub-heading.
///
/// ### Sub-sub-heading for struct impl doc
///
/// Text below sub-sub-heading.
///
impl
HeavilyDocumentedStruct
{
/// # Title for struct impl-item doc
/// Text below title.
/// ## Sub-heading for struct impl-item doc
/// Text below sub-heading.
/// ### Sub-sub-heading for struct impl-item doc
/// Text below sub-sub-heading.
pub
fn
do_nothing
()
{}
}
/// # Top-doc Prose title
///
/// Text below title.
///
/// ## Top-doc Prose sub-heading
///
/// Text below sub-heading.
///
/// ### Top-doc Prose sub-sub-heading
///
/// Text below sub-sub-heading
pub
enum
HeavilyDocumentedEnum
{
/// # None prose title
/// ## None prose sub-heading
None
,
/// # Wrapped prose title
/// ## Wrapped prose sub-heading
Wrapped
(
/// # Wrapped.0 prose title
/// ## Wrapped.0 prose sub-heading
String
,
String
,
),
Structy
{
/// # Structy prose title
/// ## Structy prose sub-heading
alpha
:
String
,
beta
:
String
,
},
}
/// # Title for enum impl doc
///
/// Text below heading.
///
/// ## Sub-heading for enum impl doc
///
/// Text below sub-heading.
///
/// ### Sub-sub-heading for enum impl doc
///
/// Text below sub-sub-heading.
///
impl
HeavilyDocumentedEnum
{
/// # Title for enum impl-item doc
/// Text below title.
/// ## Sub-heading for enum impl-item doc
/// Text below sub-heading.
/// ### Sub-sub-heading for enum impl-item doc
/// Text below sub-sub-heading.
pub
fn
do_nothing
()
{}
}
/// # Top-doc prose title
///
/// Text below heading.
///
/// ## Top-doc prose sub-heading
///
/// Text below heading.
pub
union
HeavilyDocumentedUnion
{
/// # Title for union variant
/// ## Sub-heading for union variant
pub
nothing
:
(),
pub
something
:
f32
,
}
/// # Title for union impl doc
/// ## Sub-heading for union impl doc
impl
HeavilyDocumentedUnion
{
/// # Title for union impl-item doc
/// ## Sub-heading for union impl-item doc
pub
fn
do_nothing
()
{}
}
/// # Top-doc prose title
///
/// Text below heading.
///
/// ## Top-doc prose sub-heading
///
/// Text below heading.
#[macro_export]
macro_rules!
heavily_documented_macro
{
()
=>
{};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录