2021-11-27 15:19:56 +00:00
|
|
|
import Lean
|
|
|
|
import DocGen4.Process
|
2021-11-28 20:31:22 +00:00
|
|
|
import Std.Data.HashMap
|
2021-11-27 15:19:56 +00:00
|
|
|
|
|
|
|
namespace DocGen4
|
|
|
|
|
2021-11-28 20:31:22 +00:00
|
|
|
open Lean System Std
|
2021-11-27 15:19:56 +00:00
|
|
|
|
|
|
|
def printSearchPath : IO PUnit := do
|
|
|
|
IO.println s!"{←searchPathRef.get}"
|
|
|
|
|
|
|
|
def setSearchPath (path : List FilePath) : IO PUnit := do
|
|
|
|
searchPathRef.set path
|
|
|
|
|
2021-11-28 20:31:22 +00:00
|
|
|
def load (imports : List Name) : IO (HashMap Name Module) := do
|
2021-11-27 15:19:56 +00:00
|
|
|
let env ← importModules (List.map (Import.mk · false) imports) Options.empty
|
2021-12-01 17:25:11 +00:00
|
|
|
-- TODO parameterize maxHeartbeats
|
|
|
|
let doc ← Prod.fst <$> (Meta.MetaM.toIO (process) { maxHeartbeats := 100000000} { env := env} {} {})
|
2021-11-28 20:31:22 +00:00
|
|
|
for (_, module) in doc.toList do
|
|
|
|
let s ← Core.CoreM.toIO module.prettyPrint {} { env := env }
|
2021-11-27 15:19:56 +00:00
|
|
|
IO.println s.fst
|
2021-12-01 17:25:11 +00:00
|
|
|
IO.println s!"Processed {List.foldl (λ a (_, b) => a + b.members.size) 0 doc.toList} declarations"
|
|
|
|
IO.println s!"Processed {doc.size} modules"
|
2021-11-27 15:19:56 +00:00
|
|
|
return doc
|
|
|
|
|
|
|
|
end DocGen4
|