Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5ac7a035
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
5ac7a035
编写于
2月 26, 2017
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Put the const type and value into <code>
上级
081336e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
88 addition
and
27 deletion
+88
-27
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+1
-1
src/librustdoc/html/format.rs
src/librustdoc/html/format.rs
+70
-18
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+17
-8
未找到文件。
src/librustdoc/clean/mod.rs
浏览文件 @
5ac7a035
...
@@ -1475,7 +1475,7 @@ pub struct PolyTrait {
...
@@ -1475,7 +1475,7 @@ pub struct PolyTrait {
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
/// type out of the AST/TyCtxt given one of these, if more information is needed. Most importantly
/// type out of the AST/TyCtxt given one of these, if more information is needed. Most importantly
/// it does not preserve mutability or boxes.
/// it does not preserve mutability or boxes.
#[derive(Clone,
RustcEncodable,
RustcDecodable,
PartialEq
,
Debug
)]
#[derive(Clone,
RustcEncodable,
RustcDecodable,
PartialEq)]
pub
enum
Type
{
pub
enum
Type
{
/// structs/enums/traits (most that'd be an hir::TyPath)
/// structs/enums/traits (most that'd be an hir::TyPath)
ResolvedPath
{
ResolvedPath
{
...
...
src/librustdoc/html/format.rs
浏览文件 @
5ac7a035
...
@@ -560,7 +560,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...
@@ -560,7 +560,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
}
}
fn
fmt_type
(
t
:
&
clean
::
Type
,
f
:
&
mut
fmt
::
Formatter
,
use_absolute
:
bool
)
->
fmt
::
Result
{
fn
fmt_type
(
t
:
&
clean
::
Type
,
f
:
&
mut
fmt
::
Formatter
,
use_absolute
:
bool
,
is_not_debug
:
bool
)
->
fmt
::
Result
{
match
*
t
{
match
*
t
{
clean
::
Generic
(
ref
name
)
=>
{
clean
::
Generic
(
ref
name
)
=>
{
f
.write_str
(
name
)
f
.write_str
(
name
)
...
@@ -571,7 +572,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -571,7 +572,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
tybounds
(
f
,
typarams
)
tybounds
(
f
,
typarams
)
}
}
clean
::
Infer
=>
write!
(
f
,
"_"
),
clean
::
Infer
=>
write!
(
f
,
"_"
),
clean
::
Primitive
(
prim
)
=>
primitive_link
(
f
,
prim
,
prim
.as_str
()),
clean
::
Primitive
(
prim
)
if
is_not_debug
=>
primitive_link
(
f
,
prim
,
prim
.as_str
()),
clean
::
Primitive
(
prim
)
=>
write!
(
f
,
"{}"
,
prim
.as_str
()),
clean
::
BareFunction
(
ref
decl
)
=>
{
clean
::
BareFunction
(
ref
decl
)
=>
{
if
f
.alternate
()
{
if
f
.alternate
()
{
write!
(
f
,
"{}{}fn{:#}{:#}"
,
write!
(
f
,
"{}{}fn{:#}{:#}"
,
...
@@ -589,26 +591,30 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -589,26 +591,30 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
}
}
clean
::
Tuple
(
ref
typs
)
=>
{
clean
::
Tuple
(
ref
typs
)
=>
{
match
&
typs
[
..
]
{
match
&
typs
[
..
]
{
&
[]
=>
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
"()"
),
&
[]
if
is_not_debug
=>
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
"()"
),
&
[
ref
one
]
=>
{
&
[]
=>
write!
(
f
,
"()"
),
&
[
ref
one
]
if
is_not_debug
=>
{
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
"("
)
?
;
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
"("
)
?
;
//carry f.alternate() into this display w/o branching manually
//carry f.alternate() into this display w/o branching manually
fmt
::
Display
::
fmt
(
one
,
f
)
?
;
fmt
::
Display
::
fmt
(
one
,
f
)
?
;
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
",)"
)
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
",)"
)
}
}
many
=>
{
&
[
ref
one
]
=>
write!
(
f
,
"({},)"
,
one
),
many
if
is_not_debug
=>
{
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
"("
)
?
;
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
"("
)
?
;
fmt
::
Display
::
fmt
(
&
CommaSep
(
&
many
),
f
)
?
;
fmt
::
Display
::
fmt
(
&
CommaSep
(
&
many
),
f
)
?
;
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
")"
)
primitive_link
(
f
,
PrimitiveType
::
Tuple
,
")"
)
}
}
many
=>
write!
(
f
,
"({})"
,
&
CommaSep
(
&
many
)),
}
}
}
}
clean
::
Vector
(
ref
t
)
=>
{
clean
::
Vector
(
ref
t
)
if
is_not_debug
=>
{
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"["
))
?
;
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"["
))
?
;
fmt
::
Display
::
fmt
(
t
,
f
)
?
;
fmt
::
Display
::
fmt
(
t
,
f
)
?
;
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"]"
))
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"]"
))
}
}
clean
::
FixedVector
(
ref
t
,
ref
s
)
=>
{
clean
::
Vector
(
ref
t
)
=>
write!
(
f
,
"[{}]"
,
t
),
clean
::
FixedVector
(
ref
t
,
ref
s
)
if
is_not_debug
=>
{
primitive_link
(
f
,
PrimitiveType
::
Array
,
"["
)
?
;
primitive_link
(
f
,
PrimitiveType
::
Array
,
"["
)
?
;
fmt
::
Display
::
fmt
(
t
,
f
)
?
;
fmt
::
Display
::
fmt
(
t
,
f
)
?
;
if
f
.alternate
()
{
if
f
.alternate
()
{
...
@@ -619,10 +625,17 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -619,10 +625,17 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
&
format!
(
"; {}]"
,
Escape
(
s
)))
&
format!
(
"; {}]"
,
Escape
(
s
)))
}
}
}
}
clean
::
FixedVector
(
ref
t
,
ref
s
)
=>
{
if
f
.alternate
()
{
write!
(
f
,
"[{}; {}]"
,
t
,
s
)
}
else
{
write!
(
f
,
"[{}; {}]"
,
t
,
Escape
(
s
))
}
}
clean
::
Never
=>
f
.write_str
(
"!"
),
clean
::
Never
=>
f
.write_str
(
"!"
),
clean
::
RawPointer
(
m
,
ref
t
)
=>
{
clean
::
RawPointer
(
m
,
ref
t
)
=>
{
match
**
t
{
match
**
t
{
clean
::
Generic
(
_
)
|
clean
::
ResolvedPath
{
is_generic
:
true
,
..
}
=>
{
clean
::
Generic
(
_
)
|
clean
::
ResolvedPath
{
is_generic
:
true
,
..
}
if
is_not_debug
=>
{
if
f
.alternate
()
{
if
f
.alternate
()
{
primitive_link
(
f
,
clean
::
PrimitiveType
::
RawPointer
,
primitive_link
(
f
,
clean
::
PrimitiveType
::
RawPointer
,
&
format!
(
"*{}{:#}"
,
RawMutableSpace
(
m
),
t
))
&
format!
(
"*{}{:#}"
,
RawMutableSpace
(
m
),
t
))
...
@@ -631,11 +644,21 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -631,11 +644,21 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
&
format!
(
"*{}{}"
,
RawMutableSpace
(
m
),
t
))
&
format!
(
"*{}{}"
,
RawMutableSpace
(
m
),
t
))
}
}
}
}
_
=>
{
clean
::
Generic
(
_
)
|
clean
::
ResolvedPath
{
is_generic
:
true
,
..
}
=>
{
if
f
.alternate
()
{
write!
(
f
,
"*{}{:#}"
,
RawMutableSpace
(
m
),
t
)
}
else
{
write!
(
f
,
"*{}{}"
,
RawMutableSpace
(
m
),
t
)
}
}
_
if
is_not_debug
=>
{
primitive_link
(
f
,
clean
::
PrimitiveType
::
RawPointer
,
primitive_link
(
f
,
clean
::
PrimitiveType
::
RawPointer
,
&
format!
(
"*{}"
,
RawMutableSpace
(
m
)))
?
;
&
format!
(
"*{}"
,
RawMutableSpace
(
m
)))
?
;
fmt
::
Display
::
fmt
(
t
,
f
)
fmt
::
Display
::
fmt
(
t
,
f
)
}
}
_
=>
{
write!
(
f
,
"*{}{}"
,
RawMutableSpace
(
m
),
t
)
}
}
}
}
}
clean
::
BorrowedRef
{
lifetime
:
ref
l
,
mutability
,
type_
:
ref
ty
}
=>
{
clean
::
BorrowedRef
{
lifetime
:
ref
l
,
mutability
,
type_
:
ref
ty
}
=>
{
...
@@ -647,15 +670,23 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -647,15 +670,23 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
match
**
ty
{
match
**
ty
{
clean
::
Vector
(
ref
bt
)
=>
{
// BorrowedRef{ ... Vector(T) } is &[T]
clean
::
Vector
(
ref
bt
)
=>
{
// BorrowedRef{ ... Vector(T) } is &[T]
match
**
bt
{
match
**
bt
{
clean
::
Generic
(
_
)
=>
clean
::
Generic
(
_
)
if
is_not_debug
=>
{
if
f
.alternate
()
{
if
f
.alternate
()
{
primitive_link
(
f
,
PrimitiveType
::
Slice
,
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"&{}{}[{:#}]"
,
lt
,
m
,
**
bt
))
&
format!
(
"&{}{}[{:#}]"
,
lt
,
m
,
**
bt
))
}
else
{
}
else
{
primitive_link
(
f
,
PrimitiveType
::
Slice
,
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"&{}{}[{}]"
,
lt
,
m
,
**
bt
))
&
format!
(
"&{}{}[{}]"
,
lt
,
m
,
**
bt
))
},
}
_
=>
{
}
clean
::
Generic
(
_
)
=>
{
if
f
.alternate
()
{
write!
(
f
,
"&{}{}[{:#}]"
,
lt
,
m
,
**
bt
)
}
else
{
write!
(
f
,
"&{}{}[{}]"
,
lt
,
m
,
**
bt
)
}
}
_
if
is_not_debug
=>
{
if
f
.alternate
()
{
if
f
.alternate
()
{
primitive_link
(
f
,
PrimitiveType
::
Slice
,
primitive_link
(
f
,
PrimitiveType
::
Slice
,
&
format!
(
"&{}{}["
,
lt
,
m
))
?
;
&
format!
(
"&{}{}["
,
lt
,
m
))
?
;
...
@@ -667,15 +698,26 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -667,15 +698,26 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
}
}
primitive_link
(
f
,
PrimitiveType
::
Slice
,
"]"
)
primitive_link
(
f
,
PrimitiveType
::
Slice
,
"]"
)
}
}
_
=>
{
if
f
.alternate
()
{
write!
(
f
,
"&{}{}[{:#}]"
,
lt
,
m
,
**
bt
)
}
else
{
write!
(
f
,
"&{}{}[{}]"
,
lt
,
m
,
**
bt
)
}
}
}
}
}
}
_
=>
{
_
=>
{
if
f
.alternate
()
{
if
f
.alternate
()
{
write!
(
f
,
"&{}{}"
,
lt
,
m
)
?
;
write!
(
f
,
"&{}{}"
,
lt
,
m
)
?
;
fmt_type
(
&
ty
,
f
,
use_absolute
)
fmt_type
(
&
ty
,
f
,
use_absolute
,
is_not_debug
)
}
else
{
}
else
{
write!
(
f
,
"&{}{}"
,
lt
,
m
)
?
;
if
is_not_debug
{
fmt_type
(
&
ty
,
f
,
use_absolute
)
write!
(
f
,
"&{}{}"
,
lt
,
m
)
?
;
}
else
{
write!
(
f
,
"&{}{}"
,
lt
,
m
)
?
;
}
fmt_type
(
&
ty
,
f
,
use_absolute
,
is_not_debug
)
}
}
}
}
}
}
...
@@ -725,7 +767,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -725,7 +767,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
if
f
.alternate
()
{
if
f
.alternate
()
{
write!
(
f
,
"<{:#} as {:#}>::{}"
,
self_type
,
trait_
,
name
)
write!
(
f
,
"<{:#} as {:#}>::{}"
,
self_type
,
trait_
,
name
)
}
else
{
}
else
{
write!
(
f
,
"<{} as {}>::{}"
,
self_type
,
trait_
,
name
)
if
is_not_debug
{
write!
(
f
,
"<{} as {}>::{}"
,
self_type
,
trait_
,
name
)
}
else
{
write!
(
f
,
"<{} as {}>::{}"
,
self_type
,
trait_
,
name
)
}
}
}
}
}
clean
::
Unique
(
..
)
=>
{
clean
::
Unique
(
..
)
=>
{
...
@@ -736,7 +782,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
...
@@ -736,7 +782,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
impl
fmt
::
Display
for
clean
::
Type
{
impl
fmt
::
Display
for
clean
::
Type
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fmt_type
(
self
,
f
,
false
)
fmt_type
(
self
,
f
,
false
,
true
)
}
}
impl
fmt
::
Debug
for
clean
::
Type
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fmt_type
(
self
,
f
,
false
,
false
)
}
}
}
}
...
@@ -777,7 +829,7 @@ fn fmt_impl(i: &clean::Impl,
...
@@ -777,7 +829,7 @@ fn fmt_impl(i: &clean::Impl,
plain
.push_str
(
" for "
);
plain
.push_str
(
" for "
);
}
}
fmt_type
(
&
i
.for_
,
f
,
use_absolute
)
?
;
fmt_type
(
&
i
.for_
,
f
,
use_absolute
,
true
)
?
;
plain
.push_str
(
&
format!
(
"{:#}"
,
i
.for_
));
plain
.push_str
(
&
format!
(
"{:#}"
,
i
.for_
));
fmt
::
Display
::
fmt
(
&
WhereClause
(
&
i
.generics
,
plain
.len
()
+
1
),
f
)
?
;
fmt
::
Display
::
fmt
(
&
WhereClause
(
&
i
.generics
,
plain
.len
()
+
1
),
f
)
?
;
...
...
src/librustdoc/html/render.rs
浏览文件 @
5ac7a035
...
@@ -1654,9 +1654,23 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin
...
@@ -1654,9 +1654,23 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin
Ok
(())
Ok
(())
}
}
fn
md_render_assoc_item
(
item
:
&
clean
::
Item
)
->
String
{
match
item
.inner
{
clean
::
AssociatedConstItem
(
ref
ty
,
ref
default
)
=>
{
if
let
Some
(
default
)
=
default
.as_ref
()
{
format!
(
"```
\n
{}: {:?} = {}
\n
```
\n\n
"
,
item
.name
.as_ref
()
.unwrap
(),
ty
,
default
)
}
else
{
format!
(
"```
\n
{}: {:?}
\n
```
\n\n
"
,
item
.name
.as_ref
()
.unwrap
(),
ty
)
}
}
_
=>
String
::
new
(),
}
}
fn
document_full
(
w
:
&
mut
fmt
::
Formatter
,
item
:
&
clean
::
Item
)
->
fmt
::
Result
{
fn
document_full
(
w
:
&
mut
fmt
::
Formatter
,
item
:
&
clean
::
Item
)
->
fmt
::
Result
{
if
let
Some
(
s
)
=
item
.doc_value
()
{
if
let
Some
(
s
)
=
item
.doc_value
()
{
write!
(
w
,
"<div class='docblock'>{}</div>"
,
Markdown
(
s
))
?
;
write!
(
w
,
"<div class='docblock'>{}</div>"
,
Markdown
(
&
format!
(
"{}{}"
,
md_render_assoc_item
(
item
),
s
)))
?
;
}
}
Ok
(())
Ok
(())
}
}
...
@@ -2214,17 +2228,12 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String {
...
@@ -2214,17 +2228,12 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String {
fn
assoc_const
(
w
:
&
mut
fmt
::
Formatter
,
fn
assoc_const
(
w
:
&
mut
fmt
::
Formatter
,
it
:
&
clean
::
Item
,
it
:
&
clean
::
Item
,
ty
:
&
clean
::
Type
,
_
ty
:
&
clean
::
Type
,
default
:
Option
<&
String
>
,
_
default
:
Option
<&
String
>
,
link
:
AssocItemLink
)
->
fmt
::
Result
{
link
:
AssocItemLink
)
->
fmt
::
Result
{
write!
(
w
,
"const <a href='{}' class='constant'><b>{}</b></a>"
,
write!
(
w
,
"const <a href='{}' class='constant'><b>{}</b></a>"
,
naive_assoc_href
(
it
,
link
),
naive_assoc_href
(
it
,
link
),
it
.name
.as_ref
()
.unwrap
())
?
;
it
.name
.as_ref
()
.unwrap
())
?
;
write!
(
w
,
": {}"
,
ty
)
?
;
if
let
Some
(
default
)
=
default
{
write!
(
w
,
" = {}"
,
Escape
(
default
))
?
;
}
Ok
(())
Ok
(())
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录