Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
58a257bc
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
58a257bc
编写于
12月 23, 2014
作者:
L
Liigo Zhuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustdoc: add tooltips to sidebar
上级
6869645e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
11 deletion
+23
-11
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+20
-10
src/librustdoc/html/static/main.js
src/librustdoc/html/static/main.js
+3
-1
未找到文件。
src/librustdoc/html/render.rs
浏览文件 @
58a257bc
...
@@ -66,6 +66,10 @@
...
@@ -66,6 +66,10 @@
use
html
::
markdown
;
use
html
::
markdown
;
use
stability_summary
;
use
stability_summary
;
/// A pair of name and its optional document.
#[deriving(Clone,
Eq,
Ord,
PartialEq,
PartialOrd)]
pub
struct
NameDoc
(
String
,
Option
<
String
>
);
/// Major driving force in all rustdoc rendering. This contains information
/// Major driving force in all rustdoc rendering. This contains information
/// about where in the tree-like hierarchy rendering is occurring and controls
/// about where in the tree-like hierarchy rendering is occurring and controls
/// how the current page is being rendered.
/// how the current page is being rendered.
...
@@ -95,7 +99,7 @@ pub struct Context {
...
@@ -95,7 +99,7 @@ pub struct Context {
/// functions), and the value is the list of containers belonging to this
/// functions), and the value is the list of containers belonging to this
/// header. This map will change depending on the surrounding context of the
/// header. This map will change depending on the surrounding context of the
/// page.
/// page.
pub
sidebar
:
HashMap
<
String
,
Vec
<
String
>>
,
pub
sidebar
:
HashMap
<
String
,
Vec
<
NameDoc
>>
,
/// This flag indicates whether [src] links should be generated or not. If
/// This flag indicates whether [src] links should be generated or not. If
/// the source files are present in the html rendering, then this will be
/// the source files are present in the html rendering, then this will be
/// `true`.
/// `true`.
...
@@ -1245,7 +1249,7 @@ fn render(w: io::File, cx: &Context, it: &clean::Item,
...
@@ -1245,7 +1249,7 @@ fn render(w: io::File, cx: &Context, it: &clean::Item,
}
}
}
}
fn
build_sidebar
(
&
self
,
m
:
&
clean
::
Module
)
->
HashMap
<
String
,
Vec
<
String
>>
{
fn
build_sidebar
(
&
self
,
m
:
&
clean
::
Module
)
->
HashMap
<
String
,
Vec
<
NameDoc
>>
{
let
mut
map
=
HashMap
::
new
();
let
mut
map
=
HashMap
::
new
();
for
item
in
m
.items
.iter
()
{
for
item
in
m
.items
.iter
()
{
if
self
.ignore_private_item
(
item
)
{
continue
}
if
self
.ignore_private_item
(
item
)
{
continue
}
...
@@ -1262,7 +1266,7 @@ fn build_sidebar(&self, m: &clean::Module) -> HashMap<String, Vec<String>> {
...
@@ -1262,7 +1266,7 @@ fn build_sidebar(&self, m: &clean::Module) -> HashMap<String, Vec<String>> {
let
short
=
short
.to_string
();
let
short
=
short
.to_string
();
let
v
=
map
.entry
(
short
)
.get
()
.unwrap_or_else
(
let
v
=
map
.entry
(
short
)
.get
()
.unwrap_or_else
(
|
vacant_entry
|
vacant_entry
.insert
(
Vec
::
with_capacity
(
1
)));
|
vacant_entry
|
vacant_entry
.insert
(
Vec
::
with_capacity
(
1
)));
v
.push
(
myname
);
v
.push
(
NameDoc
(
myname
,
Some
(
shorter_line
(
item
.doc_value
())))
);
}
}
for
(
_
,
items
)
in
map
.iter_mut
()
{
for
(
_
,
items
)
in
map
.iter_mut
()
{
...
@@ -1476,6 +1480,11 @@ fn shorter<'a>(s: Option<&'a str>) -> &'a str {
...
@@ -1476,6 +1480,11 @@ fn shorter<'a>(s: Option<&'a str>) -> &'a str {
}
}
}
}
#[inline]
fn
shorter_line
(
s
:
Option
<&
str
>
)
->
String
{
shorter
(
s
)
.replace
(
"
\n
"
,
" "
)
}
fn
document
(
w
:
&
mut
fmt
::
Formatter
,
item
:
&
clean
::
Item
)
->
fmt
::
Result
{
fn
document
(
w
:
&
mut
fmt
::
Formatter
,
item
:
&
clean
::
Item
)
->
fmt
::
Result
{
match
item
.doc_value
()
{
match
item
.doc_value
()
{
Some
(
s
)
=>
{
Some
(
s
)
=>
{
...
@@ -2213,21 +2222,22 @@ fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
...
@@ -2213,21 +2222,22 @@ fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
None
=>
return
Ok
(())
None
=>
return
Ok
(())
};
};
try!
(
write!
(
w
,
"<div class='block {}'><h2>{}</h2>"
,
short
,
longty
));
try!
(
write!
(
w
,
"<div class='block {}'><h2>{}</h2>"
,
short
,
longty
));
for
item
in
items
.iter
()
{
for
&
NameDoc
(
ref
name
,
ref
doc
)
in
items
.iter
()
{
let
curty
=
shortty
(
cur
)
.to_static_str
();
let
curty
=
shortty
(
cur
)
.to_static_str
();
let
class
=
if
cur
.name
.as_ref
()
.unwrap
()
==
item
&&
let
class
=
if
cur
.name
.as_ref
()
.unwrap
()
==
name
&&
short
==
curty
{
"current"
}
else
{
""
};
short
==
curty
{
"current"
}
else
{
""
};
try!
(
write!
(
w
,
"<a class='{ty} {class}' href='{href}{path}'
>
\
try!
(
write!
(
w
,
"<a class='{ty} {class}' href='{href}{path}'
\
{name}</a>"
,
title='{title}'>
{name}</a>"
,
ty
=
short
,
ty
=
short
,
class
=
class
,
class
=
class
,
href
=
if
curty
==
"mod"
{
"../"
}
else
{
""
},
href
=
if
curty
==
"mod"
{
"../"
}
else
{
""
},
path
=
if
short
==
"mod"
{
path
=
if
short
==
"mod"
{
format!
(
"{}/index.html"
,
item
.as_slice
())
format!
(
"{}/index.html"
,
name
.as_slice
())
}
else
{
}
else
{
format!
(
"{}.{}.html"
,
short
,
item
.as_slice
())
format!
(
"{}.{}.html"
,
short
,
name
.as_slice
())
},
},
name
=
item
.as_slice
()));
title
=
doc
.as_ref
()
.unwrap
()
.as_slice
(),
name
=
name
.as_slice
()));
}
}
try!
(
write!
(
w
,
"</div>"
));
try!
(
write!
(
w
,
"</div>"
));
Ok
(())
Ok
(())
...
...
src/librustdoc/html/static/main.js
浏览文件 @
58a257bc
...
@@ -689,8 +689,10 @@
...
@@ -689,8 +689,10 @@
if
(
crates
[
i
]
==
window
.
currentCrate
)
{
if
(
crates
[
i
]
==
window
.
currentCrate
)
{
klass
+=
'
current
'
;
klass
+=
'
current
'
;
}
}
var
desc
=
rawSearchIndex
[
crates
[
i
]].
items
[
0
][
3
];
div
.
append
(
$
(
'
<a>
'
,
{
'
href
'
:
'
../
'
+
crates
[
i
]
+
'
/index.html
'
,
div
.
append
(
$
(
'
<a>
'
,
{
'
href
'
:
'
../
'
+
crates
[
i
]
+
'
/index.html
'
,
'
class
'
:
klass
}).
text
(
crates
[
i
]));
'
title
'
:
desc
.
replace
(
/
\n
/g
,
'
'
),
'
class
'
:
klass
}).
text
(
crates
[
i
]));
}
}
sidebar
.
append
(
div
);
sidebar
.
append
(
div
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录