parent
b07faa65fe
commit
64f627a295
|
@ -4,6 +4,8 @@ on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 */2 * * *' # every 2 hours
|
- cron: '0 */2 * * *' # every 2 hours
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -12,7 +14,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: install elan
|
- name: install elan
|
||||||
run: |
|
run: |
|
||||||
|
@ -32,6 +34,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
if [ "$github_repo" = "leanprover/doc-gen4" ] && [ "$github_ref" = "refs/heads/main" ]; then
|
if [ "$github_repo" = "leanprover/doc-gen4" ] && [ "$github_ref" = "refs/heads/main" ]; then
|
||||||
deploy="true"
|
deploy="true"
|
||||||
|
DOC_GEN_REF="main"
|
||||||
else
|
else
|
||||||
deploy="false"
|
deploy="false"
|
||||||
fi
|
fi
|
||||||
|
@ -39,5 +42,4 @@ jobs:
|
||||||
./doc-gen4/deploy_docs.sh "mathlib4" "doc-gen4" "$deploy" "LeanInk"
|
./doc-gen4/deploy_docs.sh "mathlib4" "doc-gen4" "$deploy" "LeanInk"
|
||||||
env:
|
env:
|
||||||
MATHLIB4_DOCS_KEY: ${{ secrets.MATHLIB4_DOCS_KEY }}
|
MATHLIB4_DOCS_KEY: ${{ secrets.MATHLIB4_DOCS_KEY }}
|
||||||
github_repo: ${{ github.repository }}
|
DOC_GEN_REF: ${{ github.event.pull_request.head.sha }}
|
||||||
github_ref: ${{ github.ref }}
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ import Lean
|
||||||
import Lake
|
import Lake
|
||||||
import Lake.CLI.Main
|
import Lake.CLI.Main
|
||||||
import DocGen4.Process
|
import DocGen4.Process
|
||||||
import Std.Data.HashMap
|
import Lean.Data.HashMap
|
||||||
|
|
||||||
namespace DocGen4
|
namespace DocGen4
|
||||||
|
|
||||||
open Lean System Std IO
|
open Lean System IO
|
||||||
|
|
||||||
/--
|
/--
|
||||||
Sets up a lake workspace for the current project. Furthermore initialize
|
Sets up a lake workspace for the current project. Furthermore initialize
|
||||||
|
@ -56,6 +56,6 @@ def load (task : Process.AnalyzeTask) : IO (Process.AnalyzerResult × Hierarchy)
|
||||||
Prod.fst <$> Meta.MetaM.toIO (Process.process task) config { env := env } {} {}
|
Prod.fst <$> Meta.MetaM.toIO (Process.process task) config { env := env } {} {}
|
||||||
|
|
||||||
def loadCore : IO (Process.AnalyzerResult × Hierarchy) := do
|
def loadCore : IO (Process.AnalyzerResult × Hierarchy) := do
|
||||||
load <| .loadAll [`Init, `Std, `Lean]
|
load <| .loadAll [`Init, `Lean]
|
||||||
|
|
||||||
end DocGen4
|
end DocGen4
|
||||||
|
|
|
@ -14,11 +14,11 @@ import DocGen4.Output.Find
|
||||||
import DocGen4.Output.SourceLinker
|
import DocGen4.Output.SourceLinker
|
||||||
import DocGen4.Output.ToJson
|
import DocGen4.Output.ToJson
|
||||||
import DocGen4.LeanInk.Process
|
import DocGen4.LeanInk.Process
|
||||||
import Std.Data.HashMap
|
import Lean.Data.HashMap
|
||||||
|
|
||||||
namespace DocGen4
|
namespace DocGen4
|
||||||
|
|
||||||
open Lean IO System Output Process Std
|
open Lean IO System Output Process
|
||||||
|
|
||||||
def htmlOutputSetup (config : SiteBaseContext) : IO Unit := do
|
def htmlOutputSetup (config : SiteBaseContext) : IO Unit := do
|
||||||
let findBasePath := basePath / "find"
|
let findBasePath := basePath / "find"
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Output
|
||||||
-/
|
-/
|
||||||
def splitAround (s : String) (p : Char → Bool) : List String := splitAroundAux s p 0 0 []
|
def splitAround (s : String) (p : Char → Bool) : List String := splitAroundAux s p 0 0 []
|
||||||
|
|
||||||
instance : Inhabited Element := ⟨"", Std.RBMap.empty, #[]⟩
|
instance : Inhabited Element := ⟨"", Lean.RBMap.empty, #[]⟩
|
||||||
|
|
||||||
/-- Parse an array of Xml/Html document from String. -/
|
/-- Parse an array of Xml/Html document from String. -/
|
||||||
def manyDocument : Parsec (Array Element) := many (prolog *> element <* many Misc) <* eof
|
def manyDocument : Parsec (Array Element) := many (prolog *> element <* many Misc) <* eof
|
||||||
|
@ -119,7 +119,7 @@ def addHeadingAttributes (el : Element) (modifyElement : Element → HtmlM Eleme
|
||||||
match el with
|
match el with
|
||||||
| Element.Element name attrs contents => do
|
| Element.Element name attrs contents => do
|
||||||
let id := xmlGetHeadingId el
|
let id := xmlGetHeadingId el
|
||||||
let anchorAttributes := Std.RBMap.empty
|
let anchorAttributes := Lean.RBMap.empty
|
||||||
|>.insert "class" "hover-link"
|
|>.insert "class" "hover-link"
|
||||||
|>.insert "href" s!"#{id}"
|
|>.insert "href" s!"#{id}"
|
||||||
let anchor := Element.Element "a" anchorAttributes #[Content.Character "#"]
|
let anchor := Element.Element "a" anchorAttributes #[Content.Character "#"]
|
||||||
|
@ -159,7 +159,7 @@ def autoLink (el : Element) : HtmlM Element := do
|
||||||
let link? ← nameToLink? s
|
let link? ← nameToLink? s
|
||||||
match link? with
|
match link? with
|
||||||
| some link =>
|
| some link =>
|
||||||
let attributes := Std.RBMap.empty.insert "href" link
|
let attributes := Lean.RBMap.empty.insert "href" link
|
||||||
pure [Content.Element <| Element.Element "a" attributes #[Content.Character s]]
|
pure [Content.Element <| Element.Element "a" attributes #[Content.Character s]]
|
||||||
| none =>
|
| none =>
|
||||||
let sHead := s.dropRightWhile (λ c => c ≠ '.')
|
let sHead := s.dropRightWhile (λ c => c ≠ '.')
|
||||||
|
@ -167,7 +167,7 @@ def autoLink (el : Element) : HtmlM Element := do
|
||||||
let link'? ← nameToLink? sTail
|
let link'? ← nameToLink? sTail
|
||||||
match link'? with
|
match link'? with
|
||||||
| some link' =>
|
| some link' =>
|
||||||
let attributes := Std.RBMap.empty.insert "href" link'
|
let attributes := Lean.RBMap.empty.insert "href" link'
|
||||||
pure [
|
pure [
|
||||||
Content.Character sHead,
|
Content.Character sHead,
|
||||||
Content.Element <| Element.Element "a" attributes #[Content.Character sTail]
|
Content.Element <| Element.Element "a" attributes #[Content.Character sTail]
|
||||||
|
|
|
@ -57,7 +57,7 @@ declarations into (optionally positional) Github URLs.
|
||||||
def sourceLinker (ws : Lake.Workspace) : IO (Name → Option DeclarationRange → String) := do
|
def sourceLinker (ws : Lake.Workspace) : IO (Name → Option DeclarationRange → String) := do
|
||||||
let leanHash := ws.lakeEnv.lean.githash
|
let leanHash := ws.lakeEnv.lean.githash
|
||||||
-- Compute a map from package names to source URL
|
-- Compute a map from package names to source URL
|
||||||
let mut gitMap := Std.mkHashMap
|
let mut gitMap := Lean.mkHashMap
|
||||||
let projectBaseUrl := getGithubBaseUrl (←getProjectGithubUrl)
|
let projectBaseUrl := getGithubBaseUrl (←getProjectGithubUrl)
|
||||||
let projectCommit ← getProjectCommit
|
let projectCommit ← getProjectCommit
|
||||||
gitMap := gitMap.insert ws.root.name (projectBaseUrl, projectCommit)
|
gitMap := gitMap.insert ws.root.name (projectBaseUrl, projectCommit)
|
||||||
|
@ -72,7 +72,7 @@ def sourceLinker (ws : Lake.Workspace) : IO (Name → Option DeclarationRange
|
||||||
let parts := module.components.map Name.toString
|
let parts := module.components.map Name.toString
|
||||||
let path := (parts.intersperse "/").foldl (· ++ ·) ""
|
let path := (parts.intersperse "/").foldl (· ++ ·) ""
|
||||||
let root := module.getRoot
|
let root := module.getRoot
|
||||||
let basic := if root == `Lean ∨ root == `Init ∨ root == `Std then
|
let basic := if root == `Lean ∨ root == `Init then
|
||||||
s!"https://github.com/leanprover/lean4/blob/{leanHash}/src/{path}.lean"
|
s!"https://github.com/leanprover/lean4/blob/{leanHash}/src/{path}.lean"
|
||||||
else
|
else
|
||||||
match ws.packageArray.find? (·.isLocalModule module) with
|
match ws.packageArray.find? (·.isLocalModule module) with
|
||||||
|
|
|
@ -121,7 +121,7 @@ private def htmlHelper (n : Syntax) (children : Array Syntax) (m : Syntax) : Mac
|
||||||
let mut cs ← `(#[])
|
let mut cs ← `(#[])
|
||||||
for child in children do
|
for child in children do
|
||||||
cs ← match child with
|
cs ← match child with
|
||||||
| `(jsxChild|$t:jsxText) => `(($cs).push (Html.text $(quote t.raw[0].getAtomVal!)))
|
| `(jsxChild|$t:jsxText) => `(($cs).push (Html.text $(quote t.raw[0]!.getAtomVal)))
|
||||||
-- TODO(WN): elab as list of children if type is `t Html` where `Foldable t`
|
-- TODO(WN): elab as list of children if type is `t Html` where `Foldable t`
|
||||||
| `(jsxChild|{$t}) => `(($cs).push ($t : Html))
|
| `(jsxChild|{$t}) => `(($cs).push ($t : Html))
|
||||||
| `(jsxChild|[$t]) => `($cs ++ ($t : Array Html))
|
| `(jsxChild|[$t]) => `($cs ++ ($t : Array Html))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import Lean
|
import Lean
|
||||||
import DocGen4.Process
|
import DocGen4.Process
|
||||||
import DocGen4.Output.Base
|
import DocGen4.Output.Base
|
||||||
import Std.Data.RBMap
|
import Lean.Data.RBMap
|
||||||
|
|
||||||
namespace DocGen4.Output
|
namespace DocGen4.Output
|
||||||
|
|
||||||
open Lean Std
|
open Lean
|
||||||
|
|
||||||
structure JsonDeclaration where
|
structure JsonDeclaration where
|
||||||
name : String
|
name : String
|
||||||
|
|
|
@ -5,8 +5,8 @@ Authors: Henrik Böving
|
||||||
-/
|
-/
|
||||||
|
|
||||||
import Lean
|
import Lean
|
||||||
import Std.Data.HashMap
|
import Lean.Data.HashMap
|
||||||
import Std.Data.HashSet
|
import Lean.Data.HashSet
|
||||||
|
|
||||||
import DocGen4.Process.Base
|
import DocGen4.Process.Base
|
||||||
import DocGen4.Process.Hierarchy
|
import DocGen4.Process.Hierarchy
|
||||||
|
@ -14,7 +14,7 @@ import DocGen4.Process.DocInfo
|
||||||
|
|
||||||
namespace DocGen4.Process
|
namespace DocGen4.Process
|
||||||
|
|
||||||
open Lean Meta Std
|
open Lean Meta
|
||||||
|
|
||||||
/--
|
/--
|
||||||
Member of a module, either a declaration or some module doc string.
|
Member of a module, either a declaration or some module doc string.
|
||||||
|
|
|
@ -77,7 +77,7 @@ instance : ToString SpecializeAttributeKind where
|
||||||
/--
|
/--
|
||||||
The list of all enum based attributes doc-gen knows about and can recover.
|
The list of all enum based attributes doc-gen knows about and can recover.
|
||||||
-/
|
-/
|
||||||
def enumAttributes : Array EnumAttrWrapper := #[⟨Compiler.inlineAttrs⟩, ⟨Compiler.specializeAttrs⟩]
|
def enumAttributes : Array EnumAttrWrapper := #[⟨Compiler.inlineAttrs⟩]
|
||||||
|
|
||||||
instance : ToString ExternEntry where
|
instance : ToString ExternEntry where
|
||||||
toString entry :=
|
toString entry :=
|
||||||
|
@ -97,7 +97,7 @@ instance : ToString ExternAttrData where
|
||||||
The list of all parametric attributes (that is, attributes with any kind of information attached)
|
The list of all parametric attributes (that is, attributes with any kind of information attached)
|
||||||
doc-gen knows about and can recover.
|
doc-gen knows about and can recover.
|
||||||
-/
|
-/
|
||||||
def parametricAttributes : Array ParametricAttrWrapper := #[⟨externAttr⟩, ⟨Compiler.implementedByAttr⟩, ⟨exportAttr⟩]
|
def parametricAttributes : Array ParametricAttrWrapper := #[⟨externAttr⟩, ⟨Compiler.implementedByAttr⟩, ⟨exportAttr⟩, ⟨Compiler.specializeAttr⟩]
|
||||||
|
|
||||||
def getTags (decl : Name) : MetaM (Array String) := do
|
def getTags (decl : Name) : MetaM (Array String) := do
|
||||||
let env ← getEnv
|
let env ← getEnv
|
||||||
|
@ -127,7 +127,7 @@ def getDefaultInstance (decl : Name) (className : Name) : MetaM (Option String)
|
||||||
def hasSimp (decl : Name) : MetaM (Option String) := do
|
def hasSimp (decl : Name) : MetaM (Option String) := do
|
||||||
let thms ← simpExtension.getTheorems
|
let thms ← simpExtension.getTheorems
|
||||||
pure <|
|
pure <|
|
||||||
if thms.isLemma decl then
|
if thms.isLemma (.decl decl) then
|
||||||
some "simp"
|
some "simp"
|
||||||
else
|
else
|
||||||
none
|
none
|
||||||
|
|
|
@ -4,11 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
Authors: Henrik Böving
|
Authors: Henrik Böving
|
||||||
-/
|
-/
|
||||||
import Lean
|
import Lean
|
||||||
import Std.Data.HashMap
|
import Lean.Data.HashMap
|
||||||
|
|
||||||
open Std
|
def Lean.HashSet.fromArray [BEq α] [Hashable α] (xs : Array α) : Lean.HashSet α :=
|
||||||
|
|
||||||
def HashSet.fromArray [BEq α] [Hashable α] (xs : Array α) : HashSet α :=
|
|
||||||
xs.foldr (flip .insert) .empty
|
xs.foldr (flip .insert) .empty
|
||||||
|
|
||||||
namespace DocGen4
|
namespace DocGen4
|
||||||
|
|
|
@ -64,7 +64,7 @@ def indexCmd := `[Cli|
|
||||||
|
|
||||||
def genCoreCmd := `[Cli|
|
def genCoreCmd := `[Cli|
|
||||||
genCore VIA runGenCoreCmd;
|
genCore VIA runGenCoreCmd;
|
||||||
"Generate documentation for the core Lean modules: Init, Std and Lean since they are not Lake projects"
|
"Generate documentation for the core Lean modules: Init and Lean since they are not Lake projects"
|
||||||
]
|
]
|
||||||
|
|
||||||
def docGenCmd : Cmd := `[Cli|
|
def docGenCmd : Cmd := `[Cli|
|
||||||
|
|
|
@ -10,21 +10,23 @@ cd $1
|
||||||
mathlib_short_git_hash="$(git log -1 --pretty=format:%h)"
|
mathlib_short_git_hash="$(git log -1 --pretty=format:%h)"
|
||||||
|
|
||||||
cd ../$2
|
cd ../$2
|
||||||
docgen_git_hash="$(git log -1 --pretty=format:%h)"
|
DOC_GEN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
|
||||||
|
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
git clone "https://github.com/leanprover-community/mathlib4_docs.git" mathlib4_docs
|
git clone "https://github.com/leanprover-community/mathlib4_docs.git" mathlib4_docs
|
||||||
|
|
||||||
# skip if docs for this commit have already been generated
|
# skip if docs for this commit have already been generated
|
||||||
if [ "$(cd mathlib4_docs && git log -1 --pretty=format:%s)" == "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $docgen_git_hash" ]; then
|
if [ "$(cd mathlib4_docs && git log -1 --pretty=format:%s)" == "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# generate the docs
|
# generate the docs
|
||||||
cd $1
|
cd $1
|
||||||
sed -i "s/git \"https:\/\/github.com\/leanprover\/doc-gen4\" @ \"main\"/\"..\" \/ \"$2\" with NameMap.empty/" lakefile.lean
|
sed -i "s|\"https://github.com/leanprover/doc-gen4\" @ \"main\"|\"$DOC_GEN_URL\" @ \"$DOC_GEN_REF\"|" lakefile.lean
|
||||||
lake -Kdoc=on build Mathlib:docs --verbose
|
rm -rf lean_packages/manifest.json
|
||||||
|
lake -Kdoc=on update
|
||||||
|
lake -Kdoc=on build Mathlib:docs Std:docs --verbose
|
||||||
|
|
||||||
if [ "$3" = "true" ]; then
|
if [ "$3" = "true" ]; then
|
||||||
cd ..
|
cd ..
|
||||||
|
@ -39,6 +41,6 @@ if [ "$3" = "true" ]; then
|
||||||
git config user.name "leanprover-community-bot"
|
git config user.name "leanprover-community-bot"
|
||||||
git add -A .
|
git add -A .
|
||||||
git checkout --orphan master2
|
git checkout --orphan master2
|
||||||
git commit -m "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $docgen_git_hash"
|
git commit -m "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF"
|
||||||
git push -f origin HEAD:master
|
git push -f origin HEAD:master
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -54,7 +54,7 @@ target coreDocs : FilePath := do
|
||||||
let dataFile := basePath / "declarations" / "declaration-data-Lean.bmp"
|
let dataFile := basePath / "declarations" / "declaration-data-Lean.bmp"
|
||||||
exeJob.bindSync fun exeFile exeTrace => do
|
exeJob.bindSync fun exeFile exeTrace => do
|
||||||
let trace ← buildFileUnlessUpToDate dataFile exeTrace do
|
let trace ← buildFileUnlessUpToDate dataFile exeTrace do
|
||||||
logInfo "Documenting Lean core: Init, Std, Lean"
|
logInfo "Documenting Lean core: Init and Lean"
|
||||||
proc {
|
proc {
|
||||||
cmd := exeFile.toString
|
cmd := exeFile.toString
|
||||||
args := #["genCore"]
|
args := #["genCore"]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
leanprover/lean4:nightly-2022-08-18
|
leanprover/lean4:nightly-2022-10-03
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
{"version": 2,
|
{"version": 2,
|
||||||
"packages":
|
"packages":
|
||||||
[{"url": "https://github.com/mhuisi/lean4-cli",
|
[{"url": "https://github.com/mhuisi/lean4-cli",
|
||||||
"rev": "112b35fc348a4a18d2111ac2c6586163330b4941",
|
"rev": "80b783a8905a4e8a29ced841abb64f710bc86f06",
|
||||||
"name": "Cli"},
|
"name": "Cli",
|
||||||
|
"inputRev": "nightly"},
|
||||||
{"url": "https://github.com/hargonix/LeanInk",
|
{"url": "https://github.com/hargonix/LeanInk",
|
||||||
"rev": "439303af06465824588a486f5f9c023ca69979f3",
|
"rev": "439303af06465824588a486f5f9c023ca69979f3",
|
||||||
"name": "leanInk"},
|
"name": "leanInk",
|
||||||
|
"inputRev": "doc-gen"},
|
||||||
{"url": "https://github.com/xubaiw/Unicode.lean",
|
{"url": "https://github.com/xubaiw/Unicode.lean",
|
||||||
"rev": "25b32ef69fd6d8ae34300d51dc0b9403ffb1fd29",
|
"rev": "3a74ad4a69a3720ad8bd5f50a3233fe393f3f38e",
|
||||||
"name": "Unicode"},
|
"name": "Unicode",
|
||||||
{"url": "https://github.com/leanprover-community/mathlib4.git",
|
"inputRev": "main"},
|
||||||
"rev": "ecd37441047e490ff2ad339e16f45bb8b58591bd",
|
|
||||||
"name": "mathlib"},
|
|
||||||
{"url": "https://github.com/leanprover/lake",
|
{"url": "https://github.com/leanprover/lake",
|
||||||
"rev": "6cfb4e3fd7ff700ace8c2cfdb85056d59f321920",
|
"rev": "2cc00e4e08473939842d823fd753dcac891ab709",
|
||||||
"name": "lake"},
|
"name": "lake",
|
||||||
|
"inputRev": "master"},
|
||||||
{"url": "https://github.com/xubaiw/CMark.lean",
|
{"url": "https://github.com/xubaiw/CMark.lean",
|
||||||
"rev": "8c0f9c1b16ee8047813f43b1f92de471782114ff",
|
"rev": "8c0f9c1b16ee8047813f43b1f92de471782114ff",
|
||||||
"name": "CMark"}]}
|
"name": "CMark",
|
||||||
|
"inputRev": "main"}]}
|
||||||
|
|
Loading…
Reference in New Issue