Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c32cde16
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,发现更多精彩内容 >>
提交
c32cde16
编写于
9月 21, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustdoc: Cleanup
上级
3c2b6110
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
120 addition
and
98 deletion
+120
-98
src/rustdoc/pass.rs
src/rustdoc/pass.rs
+79
-0
src/rustdoc/rustdoc.rc
src/rustdoc/rustdoc.rc
+3
-3
src/rustdoc/rustdoc.rs
src/rustdoc/rustdoc.rs
+38
-95
未找到文件。
src/rustdoc/pass.rs
0 → 100644
浏览文件 @
c32cde16
/// A single operation on the document model
pub
type
Pass
=
{
name
:
~
str
,
f
:
fn
~
(
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
)
->
doc
::
Doc
};
pub
fn
run_passes
(
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
,
passes
:
~
[
Pass
]
)
->
doc
::
Doc
{
let
mut
passno
=
0
;
do
vec
::
foldl
(
doc
,
passes
)
|
doc
,
pass
|
{
log
(
debug
,
fmt!
(
"pass #%d"
,
passno
));
passno
+=
1
;
log
(
debug
,
doc
);
do
time
(
pass
.name
)
{
pass
.f
(
srv
,
doc
)
}
}
}
#[test]
fn
test_run_passes
()
{
fn
pass1
(
_
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
)
->
doc
::
Doc
{
doc
::
Doc_
({
pages
:
~
[
doc
::
CratePage
({
topmod
:
doc
::
ModDoc_
({
item
:
{
name
:
doc
.cratemod
()
.name
()
+
~
"two"
,
..
doc
.cratemod
()
.item
},
items
:
~
[],
index
:
None
})
})
]
})
}
fn
pass2
(
_
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
)
->
doc
::
Doc
{
doc
::
Doc_
({
pages
:
~
[
doc
::
CratePage
({
topmod
:
doc
::
ModDoc_
({
item
:
{
name
:
doc
.cratemod
()
.name
()
+
~
"three"
,
..
doc
.cratemod
()
.item
},
items
:
~
[],
index
:
None
})
})
]
})
}
let
source
=
~
""
;
do
astsrv
::
from_str
(
source
)
|
srv
|
{
let
passes
=
~
[
{
name
:
~
""
,
f
:
pass1
},
{
name
:
~
""
,
f
:
pass2
}
];
let
doc
=
extract
::
from_srv
(
srv
,
~
"one"
);
let
doc
=
run_passes
(
srv
,
doc
,
passes
);
assert
doc
.cratemod
()
.name
()
==
~
"onetwothree"
;
}
}
src/rustdoc/rustdoc.rc
浏览文件 @
c32cde16
...
...
@@ -10,11 +10,10 @@
#[crate_type = "bin"];
#[no_core];
#[legacy_modes];
#[allow(vecs_implicitly_copyable
,
non_implicitly_copyable_typarams)];
#[allow(vecs_implicitly_copyable
)];
#[allow(
non_implicitly_copyable_typarams)];
extern mod core(vers = "0.4");
extern mod std(vers = "0.4");
...
...
@@ -24,6 +23,7 @@ extern mod syntax(vers = "0.4");
use core::*;
use std::par;
mod pass;
mod config;
mod parse;
mod extract;
...
...
src/rustdoc/rustdoc.rs
浏览文件 @
c32cde16
//! Some utility interfaces
use
doc
::
ItemUtils
;
use
doc
::
Item
;
use
doc
::
util
;
/// A single operation on the document model
type
Pass
=
{
name
:
~
str
,
f
:
fn
~
(
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
)
->
doc
::
Doc
};
fn
run_passes
(
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
,
passes
:
~
[
Pass
]
)
->
doc
::
Doc
{
let
mut
passno
=
0
;
do
vec
::
foldl
(
doc
,
passes
)
|
doc
,
pass
|
{
log
(
debug
,
fmt!
(
"pass #%d"
,
passno
));
passno
+=
1
;
log
(
debug
,
doc
);
do
time
(
pass
.name
)
{
pass
.f
(
srv
,
doc
)
}
}
}
#[test]
fn
test_run_passes
()
{
fn
pass1
(
_
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
)
->
doc
::
Doc
{
doc
::
Doc_
({
pages
:
~
[
doc
::
CratePage
({
topmod
:
doc
::
ModDoc_
({
item
:
{
name
:
doc
.cratemod
()
.name
()
+
~
"two"
,
..
doc
.cratemod
()
.item
},
items
:
~
[],
index
:
None
})
})
]
})
}
fn
pass2
(
_
srv
:
astsrv
::
Srv
,
doc
:
doc
::
Doc
)
->
doc
::
Doc
{
doc
::
Doc_
({
pages
:
~
[
doc
::
CratePage
({
topmod
:
doc
::
ModDoc_
({
item
:
{
name
:
doc
.cratemod
()
.name
()
+
~
"three"
,
..
doc
.cratemod
()
.item
},
items
:
~
[],
index
:
None
})
})
]
})
}
let
source
=
~
""
;
do
astsrv
::
from_str
(
source
)
|
srv
|
{
let
passes
=
~
[
{
name
:
~
""
,
f
:
pass1
},
{
name
:
~
""
,
f
:
pass2
}
];
let
doc
=
extract
::
from_srv
(
srv
,
~
"one"
);
let
doc
=
run_passes
(
srv
,
doc
,
passes
);
assert
doc
.cratemod
()
.name
()
==
~
"onetwothree"
;
}
}
use
pass
::
Pass
;
use
config
::
Config
;
fn
main
(
args
:
~
[
~
str
])
{
...
...
@@ -92,8 +11,8 @@ fn main(args: ~[~str]) {
}
let
config
=
match
config
::
parse_config
(
args
)
{
result
::
Ok
(
config
)
=>
config
,
result
::
Err
(
err
)
=>
{
Ok
(
config
)
=>
config
,
Err
(
err
)
=>
{
io
::
println
(
fmt!
(
"error: %s"
,
err
));
return
;
}
...
...
@@ -102,43 +21,67 @@ fn main(args: ~[~str]) {
run
(
config
);
}
fn
time
<
T
>
(
what
:
~
str
,
f
:
fn
()
->
T
)
->
T
{
let
start
=
std
::
time
::
precise_time_s
();
let
rv
=
f
();
let
end
=
std
::
time
::
precise_time_s
();
info!
(
"time: %3.3f s %s"
,
end
-
start
,
what
);
return
rv
;
}
/// Runs rustdoc over the given file
fn
run
(
config
:
config
::
Config
)
{
fn
run
(
config
:
Config
)
{
let
source_file
=
config
.input_crate
;
// Create an AST service from the source code
do
astsrv
::
from_file
(
source_file
.to_str
())
|
srv
|
{
// Just time how long it takes for the AST to become available
do
time
(
~
"wait_ast"
)
{
do
astsrv
::
exec
(
srv
)
|
_
ctxt
|
{
}
};
// Extract the initial doc tree from the AST. This contains
// just names and node ids.
let
doc
=
time
(
~
"extract"
,
||
{
let
default_name
=
source_file
;
extract
::
from_srv
(
srv
,
default_name
.to_str
())
});
run_passes
(
srv
,
doc
,
~
[
// Refine and publish the document
pass
::
run_passes
(
srv
,
doc
,
~
[
// Generate type and signature strings
tystr_pass
::
mk_pass
(),
// Record the full paths to various nodes
path_pass
::
mk_pass
(),
// Extract the docs attributes and attach them to doc nodes
attr_pass
::
mk_pass
(),
// Perform various text escaping
escape_pass
::
mk_pass
(),
// Remove things marked doc(hidden)
prune_hidden_pass
::
mk_pass
(),
// Extract brief documentation from the full descriptions
desc_to_brief_pass
::
mk_pass
(),
// Massage the text to remove extra indentation
unindent_pass
::
mk_pass
(),
// Split text into multiple sections according to headers
sectionalize_pass
::
mk_pass
(),
// Trim extra spaces from text
trim_pass
::
mk_pass
(),
// Sort items by name
sort_item_name_pass
::
mk_pass
(),
// Sort items again by kind
sort_item_type_pass
::
mk_pass
(),
// Create indexes appropriate for markdown
markdown_index_pass
::
mk_pass
(
config
),
// Break the document into pages if required by the
// output format
page_pass
::
mk_pass
(
config
.output_style
),
// Render
markdown_pass
::
mk_pass
(
markdown_writer
::
make_writer_factory
(
config
)
)
]);
}
}
fn
time
<
T
>
(
what
:
~
str
,
f
:
fn
()
->
T
)
->
T
{
let
start
=
std
::
time
::
precise_time_s
();
let
rv
=
f
();
let
end
=
std
::
time
::
precise_time_s
();
info!
(
"time: %3.3f s %s"
,
end
-
start
,
what
);
return
rv
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录