Skip to content

Commit 9b6ee09

Browse files
feat: set up a subproject with a database in it for building docs
1 parent 82c57c8 commit 9b6ee09

9 files changed

Lines changed: 796 additions & 2 deletions

File tree

lake-manifest.json

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{"version": "1.1.0",
22
"packagesDir": ".lake/packages",
33
"packages":
4-
[{"url": "https://github.com/leanprover-community/plausible",
4+
[{"url": "https://github.com/leanprover/doc-gen4",
5+
"type": "git",
6+
"subDir": null,
7+
"scope": "",
8+
"rev": "f178e492e7f345d7be5a57d2178e95f7a3cc070b",
9+
"name": "«doc-gen4»",
10+
"manifestFile": "lake-manifest.json",
11+
"inputRev": "main",
12+
"inherited": false,
13+
"configFile": "lakefile.lean"},
14+
{"url": "https://github.com/leanprover-community/plausible",
515
"type": "git",
616
"subDir": null,
717
"scope": "",
@@ -30,6 +40,46 @@
3040
"manifestFile": "lake-manifest.json",
3141
"inputRev": "main",
3242
"inherited": false,
33-
"configFile": "lakefile.lean"}],
43+
"configFile": "lakefile.lean"},
44+
{"url": "https://github.com/david-christiansen/leansqlite",
45+
"type": "git",
46+
"subDir": null,
47+
"scope": "",
48+
"rev": "739abe6c8ae0602d6ce56461d33f3e49837c9b70",
49+
"name": "leansqlite",
50+
"manifestFile": "lake-manifest.json",
51+
"inputRev": "main",
52+
"inherited": true,
53+
"configFile": "lakefile.lean"},
54+
{"url": "https://github.com/leanprover/lean4-cli",
55+
"type": "git",
56+
"subDir": null,
57+
"scope": "",
58+
"rev": "474983579ecce1ca7d8a63e65c7ae0b1a22db6a3",
59+
"name": "Cli",
60+
"manifestFile": "lake-manifest.json",
61+
"inputRev": "main",
62+
"inherited": true,
63+
"configFile": "lakefile.toml"},
64+
{"url": "https://github.com/fgdorais/lean4-unicode-basic",
65+
"type": "git",
66+
"subDir": null,
67+
"scope": "",
68+
"rev": "9484dd63d30bce157c7f98007a9f26ca4dfb7fb6",
69+
"name": "UnicodeBasic",
70+
"manifestFile": "lake-manifest.json",
71+
"inputRev": "main",
72+
"inherited": true,
73+
"configFile": "lakefile.lean"},
74+
{"url": "https://github.com/dupuisf/BibtexQuery",
75+
"type": "git",
76+
"subDir": null,
77+
"scope": "",
78+
"rev": "29e7df238aa51dba17463e360e68657a8d433f43",
79+
"name": "BibtexQuery",
80+
"manifestFile": "lake-manifest.json",
81+
"inputRev": "master",
82+
"inherited": true,
83+
"configFile": "lakefile.toml"}],
3484
"name": "verso",
3585
"lakeDir": ".lake"}

lakefile.lean

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ open Lake DSL
44
require subverso from git "https://github.com/leanprover/subverso"@"main"
55
require MD4Lean from git "https://github.com/acmepjz/md4lean"@"main"
66
require plausible from git "https://github.com/leanprover-community/plausible"@"main"
7+
require «doc-gen4» from git "https://github.com/leanprover/doc-gen4"@"main"
78

89
package verso where
910
precompileModules := false -- temporarily disabled to work around an issue with nightly-2025-03-30
@@ -197,3 +198,40 @@ package_facet literate pkg : Array System.FilePath := do
197198
let libs := Job.collectArray (← pkg.leanLibs.mapM (·.facet `literate |>.fetch))
198199
let exes := Job.collectArray (← pkg.leanExes.mapM (·.toLeanLib.facet `literate |>.fetch))
199200
return libs.zipWith (·.flatten ++ ·.flatten) exes
201+
202+
lean_exe «verso-docgen-setup» where
203+
root := `VersoManual.DB.Setup
204+
srcDir := "src/verso-manual"
205+
supportInterpreter := true
206+
207+
package_facet docSource pkg : System.FilePath := do
208+
let ws ← getWorkspace
209+
let exeJob ← «verso-docgen-setup».fetch
210+
211+
let pkgDir := ws.root.dir
212+
let buildDir := ws.root.buildDir
213+
let tomlPath := pkgDir / "doc-sources.toml"
214+
let wsDir := buildDir / "verso-doc-db"
215+
let dbPath := wsDir / ".lake" / "build" / "api-docs.db"
216+
217+
let docgen4Dir := match ws.findPackageByName? `«doc-gen4» with
218+
| some pkg => pkg.dir
219+
| none => buildDir / ".." / "packages" / "doc-gen4"
220+
221+
exeJob.mapM fun exeFile => do
222+
-- Add trace for the TOML config file so changes trigger rebuild
223+
if ← tomlPath.pathExists then
224+
addTrace (← fetchFileTrace tomlPath (text := true))
225+
226+
buildFileUnlessUpToDate' dbPath do
227+
let args :=
228+
if ← tomlPath.pathExists then
229+
#[wsDir.toString, docgen4Dir.toString, pkgDir.toString, tomlPath.toString]
230+
else
231+
#[wsDir.toString, docgen4Dir.toString, pkgDir.toString]
232+
proc {
233+
cmd := exeFile.toString
234+
args
235+
}
236+
237+
pure dbPath

src/tests/TestMain.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ def testBlog (_ : Config) : IO Unit := do
153153
if fails > 0 then
154154
throw <| .userError s!"{fails} blog tests failed"
155155

156+
def testDocSourceConfig (_ : Config) : IO Unit := do
157+
let fails ← runDocSourceConfigTests
158+
if fails > 0 then
159+
throw <| .userError s!"{fails} doc source config tests failed"
160+
156161
-- Interactive tests via the LSP server
157162
def testInteractive (_ : Config) : IO Unit := do
158163
IO.println "Running interactive (LSP) tests..."
@@ -167,6 +172,7 @@ open Verso.Integration in
167172
def tests := [
168173
testSerialization,
169174
testBlog,
175+
testDocSourceConfig,
170176
testStemmer,
171177
testTexOutput "sample-doc" SampleDoc.doc,
172178
testTexOutput "inheritance-doc" InheritanceDoc.doc,

src/tests/Tests.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ import Tests.VersoBlog
3131
import Tests.VersoManual
3232
import Tests.Z85
3333
import Tests.Zip
34+
import Tests.DocSourceConfig

0 commit comments

Comments
 (0)