@@ -41,40 +41,38 @@ in where they occur. Use them to group features, for example.
41
41
## Examples:
42
42
43
43
*/
44
- // Note: because rustdoc escapes the first `#` of a line starting with `#`,
45
- // these docs comments have one more `#` ,
46
44
#![ doc = self_test ! ( /**
47
45
[package]
48
46
name = "..."
49
- ## ...
47
+ # ...
50
48
51
49
[features]
52
50
default = ["foo"]
53
- ## ! This comments goes on top
51
+ #! This comments goes on top
54
52
55
- ### The foo feature enables the `foo` functions
53
+ ## The foo feature enables the `foo` functions
56
54
foo = []
57
55
58
- ### The bar feature enables the bar module
56
+ ## The bar feature enables the bar module
59
57
bar = []
60
58
61
- ## ! ### Experimental features
62
- ## ! The following features are experimental
59
+ #! ### Experimental features
60
+ #! The following features are experimental
63
61
64
- ### Enable the fusion reactor
65
- ###
66
- ### ⚠️ Can lead to explosions
62
+ ## Enable the fusion reactor
63
+ ##
64
+ ## ⚠️ Can lead to explosions
67
65
fusion = []
68
66
69
67
[dependencies]
70
68
document-features = "0.2"
71
69
72
- ## ! ### Optional dependencies
70
+ #! ### Optional dependencies
73
71
74
- ### Enable this feature to implement the trait for the types from the genial crate
72
+ ## Enable this feature to implement the trait for the types from the genial crate
75
73
genial = { version = "0.2", optional = true }
76
74
77
- ### This awesome dependency is specified in its own table
75
+ ## This awesome dependency is specified in its own table
78
76
[dependencies.awesome]
79
77
version = "1.3.5"
80
78
optional = true
@@ -465,14 +463,20 @@ fn test_get_balanced() {
465
463
#[ doc( hidden) ]
466
464
/// Helper macro for the tests. Do not use
467
465
pub fn self_test_helper ( input : TokenStream ) -> TokenStream {
468
- process_toml ( ( & input) . to_string ( ) . trim_matches ( |c| c == '"' || c == '#' ) , & Args :: default ( ) )
469
- . map_or_else (
470
- |e| error ( & e) ,
471
- |r| {
472
- std:: iter:: once ( proc_macro:: TokenTree :: from ( proc_macro:: Literal :: string ( & r) ) )
473
- . collect ( )
474
- } ,
475
- )
466
+ let mut code = String :: new ( ) ;
467
+ for line in ( & input) . to_string ( ) . trim_matches ( |c| c == '"' || c == '#' ) . lines ( ) {
468
+ // Rustdoc removes the lines that starts with `# ` and removes one `#` from lines that starts with # followed by space.
469
+ // We need to re-add the `#` that was removed by rustdoc to get the original.
470
+ if line. strip_prefix ( '#' ) . map_or ( false , |x| x. is_empty ( ) || x. starts_with ( ' ' ) ) {
471
+ code += "#" ;
472
+ }
473
+ code += line;
474
+ code += "\n " ;
475
+ }
476
+ process_toml ( & code, & Args :: default ( ) ) . map_or_else (
477
+ |e| error ( & e) ,
478
+ |r| std:: iter:: once ( proc_macro:: TokenTree :: from ( proc_macro:: Literal :: string ( & r) ) ) . collect ( ) ,
479
+ )
476
480
}
477
481
478
482
#[ cfg( feature = "self-test" ) ]
0 commit comments