2022-02-02 10:22:15 +00:00
|
|
|
import DocGen4.Output.Template
|
2022-02-17 05:47:38 +00:00
|
|
|
import DocGen4.Output.DocString
|
2022-05-19 22:36:43 +00:00
|
|
|
import DocGen4.Process
|
2022-02-02 10:22:15 +00:00
|
|
|
|
|
|
|
namespace DocGen4
|
|
|
|
namespace Output
|
|
|
|
|
|
|
|
open scoped DocGen4.Jsx
|
|
|
|
open Lean Widget
|
|
|
|
|
2022-05-19 19:07:44 +00:00
|
|
|
/-- This is basically an arbitrary number that seems to work okay. -/
|
2022-02-20 12:45:18 +00:00
|
|
|
def equationLimit : Nat := 200
|
|
|
|
|
2022-02-02 10:22:15 +00:00
|
|
|
def equationToHtml (c : CodeWithInfos) : HtmlM Html := do
|
2023-01-01 18:51:01 +00:00
|
|
|
return <li class="equation">[← infoFormatToHtml c]</li>
|
2022-02-02 10:22:15 +00:00
|
|
|
|
2022-05-19 19:07:44 +00:00
|
|
|
/--
|
|
|
|
Attempt to render all `simp` equations for this definition. At a size
|
|
|
|
defined in `equationLimit` we stop trying since they:
|
|
|
|
- are too ugly to read most of the time
|
|
|
|
- take too long
|
|
|
|
-/
|
2022-05-19 22:36:43 +00:00
|
|
|
def equationsToHtml (i : Process.DefinitionInfo) : HtmlM (Array Html) := do
|
2022-02-12 14:09:13 +00:00
|
|
|
if let some eqs := i.equations then
|
2022-02-02 10:22:15 +00:00
|
|
|
let equationsHtml ← eqs.mapM equationToHtml
|
2023-01-01 18:51:01 +00:00
|
|
|
let filteredEquationsHtml := equationsHtml.filter (·.textLength < equationLimit)
|
2022-02-20 12:45:18 +00:00
|
|
|
if equationsHtml.size ≠ filteredEquationsHtml.size then
|
2023-01-01 18:51:01 +00:00
|
|
|
return #[
|
2022-02-20 12:45:18 +00:00
|
|
|
<details>
|
|
|
|
<summary>Equations</summary>
|
2022-05-19 09:14:47 +00:00
|
|
|
<ul class="equations">
|
|
|
|
<li class="equation">One or more equations did not get rendered due to their size.</li>
|
2022-02-20 12:45:18 +00:00
|
|
|
[filteredEquationsHtml]
|
|
|
|
</ul>
|
|
|
|
</details>
|
|
|
|
]
|
|
|
|
else
|
2023-01-01 18:51:01 +00:00
|
|
|
return #[
|
2022-02-20 12:45:18 +00:00
|
|
|
<details>
|
|
|
|
<summary>Equations</summary>
|
2022-05-19 09:14:47 +00:00
|
|
|
<ul class="equations">
|
2022-02-20 12:45:18 +00:00
|
|
|
[filteredEquationsHtml]
|
|
|
|
</ul>
|
|
|
|
</details>
|
|
|
|
]
|
2022-02-02 10:22:15 +00:00
|
|
|
else
|
2023-01-01 18:51:01 +00:00
|
|
|
return #[]
|
2022-02-02 10:22:15 +00:00
|
|
|
|
|
|
|
end Output
|
|
|
|
end DocGen4
|
|
|
|
|