Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fba4149b
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,发现更多精彩内容 >>
提交
fba4149b
编写于
8月 31, 2021
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean render_impl arguments
上级
d7159bdb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
67 addition
and
46 deletion
+67
-46
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/mod.rs
+52
-36
src/librustdoc/html/render/print_item.rs
src/librustdoc/html/render/print_item.rs
+15
-10
未找到文件。
src/librustdoc/html/render/mod.rs
浏览文件 @
fba4149b
...
...
@@ -711,13 +711,15 @@ fn render_impls(
containing_item
,
assoc_link
,
RenderMode
::
Normal
,
true
,
None
,
false
,
true
,
true
,
&
[],
true
,
ImplRenderingParameters
{
show_def_docs
:
true
,
is_on_foreign_type
:
false
,
show_default_items
:
true
,
show_non_assoc_items
:
true
,
toggle_open_by_default
:
true
,
},
);
buffer
.into_inner
()
})
...
...
@@ -1052,13 +1054,15 @@ fn render_assoc_items(
containing_item
,
AssocItemLink
::
Anchor
(
None
),
render_mode
,
true
,
None
,
false
,
true
,
true
,
&
[],
true
,
ImplRenderingParameters
{
show_def_docs
:
true
,
is_on_foreign_type
:
false
,
show_default_items
:
true
,
show_non_assoc_items
:
true
,
toggle_open_by_default
:
true
,
},
);
}
}
...
...
@@ -1248,6 +1252,16 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
out
.into_inner
()
}
#[derive(Clone,
Copy,
Debug)]
struct
ImplRenderingParameters
{
show_def_docs
:
bool
,
is_on_foreign_type
:
bool
,
show_default_items
:
bool
,
/// Whether or not to show methods.
show_non_assoc_items
:
bool
,
toggle_open_by_default
:
bool
,
}
fn
render_impl
(
w
:
&
mut
Buffer
,
cx
:
&
Context
<
'_
>
,
...
...
@@ -1255,16 +1269,9 @@ fn render_impl(
parent
:
&
clean
::
Item
,
link
:
AssocItemLink
<
'_
>
,
render_mode
:
RenderMode
,
show_def_docs
:
bool
,
use_absolute
:
Option
<
bool
>
,
is_on_foreign_type
:
bool
,
show_default_items
:
bool
,
// It'll exclude methods.
show_non_assoc_items
:
bool
,
// This argument is used to reference same type with different paths to avoid duplication
// in documentation pages for trait with automatic implementations like "Send" and "Sync".
aliases
:
&
[
String
],
toggle_open_by_default
:
bool
,
rendering_params
:
ImplRenderingParameters
,
)
{
let
cache
=
cx
.cache
();
let
traits
=
&
cache
.traits
;
...
...
@@ -1287,13 +1294,12 @@ fn doc_impl_item(
render_mode
:
RenderMode
,
is_default_item
:
bool
,
trait_
:
Option
<&
clean
::
Trait
>
,
show_def_docs
:
bool
,
show_non_assoc_items
:
bool
,
rendering_params
:
ImplRenderingParameters
,
)
{
let
item_type
=
item
.type_
();
let
name
=
item
.name
.as_ref
()
.unwrap
();
let
render_method_item
=
show_non_assoc_items
let
render_method_item
=
rendering_params
.
show_non_assoc_items
&&
match
render_mode
{
RenderMode
::
Normal
=>
true
,
RenderMode
::
ForDeref
{
mut_
:
deref_mut_
}
=>
{
...
...
@@ -1322,18 +1328,32 @@ fn doc_impl_item(
}
else
{
// In case the item isn't documented,
// provide short documentation from the trait.
document_short
(
&
mut
doc_buffer
,
it
,
cx
,
link
,
parent
,
show_def_docs
);
document_short
(
&
mut
doc_buffer
,
it
,
cx
,
link
,
parent
,
rendering_params
.show_def_docs
,
);
}
}
}
else
{
document_item_info
(
&
mut
info_buffer
,
cx
,
item
,
Some
(
parent
));
if
show_def_docs
{
if
rendering_params
.
show_def_docs
{
document_full
(
&
mut
doc_buffer
,
item
,
cx
);
short_documented
=
false
;
}
}
}
else
{
document_short
(
&
mut
doc_buffer
,
item
,
cx
,
link
,
parent
,
show_def_docs
);
document_short
(
&
mut
doc_buffer
,
item
,
cx
,
link
,
parent
,
rendering_params
.show_def_docs
,
);
}
}
let
w
=
if
short_documented
&&
trait_
.is_some
()
{
interesting
}
else
{
boring
};
...
...
@@ -1465,8 +1485,7 @@ fn doc_impl_item(
render_mode
,
false
,
trait_
.map
(|
t
|
&
t
.trait_
),
show_def_docs
,
show_non_assoc_items
,
rendering_params
,
);
}
...
...
@@ -1479,8 +1498,7 @@ fn render_default_items(
parent
:
&
clean
::
Item
,
containing_item
:
&
clean
::
Item
,
render_mode
:
RenderMode
,
show_def_docs
:
bool
,
show_non_assoc_items
:
bool
,
rendering_params
:
ImplRenderingParameters
,
)
{
for
trait_item
in
&
t
.items
{
let
n
=
trait_item
.name
;
...
...
@@ -1502,8 +1520,7 @@ fn render_default_items(
render_mode
,
true
,
Some
(
t
),
show_def_docs
,
show_non_assoc_items
,
rendering_params
,
);
}
}
...
...
@@ -1512,7 +1529,7 @@ fn render_default_items(
// default items which weren't overridden in the implementation block.
// We don't emit documentation for default items if they appear in the
// Implementations on Foreign Types or Implementors sections.
if
show_default_items
{
if
rendering_params
.
show_default_items
{
if
let
Some
(
t
)
=
trait_
{
render_default_items
(
&
mut
default_impl_items
,
...
...
@@ -1523,8 +1540,7 @@ fn render_default_items(
&
i
.impl_item
,
parent
,
render_mode
,
show_def_docs
,
show_non_assoc_items
,
rendering_params
,
);
}
}
...
...
@@ -1535,7 +1551,7 @@ fn render_default_items(
write!
(
w
,
"<details class=
\"
rustdoc-toggle implementors-toggle
\"
{}>"
,
if
toggle_open_by_default
{
" open"
}
else
{
""
}
if
rendering_params
.
toggle_open_by_default
{
" open"
}
else
{
""
}
);
write!
(
w
,
"<summary>"
)
}
...
...
@@ -1545,9 +1561,9 @@ fn render_default_items(
i
,
parent
,
parent
,
show_def_docs
,
rendering_params
.
show_def_docs
,
use_absolute
,
is_on_foreign_type
,
rendering_params
.
is_on_foreign_type
,
aliases
,
);
if
toggled
{
...
...
src/librustdoc/html/render/print_item.rs
浏览文件 @
fba4149b
...
...
@@ -17,6 +17,7 @@
collect_paths_for_type
,
document
,
ensure_trailing_slash
,
item_ty_to_strs
,
notable_traits_decl
,
render_assoc_item
,
render_assoc_items
,
render_attributes_in_code
,
render_attributes_in_pre
,
render_impl
,
render_stability_since_raw
,
write_srclink
,
AssocItemLink
,
Context
,
ImplRenderingParameters
,
};
use
crate
::
clean
::{
self
,
GetDefId
};
use
crate
::
formats
::
item_type
::
ItemType
;
...
...
@@ -735,13 +736,15 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
it
,
assoc_link
,
RenderMode
::
Normal
,
false
,
None
,
true
,
false
,
true
,
&
[],
false
,
ImplRenderingParameters
{
show_def_docs
:
false
,
is_on_foreign_type
:
true
,
show_default_items
:
false
,
show_non_assoc_items
:
true
,
toggle_open_by_default
:
false
,
},
);
}
}
...
...
@@ -1396,13 +1399,15 @@ fn render_implementor(
trait_
,
AssocItemLink
::
Anchor
(
None
),
RenderMode
::
Normal
,
false
,
Some
(
use_absolute
),
false
,
false
,
false
,
aliases
,
false
,
ImplRenderingParameters
{
show_def_docs
:
false
,
is_on_foreign_type
:
false
,
show_default_items
:
false
,
show_non_assoc_items
:
false
,
toggle_open_by_default
:
false
,
},
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录