bookshelf-doc/DocGen4/Output.lean

36 lines
1.1 KiB
Plaintext
Raw Normal View History

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
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
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
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
FS.writeFile (basePath / "nav.js") navJs
2021-12-13 12:00:53 +00:00
for (module, content) in result.modules.toArray do
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