bookshelf-doc/Main.lean

39 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-11-27 15:19:56 +00:00
import DocGen4
import Lean
2022-02-23 21:54:10 +00:00
import Cli
2021-11-27 15:19:56 +00:00
2022-02-23 21:54:10 +00:00
open DocGen4 Lean Cli
2021-11-27 15:19:56 +00:00
2022-02-23 21:54:10 +00:00
def runDocGenCmd (p : Parsed) : IO UInt32 := do
let modules : List String := p.variableArgsAs! String |>.toList
2022-03-06 17:51:06 +00:00
let res ← lakeSetup modules
match res with
| Except.ok (ws, leanHash) =>
IO.println s!"Loading modules from: {←searchPathRef.get}"
let doc ← load $ modules.map Name.mkSimple
IO.println "Outputting HTML"
match p.flag? "ink" with
| some ink =>
let inkPath := System.FilePath.mk ink.value
if ←inkPath.pathExists then
htmlOutput doc ws leanHash inkPath
else
throw $ IO.userError "Invalid path to LeanInk binary provided"
| none => htmlOutput doc ws leanHash none
2022-03-06 17:51:06 +00:00
pure 0
| Except.error rc => pure rc
2022-02-23 21:54:10 +00:00
def docGenCmd : Cmd := `[Cli|
"doc-gen4" VIA runDocGenCmd; ["0.0.1"]
"A documentation generator for Lean 4."
FLAGS:
ink : String; "Path to a LeanInk binary to use for rendering the Lean sources."
2022-02-23 21:54:10 +00:00
ARGS:
...modules : String; "The modules to generate the HTML for"
]
def main (args : List String) : IO UInt32 :=
docGenCmd.validate args