File tree Expand file tree Collapse file tree 4 files changed +70
-1
lines changed
branches/dist-snap/src/rustdoc Expand file tree Collapse file tree 4 files changed +70
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9
9
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10
- refs/heads/dist-snap: c32cde16ab1cd7d8483d176591c22dbac3520833
10
+ refs/heads/dist-snap: 60443d48881bfbc7a305e807390e74b327f100b8
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change
1
+ //! Prune things that are private
2
+
3
+ export mk_pass;
4
+
5
+ fn mk_pass ( ) -> Pass {
6
+ {
7
+ name: ~"prune_private",
8
+ f: run
9
+ }
10
+ }
11
+
12
+ fn run ( srv : astsrv:: Srv , doc : doc:: Doc ) -> doc:: Doc {
13
+ let fold = fold:: Fold ( {
14
+ fold_mod: fold_mod,
15
+ .. * fold:: default_any_fold ( srv)
16
+ } ) ;
17
+ fold. fold_doc ( fold, doc)
18
+ }
19
+
20
+ fn fold_mod (
21
+ fold : fold:: Fold < astsrv:: Srv > ,
22
+ doc : doc:: ModDoc
23
+ ) -> doc:: ModDoc {
24
+ let doc = fold:: default_any_fold_mod ( fold, doc) ;
25
+
26
+ doc:: ModDoc_ ( {
27
+ items: do doc. items . filter |ItemTag | {
28
+ is_visible ( fold. ctxt , ItemTag . item ( ) )
29
+ } ,
30
+ .. * doc
31
+ } )
32
+ }
33
+
34
+ fn is_visible ( srv : astsrv:: Srv , doc : doc:: ItemDoc ) -> bool {
35
+ use syntax:: ast_map;
36
+ use syntax:: ast;
37
+
38
+ let id = doc. id ;
39
+
40
+ do astsrv:: exec ( srv) |ctxt| {
41
+ match ctxt. ast_map . get ( id) {
42
+ ast_map:: node_item( item, _) => {
43
+ item. vis == ast:: public
44
+ }
45
+ _ => util:: unreachable ( )
46
+ }
47
+ }
48
+ }
49
+
50
+ #[ test]
51
+ fn should_prune_items_without_pub_modifier ( ) {
52
+ let doc = test:: mk_doc ( ~"mod a { } ") ;
53
+ assert vec:: is_empty ( doc. cratemod ( ) . mods ( ) ) ;
54
+ }
55
+
56
+ #[ cfg( test) ]
57
+ mod test {
58
+ fn mk_doc ( source : ~str ) -> doc:: Doc {
59
+ do astsrv:: from_str ( source) |srv| {
60
+ let doc = extract:: from_srv ( srv, ~"") ;
61
+ run ( srv, doc)
62
+ }
63
+ }
64
+ }
65
+
Original file line number Diff line number Diff line change @@ -49,3 +49,4 @@ mod sort_item_type_pass;
49
49
mod page_pass;
50
50
mod sectionalize_pass;
51
51
mod escape_pass;
52
+ mod prune_private_pass;
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ fn run(config: Config) {
53
53
escape_pass:: mk_pass ( ) ,
54
54
// Remove things marked doc(hidden)
55
55
prune_hidden_pass:: mk_pass ( ) ,
56
+ // Remove things that are private
57
+ // XXX enable this after 'export' is removed in favor of 'pub'
58
+ // prune_private_pass::mk_pass(),
56
59
// Extract brief documentation from the full descriptions
57
60
desc_to_brief_pass:: mk_pass ( ) ,
58
61
// Massage the text to remove extra indentation
You can’t perform that action at this time.
0 commit comments