diff --git a/DocGen4/Process/Attributes.lean b/DocGen4/Process/Attributes.lean index 4eccced..14d3336 100644 --- a/DocGen4/Process/Attributes.lean +++ b/DocGen4/Process/Attributes.lean @@ -62,34 +62,42 @@ open Compiler in instance : ToString InlineAttributeKind where toString kind := match kind with - | InlineAttributeKind.inline => "inline" - | InlineAttributeKind.noinline => "noinline" - | InlineAttributeKind.macroInline => "macro_inline" - | InlineAttributeKind.inlineIfReduce => "inline_if_reduce" - | InlineAttributeKind.alwaysInline => "always_inline" + | .inline => "inline" + | .noinline => "noinline" + | .macroInline => "macro_inline" + | .inlineIfReduce => "inline_if_reduce" + | .alwaysInline => "always_inline" open Compiler in instance : ToString SpecializeAttributeKind where toString kind := match kind with - | SpecializeAttributeKind.specialize => "specialize" - | SpecializeAttributeKind.nospecialize => "nospecialize" + | .specialize => "specialize" + | .nospecialize => "nospecialize" + +instance : ToString ReducibilityStatus where + toString kind := + match kind with + | .reducible => "reducible" + | .semireducible => "semireducible" + | .irreducible => "irreducible" /-- The list of all enum based attributes doc-gen knows about and can recover. -/ -def enumAttributes : Array EnumAttrWrapper := #[⟨Compiler.inlineAttrs⟩] +@[reducible] +def enumAttributes : Array EnumAttrWrapper := #[⟨Compiler.inlineAttrs⟩, ⟨reducibilityAttrs⟩] instance : ToString ExternEntry where toString entry := match entry with - | ExternEntry.adhoc `all => "" - | ExternEntry.adhoc backend => s!"{backend} adhoc" - | ExternEntry.standard `all fn => fn - | ExternEntry.standard backend fn => s!"{backend} {fn}" - | ExternEntry.inline backend pattern => s!"{backend} inline {String.quote pattern}" + | .adhoc `all => "" + | .adhoc backend => s!"{backend} adhoc" + | .standard `all fn => fn + | .standard backend fn => s!"{backend} {fn}" + | .inline backend pattern => s!"{backend} inline {String.quote pattern}" -- TODO: The docs in the module dont specific how to render this - | ExternEntry.foreign backend fn => s!"{backend} foreign {fn}" + | .foreign backend fn => s!"{backend} foreign {fn}" instance : ToString ExternAttrData where toString data := (data.arity?.map toString |>.getD "") ++ " " ++ String.intercalate " " (data.entries.map toString) diff --git a/DocGen4/Process/DocInfo.lean b/DocGen4/Process/DocInfo.lean index 8985ab8..e736c16 100644 --- a/DocGen4/Process/DocInfo.lean +++ b/DocGen4/Process/DocInfo.lean @@ -190,17 +190,19 @@ def getKindDescription : DocInfo → String | DefinitionSafety.unsafe => "unsafe opaque" | DefinitionSafety.partial => "partial def" | definitionInfo i => Id.run do - if i.hints.isAbbrev then - return "abbrev" - else - let mut modifiers := #[] - if i.isUnsafe then - modifiers := modifiers.push "unsafe" - if i.isNonComputable then - modifiers := modifiers.push "noncomputable" + let mut modifiers := #[] + if i.isUnsafe then + modifiers := modifiers.push "unsafe" + if i.isNonComputable then + modifiers := modifiers.push "noncomputable" - modifiers := modifiers.push "def" - return String.intercalate " " modifiers.toList + let defKind := + if i.hints.isAbbrev then + "abbrev" + else + "def" + modifiers := modifiers.push defKind + return String.intercalate " " modifiers.toList | instanceInfo i => Id.run do let mut modifiers := #[] if i.isUnsafe then