tamer: xir::parse: Improvements to generated docs for NIR attributes

This hides the internal state machine and provides better language for what
remains.

DEV-7145
main
Mike Gerwitz 2022-09-16 13:37:46 -04:00
parent 1dc691160b
commit dcb42b6e4b
2 changed files with 8 additions and 9 deletions

View File

@ -102,7 +102,7 @@ macro_rules! attr_parse {
$(vis($vis:vis);)?
$(type ValueError = $evty:ty;)?
struct $state_name:ident -> $struct_name:ident {
struct $(#[$st_attr:meta])? $state_name:ident -> $struct_name:ident {
$(
$(#[$fattr:meta])*
$field:ident: ($qname:ident $($fmod:tt)?) => $ty:ty,
@ -117,6 +117,8 @@ macro_rules! attr_parse {
$crate::attr_parse!(@ty_assert $($fmod)? $ty);
)*
$(#[$st_attr])?
///
#[doc=concat!("Parser producing [`", stringify!($struct_name), "`].")]
///
/// Unlike the final type,
@ -225,12 +227,6 @@ macro_rules! attr_parse {
}
$(#[$sattr])*
#[doc=""]
#[doc=concat!(
"This is produced by the parser [`",
stringify!($state_name),
"`]."
)]
#[derive(Debug, PartialEq)]
$($vis)? struct $struct_name {
$(

View File

@ -436,10 +436,12 @@ macro_rules! ele_parse {
}
) => { paste::paste! {
crate::attr_parse! {
/// Attribute parser for
#[doc=concat!("[`", stringify!($nt), "`].")]
vis($vis);
$(type ValueError = $evty;)?
struct [<$nt AttrState_>] -> [<$nt Attrs>] {
struct #[doc(hidden)] [<$nt AttrState_>] -> [<$nt Attrs>] {
$(
$(#[$fattr])*
$field: ($($fmatch)+) => $fty,
@ -471,7 +473,8 @@ macro_rules! ele_parse {
$(#[$nt_attr])*
///
#[doc=concat!("Parser for element [`", stringify!($qname), "`].")]
#[doc=concat!("Parser for element [`", stringify!($qname), "`] ")]
#[doc=concat!("with attributes [`", stringify!([<$nt Attrs>]), "`].")]
#[derive(Debug, PartialEq, Eq, Default)]
$vis struct $nt(crate::xir::parse::NtState<$nt>);