@@ -5,40 +5,19 @@ import std::io::writer_util;
5
5
6
6
export mk_pass;
7
7
8
+ fn mk_pass ( config : config:: config ) -> pass {
9
+ mk_pass_ ( config, { |f| f ( std:: io:: stdout ( ) ) } )
10
+ }
11
+
8
12
// FIXME: This is a really convoluted interface to work around trying
9
13
// to get a writer into a unique closure and then being able to test
10
14
// what was written afterward
11
- fn mk_pass (
15
+ fn mk_pass_ (
16
+ config : config:: config ,
12
17
give_writer : fn ~( fn ( io:: writer ) )
13
18
) -> pass {
14
- let f = fn ~(
15
- srv: astsrv:: srv,
16
- doc: doc:: cratedoc
17
- ) -> doc:: cratedoc {
18
-
19
- fn mods_last( item1: doc:: itemtag, item2: doc:: itemtag) -> bool {
20
- fn is_mod ( item : doc:: itemtag ) -> bool {
21
- alt item {
22
- doc : : modtag ( _) { true }
23
- _ { false }
24
- }
25
- }
26
-
27
- let lteq = !is_mod ( item1) || is_mod ( item2) ;
28
- lteq
29
- }
30
-
31
- give_writer { |writer|
32
- // Sort the items so mods come last. All mods will be
33
- // output at the same header level so sorting mods last
34
- // makes the headers come out nested correctly.
35
- let sorted_doc = sort_pass:: mk_pass (
36
- "mods last" , mods_last
37
- ) . f ( srv, doc) ;
38
-
39
- write_markdown ( sorted_doc, writer) ;
40
- }
41
- doc
19
+ let f = fn ~( srv: astsrv:: srv, doc: doc:: cratedoc) -> doc:: cratedoc {
20
+ run( srv, doc, config, give_writer)
42
21
} ;
43
22
44
23
{
@@ -47,6 +26,38 @@ fn mk_pass(
47
26
}
48
27
}
49
28
29
+ fn run (
30
+ srv : astsrv:: srv ,
31
+ doc : doc:: cratedoc ,
32
+ _config : config:: config ,
33
+ give_writer : fn ~( fn ( io:: writer ) )
34
+ ) -> doc:: cratedoc {
35
+
36
+ fn mods_last ( item1 : doc:: itemtag , item2 : doc:: itemtag ) -> bool {
37
+ fn is_mod ( item : doc:: itemtag ) -> bool {
38
+ alt item {
39
+ doc : : modtag ( _) { true }
40
+ _ { false }
41
+ }
42
+ }
43
+
44
+ let lteq = !is_mod ( item1) || is_mod ( item2) ;
45
+ lteq
46
+ }
47
+
48
+ give_writer { |writer|
49
+ // Sort the items so mods come last. All mods will be
50
+ // output at the same header level so sorting mods last
51
+ // makes the headers come out nested correctly.
52
+ let sorted_doc = sort_pass:: mk_pass (
53
+ "mods last" , mods_last
54
+ ) . f ( srv, doc) ;
55
+
56
+ write_markdown ( sorted_doc, writer) ;
57
+ }
58
+ doc
59
+ }
60
+
50
61
#[ test]
51
62
fn should_write_modules_last ( ) {
52
63
/*
@@ -858,7 +869,7 @@ mod test {
858
869
let port = comm:: port ( ) ;
859
870
let chan = comm:: chan ( port) ;
860
871
861
- let pass = mk_pass { |f|
872
+ let pass = mk_pass_ ( config :: default_config ( "" ) ) { |f|
862
873
let buffer = io:: mk_mem_buffer ( ) ;
863
874
let writer = io:: mem_buffer_writer ( buffer) ;
864
875
f ( writer) ;
0 commit comments