You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Removed the parseNatWithUnderscores function and its doc comments with issue references
- Simplified getMaxHeartbeats to use flag.as! Nat directly for the CLI flag and s.toNat? for the environment variable
- Changed the max-heartbeats flag type from String to Nat in both singleCmd and genCoreCmd
- Removed the "Supports underscores as separators" mention from flag descriptions
In README.md:
- Removed the "Underscores can be used as separators for readability" sentence (the examples still show underscores since they will work in a version of Lean4 that includes this merged PR: leanprover/lean4#11541
Copy file name to clipboardExpand all lines: Main.lean
+4-17Lines changed: 4 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -6,21 +6,13 @@ open DocGen4 Lean Cli
6
6
7
7
defdefaultMaxHeartbeats : Nat := 100_000_000
8
8
9
-
/-- Parse a natural number, allowing underscores as separators (e.g., "100_000_000").
10
-
11
-
See discussion: https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/String.2EtoNat.3F.20and.20String.2EtoInt.3F.20handling.20underscores/with/562357458
12
-
See this related issue: https://github.com/leanprover/lean4/issues/11538
13
-
-/
14
-
defparseNatWithUnderscores (s : String) : Option Nat :=
15
-
(s.replace "_""").toNat?
16
-
17
9
/-- Get maxHeartbeats from CLI flag, falling back to environment variable, then default. -/
18
10
defgetMaxHeartbeats (p : Parsed) : IO Nat := do
19
11
match p.flag? "max-heartbeats"with
20
-
| some flag => pure <| (parseNatWithUnderscores (flag.as! String)).getD defaultMaxHeartbeats
12
+
| some flag => pure <| flag.as! Nat
21
13
| none => do
22
14
match ← IO.getEnv "DOCGEN_MAX_HEARTBEATS"with
23
-
| some s => pure <| (parseNatWithUnderscores s).getD defaultMaxHeartbeats
15
+
| some s => pure <| s.toNat?.getD defaultMaxHeartbeats
24
16
| none => pure defaultMaxHeartbeats
25
17
26
18
defgetTopLevelModules (p : Parsed) : IO (List String) := do
| _ => throw <| IO.userError "there should be exactly one source file"
96
88
return0
97
89
98
-
/--
99
-
See discussion: https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/String.2EtoNat.3F.20and.20String.2EtoInt.3F.20handling.20underscores/with/562357458
100
-
If https://github.com/leanprover/lean4/issues/11538 is resolved, change "max-heartbeats" to be of type Nat directly.
"Only generate the documentation for the module it was given, might contain broken links unless all documentation is generated."
106
93
107
94
FLAGS:
108
95
b, build : String; "Build directory."
109
-
"max-heartbeats" : String; "Maximum heartbeats for elaboration (default: 100_000_000). Supports underscores as separators. Can also be set via DOCGEN_MAX_HEARTBEATS env var."
96
+
"max-heartbeats" : Nat; "Maximum heartbeats for elaboration (default: 100_000_000). Can also be set via DOCGEN_MAX_HEARTBEATS env var."
110
97
111
98
ARGS:
112
99
module : String; "The module to generate the HTML for. Does not have to be part of topLevelModules."
@@ -128,7 +115,7 @@ def genCoreCmd := `[Cli|
128
115
FLAGS:
129
116
b, build : String; "Build directory."
130
117
m, manifest : String; "Manifest output, to list all the files generated."
131
-
"max-heartbeats" : String; "Maximum heartbeats for elaboration (default: 100_000_000). Supports underscores as separators. Can also be set via DOCGEN_MAX_HEARTBEATS env var."
118
+
"max-heartbeats" : Nat; "Maximum heartbeats for elaboration (default: 100_000_000). Can also be set via DOCGEN_MAX_HEARTBEATS env var."
132
119
133
120
ARGS:
134
121
module : String; "The module to generate the HTML for."
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ The different options are:
92
92
Generation of equations for definitions is enabled by default, but can be disabled by setting the `DISABLE_EQUATIONS` environment variable to `1`.
93
93
94
94
## Max heartbeats
95
-
The maximum number of heartbeats for elaboration can be configured by setting the `DOCGEN_MAX_HEARTBEATS` environment variable. The default is `100_000_000`. Underscores can be used as separators for readability. For example:
95
+
The maximum number of heartbeats for elaboration can be configured by setting the `DOCGEN_MAX_HEARTBEATS` environment variable. The default is `100_000_000`. For example:
96
96
```
97
97
DOCGEN_MAX_HEARTBEATS=200_000_000 lake build YourLibraryName:docs
0 commit comments