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
|
2022-10-05 10:05:58 +00:00
|
|
|
|
import Lean.Data.HashMap
|
2021-11-27 15:19:56 +00:00
|
|
|
|
|
|
|
|
|
namespace DocGen4
|
|
|
|
|
|
2022-10-05 10:05:58 +00:00
|
|
|
|
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
|
2022-07-21 16:26:01 +00:00
|
|
|
|
importModules (imports.map (Import.mk · false)) Options.empty
|
|
|
|
|
|
2023-09-18 20:03:27 +00:00
|
|
|
|
def loadInit (imports : Array Name) : IO Hierarchy := do
|
2022-07-21 16:26:01 +00:00
|
|
|
|
let env ← envOfImports imports
|
2022-07-23 11:01:25 +00:00
|
|
|
|
pure <| Hierarchy.fromArray env.header.moduleNames
|
2022-07-21 16:26:01 +00:00
|
|
|
|
|
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.
|
|
|
|
|
-/
|
2022-07-21 16:26:01 +00:00
|
|
|
|
def load (task : Process.AnalyzeTask) : IO (Process.AnalyzerResult × Hierarchy) := do
|
2023-10-09 07:30:16 +00:00
|
|
|
|
initSearchPath (← findSysroot)
|
2022-07-21 16:26:01 +00:00
|
|
|
|
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,
|
|
|
|
|
}
|
2022-07-21 16:26:01 +00:00
|
|
|
|
|
|
|
|
|
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
|