@@ -20,6 +20,28 @@ struct Assist {
2020 after : String ,
2121}
2222
23+ fn hide_hash_comments ( text : & str ) -> String {
24+ text. split ( '\n' ) // want final newline
25+ . filter ( |& it| !( it. starts_with ( "# " ) || it == "#" ) )
26+ . map ( |it| format ! ( "{}\n " , it) )
27+ . collect ( )
28+ }
29+
30+ fn reveal_hash_comments ( text : & str ) -> String {
31+ text. split ( '\n' ) // want final newline
32+ . map ( |it| {
33+ if it. starts_with ( "# " ) {
34+ & it[ 2 ..]
35+ } else if it == "#" {
36+ ""
37+ } else {
38+ it
39+ }
40+ } )
41+ . map ( |it| format ! ( "{}\n " , it) )
42+ . collect ( )
43+ }
44+
2345fn collect_assists ( ) -> Result < Vec < Assist > > {
2446 let mut res = Vec :: new ( ) ;
2547 for entry in fs:: read_dir ( project_root ( ) . join ( codegen:: ASSISTS_DIR ) ) ? {
@@ -91,13 +113,14 @@ fn doctest_{}() {{
91113 check(
92114 "{}",
93115r#####"
94- {}
95- "#####, r#####"
96- {}
97- "#####)
116+ {}"#####, r#####"
117+ {}"#####)
98118}}
99119"###### ,
100- assist. id, assist. id, assist. before, assist. after
120+ assist. id,
121+ assist. id,
122+ reveal_hash_comments( & assist. before) ,
123+ reveal_hash_comments( & assist. after)
101124 ) ;
102125
103126 buf. push_str ( & test)
@@ -123,12 +146,13 @@ fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
123146```rust
124147// BEFORE
125148{}
126-
127149// AFTER
128- {}
129- ```
150+ {}```
130151" ,
131- assist. id, assist. doc, before, after
152+ assist. id,
153+ assist. doc,
154+ hide_hash_comments( & before) ,
155+ hide_hash_comments( & after)
132156 ) ;
133157 buf. push_str ( & docs) ;
134158 }
0 commit comments