bookshelf/lakefile.lean

58 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-04-22 20:20:37 +00:00
import Lake
2023-04-22 20:20:37 +00:00
open Lake DSL
package «bookshelf»
require mathlib from git
"https://github.com/leanprover-community/mathlib4.git" @
"d65ed3b2920dbfb0b2bf1aca2189ec177eb68980"
2023-05-02 15:14:50 +00:00
require std4 from git
"https://github.com/leanprover/std4.git" @
"6006307d2ceb8743fea7e00ba0036af8654d0347"
require «doc-gen4» from git
"https://github.com/jrpotter/bookshelf-docgen.git" @
"699f606df8f38c8abb287277df9e79669587c2b9"
2023-04-22 20:20:37 +00:00
@[default_target]
lean_lib «Bookshelf» {
2023-05-08 19:43:54 +00:00
roots := #[`Bookshelf, `Common]
2023-04-22 20:20:37 +00:00
}
/--
The contents of our `.env` file.
-/
structure Config where
port : Nat := 5555
/--
Read in the `.env` file into an in-memory structure.
-/
private def readConfig : StateT Config ScriptM Unit := do
let env <- IO.FS.readFile ".env"
for line in env.trim.split (fun c => c == '\n') do
match line.split (fun c => c == '=') with
| ["PORT", port] => modify (fun c => { c with port := String.toNat! port })
| _ => error "Malformed `.env` file."
return ()
/--
Start an HTTP server for locally serving documentation. It is expected the
documentation has already been generated prior via
```bash
> lake build Bookshelf:docs
```
USAGE:
lake run server
-/
script server (_args) do
let ((), config) <- StateT.run readConfig {}
IO.println s!"Running Lean on `http://localhost:{config.port}`"
_ <- IO.Process.run {
cmd := "python3",
args := #["-m", "http.server", toString config.port, "-d", "build/doc"],
}
return 0