2021-12-12 12:21:53 +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
|
|
|
|
-/
|
|
|
|
import Lean
|
|
|
|
import DocGen4.Process
|
2021-12-15 08:24:49 +00:00
|
|
|
import DocGen4.Output.Base
|
|
|
|
import DocGen4.Output.Index
|
|
|
|
import DocGen4.Output.Module
|
|
|
|
import DocGen4.Output.NotFound
|
2021-12-12 12:21:53 +00:00
|
|
|
|
|
|
|
namespace DocGen4
|
|
|
|
|
2021-12-15 08:24:49 +00:00
|
|
|
open Lean Std IO System Output
|
2021-12-13 12:00:53 +00:00
|
|
|
|
2021-12-12 12:21:53 +00:00
|
|
|
def htmlOutput (result : AnalyzerResult) : IO Unit := do
|
|
|
|
-- TODO: parameterize this
|
2021-12-13 20:27:08 +00:00
|
|
|
let config := { root := "/", result := result, currentName := none}
|
2021-12-12 12:21:53 +00:00
|
|
|
let basePath := FilePath.mk "./build/doc/"
|
|
|
|
let indexHtml := ReaderT.run index config
|
2021-12-13 12:00:53 +00:00
|
|
|
let notFoundHtml := ReaderT.run notFound config
|
2021-12-12 12:21:53 +00:00
|
|
|
FS.createDirAll basePath
|
|
|
|
FS.writeFile (basePath / "index.html") indexHtml.toString
|
|
|
|
FS.writeFile (basePath / "style.css") styleCss
|
2021-12-13 12:00:53 +00:00
|
|
|
FS.writeFile (basePath / "404.html") notFoundHtml.toString
|
2021-12-13 20:36:21 +00:00
|
|
|
FS.writeFile (basePath / "nav.js") navJs
|
2021-12-17 16:20:44 +00:00
|
|
|
for (module, content) in result.moduleInfo.toArray do
|
2021-12-13 12:00:53 +00:00
|
|
|
let moduleHtml := ReaderT.run (moduleToHtml content) config
|
2021-12-15 10:59:13 +00:00
|
|
|
let path := moduleNameToFile basePath module
|
|
|
|
FS.createDirAll $ moduleNameToDirectory basePath module
|
2021-12-13 12:00:53 +00:00
|
|
|
FS.writeFile path moduleHtml.toString
|
2021-12-12 12:21:53 +00:00
|
|
|
|
|
|
|
end DocGen4
|
|
|
|
|