Pretty-print macro matchers instead of using source code

The output is not quite as nice as it used to be, but it does work.
This commit is contained in:
Noah Lev 2021-06-13 15:30:05 -07:00
parent f749d97b8a
commit f82d4845f2
6 changed files with 53 additions and 62 deletions

View file

@ -9,7 +9,7 @@ pub macro my_macro() {
}
// @has decl_macro/macro.my_macro_2.html //pre 'pub macro my_macro_2($($tok:tt)*) {'
// @has decl_macro/macro.my_macro_2.html //pre 'pub macro my_macro_2($ ($ tok : tt) *) {'
// @has - //pre '...'
// @has - //pre '}'
pub macro my_macro_2($($tok:tt)*) {
@ -18,8 +18,8 @@ pub macro my_macro_2($($tok:tt)*) {
// @has decl_macro/macro.my_macro_multi.html //pre 'pub macro my_macro_multi {'
// @has - //pre '(_) => { ... },'
// @has - //pre '($foo:ident . $bar:expr) => { ... },'
// @has - //pre '($($foo:literal),+) => { ... }'
// @has - //pre '($ foo : ident.$ bar : expr) => { ... },'
// @has - //pre '($ ($ foo : literal), +) => { ... },'
// @has - //pre '}'
pub macro my_macro_multi {
(_) => {
@ -33,7 +33,7 @@ pub macro my_macro_multi {
}
}
// @has decl_macro/macro.by_example_single.html //pre 'pub macro by_example_single($foo:expr) {'
// @has decl_macro/macro.by_example_single.html //pre 'pub macro by_example_single($ foo : expr) {'
// @has - //pre '...'
// @has - //pre '}'
pub macro by_example_single {
@ -42,12 +42,12 @@ pub macro by_example_single {
mod a {
mod b {
// @has decl_macro/a/b/macro.by_example_vis.html //pre 'pub(super) macro by_example_vis($foo:expr) {'
// @has decl_macro/a/b/macro.by_example_vis.html //pre 'pub(super) macro by_example_vis($ foo : expr) {'
pub(in super) macro by_example_vis {
($foo:expr) => {}
}
mod c {
// @has decl_macro/a/b/c/macro.by_example_vis_named.html //pre 'pub(in a) macro by_example_vis_named($foo:expr) {'
// @has decl_macro/a/b/c/macro.by_example_vis_named.html //pre 'pub(in a) macro by_example_vis_named($ foo : expr) {'
pub(in a) macro by_example_vis_named {
($foo:expr) => {}
}

View file

@ -7,16 +7,15 @@
// @has - '//span[@class="macro"]' 'macro_rules!'
// @has - '//span[@class="ident"]' 'todo'
// Note: count = 2 * ('=' + '>') + '+' = 2 * (1 + 1) + 1 = 5
// @count - '//span[@class="op"]' 5
// @count - '//pre[@class="rust macro"]//span[@class="op"]' 5
// @has - '{ ()'
// @has - '//span[@class="op"]' '='
// @has - '//span[@class="op"]' '>'
// @has - '{ ... };'
// @has - '($('
// @has - '//span[@class="macro-nonterminal"]' '$'
// @has - '//span[@class="macro-nonterminal"]' 'arg'
// @has - '($ ($'
// @has - '//span[@class="ident"]' 'arg'
// @has - ':'
// @has - '//span[@class="ident"]' 'tt'
// @has - '//span[@class="op"]' '+'
@ -28,7 +27,7 @@ mod mod1 {
// @has - 'macro_rules!'
// @has - 'macro1'
// @has - '{ ()'
// @has - '($('
// @has - '($ ('
// @has - 'arg'
// @has - 'expr'
// @has - ','

View file

@ -1,7 +1,7 @@
// @has macros/macro.my_macro.html //pre 'macro_rules! my_macro {'
// @has - //pre '() => { ... };'
// @has - //pre '($a:tt) => { ... };'
// @has - //pre '($e:expr) => { ... };'
// @has - //pre '($ a : tt) => { ... };'
// @has - //pre '($ e : expr) => { ... };'
#[macro_export]
macro_rules! my_macro {
() => [];
@ -12,8 +12,8 @@ macro_rules! my_macro {
// Check that exported macro defined in a module are shown at crate root.
// @has macros/macro.my_sub_macro.html //pre 'macro_rules! my_sub_macro {'
// @has - //pre '() => { ... };'
// @has - //pre '($a:tt) => { ... };'
// @has - //pre '($e:expr) => { ... };'
// @has - //pre '($ a : tt) => { ... };'
// @has - //pre '($ e : expr) => { ... };'
mod sub {
#[macro_export]
macro_rules! my_sub_macro {