From 49b2f019b7fa932aa7205bc0fbc8ebf0437e6893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20B=C3=B6ving?= Date: Mon, 20 Jun 2022 19:21:50 +0200 Subject: [PATCH] feat: type hovers --- DocGen4/LeanInk/Output.lean | 55 +++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/DocGen4/LeanInk/Output.lean b/DocGen4/LeanInk/Output.lean index 91db9b6..04c8c7a 100644 --- a/DocGen4/LeanInk/Output.lean +++ b/DocGen4/LeanInk/Output.lean @@ -25,15 +25,50 @@ def getNextButtonLabel : AlectryonM String := do set { val with counter := newCounter } pure s!"plain-lean4-lean-chk{val.counter}" -def TypeInfo.toHtml : TypeInfo → AlectryonM Html := sorry +def TypeInfo.toHtml (tyi : TypeInfo) : AlectryonM Html := do + pure +
+ +
+
+
+ + {tyi.name} + : + {tyi.type} + + + + + + def Token.toHtml (t : Token) : AlectryonM Html := do - -- TODO: Show rest of token - pure $ Html.text t.raw + -- Right now t.link is always none from LeanInk, ignore it + -- TODO: render docstring + let mut parts := #[] + if let some tyi := t.typeinfo then + parts := parts.push $ ←tyi.toHtml -def Contents.toHtml : Contents → AlectryonM (Array Html) - | .string value => pure #[Html.text value] - | .experimentalTokens values => values.mapM Token.toHtml + parts := parts.push $ Html.text t.raw + pure + -- TODO: Show rest of token + + [parts] + + +def Contents.toHtml : Contents → AlectryonM Html + | .string value => + pure + + {value} + + | .experimentalTokens values => do + let values ← values.mapM Token.toHtml + pure + + [values] + def Hypothesis.toHtml (h : Hypothesis) : AlectryonM Html := do let mut hypParts := #[[h.names.intersperse ", " |>.map Html.text |>.toArray]] @@ -108,7 +143,7 @@ def Sentence.toHtml (s : Sentence) : AlectryonM Html := do