bookshelf-doc/DocGen4/Load.lean

44 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-12-10 12:29:04 +00:00
/-
Copyright (c) 2021 Henrik Böving. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving
-/
2021-11-27 15:19:56 +00:00
import Lean
import DocGen4.Process
import Lean.Data.HashMap
2021-11-27 15:19:56 +00:00
namespace DocGen4
open Lean System IO
2021-11-27 15:19:56 +00:00
2023-09-18 20:03:27 +00:00
def envOfImports (imports : Array Name) : IO Environment := do
importModules (imports.map (Import.mk · false)) Options.empty
2023-09-18 20:03:27 +00:00
def loadInit (imports : Array Name) : IO Hierarchy := do
let env ← envOfImports imports
2022-07-23 11:01:25 +00:00
pure <| Hierarchy.fromArray env.header.moduleNames
2022-05-19 18:45:12 +00:00
/--
Load a list of modules from the current Lean search path into an `Environment`
to process for documentation.
-/
def load (task : Process.AnalyzeTask) : IO (Process.AnalyzerResult × Hierarchy) := do
initSearchPath (← findSysroot)
let env ← envOfImports task.getLoad
2022-06-19 14:41:59 +00:00
let config := {
-- TODO: parameterize maxHeartbeats
maxHeartbeats := 100000000,
options := ⟨[(`pp.tagAppFns, true)]⟩,
-- TODO: Figure out whether this could cause some bugs
fileName := default,
fileMap := default,
}
Prod.fst <$> Meta.MetaM.toIO (Process.process task) config { env := env } {} {}
2021-11-27 15:19:56 +00:00
2022-08-11 19:37:10 +00:00
def loadCore : IO (Process.AnalyzerResult × Hierarchy) := do
2023-09-18 20:03:27 +00:00
load <| .loadAll #[`Init, `Lean, `Lake]
2022-08-11 19:37:10 +00:00
2021-11-27 15:19:56 +00:00
end DocGen4