feat: parameterize the URL root for links in the HTML

main
Henrik Böving 2022-01-07 10:56:39 +01:00
parent 49fdb6279d
commit 82f63cb613
4 changed files with 9 additions and 8 deletions

View File

@ -14,9 +14,8 @@ namespace DocGen4
open Lean Std IO System Output open Lean Std IO System Output
def htmlOutput (result : AnalyzerResult) : IO Unit := do def htmlOutput (result : AnalyzerResult) (root : String) : IO Unit := do
-- TODO: parameterize this let config := { root := root, result := result, currentName := none}
let config := { root := "/", result := result, currentName := none}
let basePath := FilePath.mk "./build/doc/" let basePath := FilePath.mk "./build/doc/"
let indexHtml := ReaderT.run index config let indexHtml := ReaderT.run index config
let notFoundHtml := ReaderT.run notFound config let notFoundHtml := ReaderT.run notFound config

View File

@ -4,9 +4,10 @@ import Lean
open DocGen4 Lean IO open DocGen4 Lean IO
def main (args : List String) : IO Unit := do def main (args : List String) : IO Unit := do
let modules := args let root := args.head!
let modules := args.tail!
let path ← lakeSetupSearchPath (←getLakePath) modules.toArray let path ← lakeSetupSearchPath (←getLakePath) modules.toArray
IO.println s!"Loading modules from: {path}" IO.println s!"Loading modules from: {path}"
let doc ← load $ modules.map Name.mkSimple let doc ← load $ modules.map Name.mkSimple
IO.println "Outputting HTML" IO.println "Outputting HTML"
htmlOutput doc htmlOutput doc root

View File

@ -4,9 +4,10 @@ Document Generator for Lean 4
## Usage ## Usage
You can call `doc-gen4` from the top of a Lake project like this: You can call `doc-gen4` from the top of a Lake project like this:
```sh ```sh
$ /path/to/doc-gen4 Module $ /path/to/doc-gen4 / Module
``` ```
Where `Module` is one or more of the top level modules you want to document. Where the `/` is the root URL the HTML will refer to and `Module` is one or
more of the top level modules you want to document.
The tool will then proceed to compile the project using lake (if that hasn't happened yet), The tool will then proceed to compile the project using lake (if that hasn't happened yet),
analyze it and put the result in `./build/doc`. analyze it and put the result in `./build/doc`.
You could e.g. host the files locally with the built-in Python webserver: You could e.g. host the files locally with the built-in Python webserver:

View File

@ -23,7 +23,7 @@ fi
# generate the docs # generate the docs
cd $1 cd $1
../$2/build/bin/doc-gen4 Mathlib ../$2/build/bin/doc-gen4 /mathlib4_docs/ Mathlib
if [ "$3" = "true" ]; then if [ "$3" = "true" ]; then
cd .. cd ..