Skip to content

Commit 05bb841

Browse files
authored
chore: bump toolchain to v4.27.0-rc1 (#338)
1 parent 77ef3eb commit 05bb841

File tree

10 files changed

+37
-37
lines changed

10 files changed

+37
-37
lines changed

DocGen4/Output/Base.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ corresponds to which identifier it will thus say that `" + "` corresponds to
251251
only `+` should be linked, taking care of this is what this function is
252252
responsible for.
253253
-/
254-
def splitWhitespaces (s : String) : (String × String × String) := Id.run do
255-
let mut length := s.length
256-
let mut s := s.trimLeft
257-
let front := "".pushn ' ' (length - s.length)
258-
length := s.length
259-
s := s.trimRight
254+
def splitWhitespaces (s : String) : String × String × String :=
255+
let length := s.length
256+
let s := s.trimAsciiStart
257+
let front := "".pushn ' ' (length - s.positions.count)
258+
let length := s.positions.count
259+
let s := s.trimAsciiEnd.copy
260260
let back := "".pushn ' ' (length - s.length)
261261
(front, s, back)
262262

DocGen4/Output/Bibtex.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace DocGen4.Bibtex
1919

2020
/-- Process the contents of bib file. -/
2121
def process' (contents : String) : Except String (Array BibItem) := do
22-
match BibtexQuery.Parser.bibtexFile ⟨contents, contents.startValidPoswith
22+
match BibtexQuery.Parser.bibtexFile ⟨contents, contents.startPoswith
2323
| .success _ arr =>
2424
let arr ← arr.toArray.filterMapM ProcessedEntry.ofEntry
2525
return arr |> sortEntry |> deduplicateTag |>.map fun x =>

DocGen4/Output/DocString.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ partial def xmlGetHeadingId (el : Xml.Element) : String :=
7070
def nameToLink? (s : String) : HtmlM (Option String) := do
7171
let res ← getResult
7272
if s.endsWith ".lean" && s.contains '/' then
73-
return (← getRoot) ++ s.dropRight 5 ++ ".html"
73+
return (← getRoot) ++ s.dropEnd 5 ++ ".html"
7474
else if let some name := Lean.Syntax.decodeNameLit ("`" ++ s) then
7575
-- with exactly the same name
7676
if res.name2ModIdx.contains name then
@@ -106,7 +106,7 @@ def nameToLink? (s : String) : HtmlM (Option String) := do
106106
def extendLink (s : String) : HtmlM String := do
107107
-- for intra doc links
108108
if s.startsWith "##" then
109-
if let some link ← nameToLink? (s.drop 2) then
109+
if let some link ← nameToLink? (s.drop 2).copy then
110110
return link
111111
else
112112
return s!"{← getRoot}find/?pattern={s.drop 2}#doc"
@@ -158,7 +158,7 @@ def addHeadingAttributes (el : Element) (funName : String)
158158
/-- Find a bibitem if `href` starts with `thePrefix`. -/
159159
def findBibitem? (href : String) (thePrefix : String := "") : HtmlM (Option BibItem) := do
160160
if href.startsWith thePrefix then
161-
pure <| (← read).refsMap[href.drop thePrefix.length]?
161+
pure <| (← read).refsMap[href.drop thePrefix.length |>.copy]?
162162
else
163163
pure .none
164164

@@ -206,8 +206,8 @@ def autoLink (el : Element) : HtmlM Element := do
206206
let attributes := Std.TreeMap.empty.insert "href" link
207207
return [Content.Element <| Element.Element "a" attributes #[Content.Character s]]
208208
| none =>
209-
let sHead := s.dropRightWhile (· != '.')
210-
let sTail := s.takeRightWhile (· != '.')
209+
let sHead := s.dropEndWhile (· != '.') |>.copy
210+
let sTail := s.takeEndWhile (· != '.') |>.copy
211211
let link'? ← nameToLink? sTail
212212
match link'? with
213213
| some link' =>
@@ -242,13 +242,13 @@ partial def modifyElement (element : Element) (funName : String) : HtmlM Element
242242
return ⟨ name, attrs, ← modifyContents contents funName modifyElement ⟩
243243

244244
/-- Find all references in a markdown text. -/
245-
partial def findAllReferences (refsMap : Std.HashMap String BibItem) (s : String) (i : String.Pos.Raw := 0)
245+
partial def findAllReferences (refsMap : Std.HashMap String BibItem) (s : String) (i : s.Pos := s.startPos)
246246
(ret : Std.HashSet String := ∅) : Std.HashSet String :=
247-
let lps := s.posOfAux '[' s.rawEndPos i
248-
if lps < s.rawEndPos then
249-
let lpe := s.posOfAux ']' s.rawEndPos lps
250-
if lpe < s.rawEndPos then
251-
let citekey := Substring.Raw.toString ⟨s, ⟨lps.1 + 1⟩, lpe
247+
let lps := i.find '['
248+
if hs : lps s.endPos then
249+
let lpe := lps.find ']'
250+
if lpe s.endPos then
251+
let citekey := s.extract (lps.next hs) lpe
252252
match refsMap[citekey]? with
253253
| .some _ => findAllReferences refsMap s lpe (ret.insert citekey)
254254
| .none => findAllReferences refsMap s lpe ret
@@ -264,7 +264,7 @@ def docStringToHtml (docString : String) (funName : String) : HtmlM (Array Html)
264264
s!"[{s}]: references.html#ref_{s}\n")
265265
match MD4Lean.renderHtml (docString ++ refsMarkdown) with
266266
| .some rendered =>
267-
match manyDocument ⟨rendered, rendered.startValidPoswith
267+
match manyDocument ⟨rendered, rendered.startPoswith
268268
| .success _ res =>
269269
let newRes ← modifyElements res funName modifyElement
270270
-- TODO: use `toString` instead of `eToStringEscaped`

DocGen4/Output/References.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def preprocessBibFile (buildDir : System.FilePath) (contents : String) (process
3333
IO.FS.writeFile (basePath buildDir / "references.bib") contents
3434
IO.FS.writeFile (declarationsBasePath buildDir / "references.json") "[]"
3535
-- if contents is empty, just do nothing
36-
if contents.trim.isEmpty then
36+
if contents.trimAscii.isEmpty then
3737
return
3838
-- run the user provided process function
3939
let items ← process contents

DocGen4/Output/ToHtmlFormat.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ partial def toStringAux : Html → String
8787
| raw s => s
8888

8989
def toString (html : Html) : String :=
90-
html.toStringAux.trimRight
90+
html.toStringAux.trimAsciiEnd.copy
9191

9292
partial def textLength : Html → Nat
9393
| raw s => s.length -- measures lengths of escape sequences too!
@@ -109,7 +109,7 @@ def jsxText : Parser :=
109109
withAntiquot (mkAntiquot "jsxText" `jsxText) {
110110
fn := fun c s =>
111111
let startPos := s.pos
112-
let s := takeWhile1Fn (not ∘ "[{<>}]$".contains) "expected JSX text" c s
112+
let s := takeWhile1Fn (!"[{<>}]$".contains ·) "expected JSX text" c s
113113
mkNodeToken `jsxText startPos true c s }
114114

115115
@[combinator_formatter DocGen4.Jsx.jsxText] def jsxText.formatter : Formatter := pure ()

DocGen4/Process/Attributes.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ instance : ToString Linter.DeprecationEntry where
113113
if let some since := entry.since? then
114114
string := string ++ s!"(since := \"{since}\")"
115115

116-
string := string.trimRight
116+
string := string.trimAsciiEnd.copy
117117
return string
118118

119119
/--

DocGen4/Process/Hierarchy.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def toArray : HierarchyMap → Array (Name × Hierarchy)
3232
def hForIn [Monad m] (t : HierarchyMap) (init : σ) (f : (Name × Hierarchy) → σ → m (ForInStep σ)) : m σ :=
3333
t.forIn init (fun a b acc => f (a, b) acc)
3434

35-
instance : ForIn m HierarchyMap (Name × Hierarchy) where
35+
instance [Monad m] : ForIn m HierarchyMap (Name × Hierarchy) where
3636
forIn := HierarchyMap.hForIn
3737

3838
end HierarchyMap
@@ -105,7 +105,7 @@ partial def fromDirectoryAux (dir : System.FilePath) (previous : Name) : IO (Arr
105105
if ← entry.path.isDir then
106106
children := children ++ (← fromDirectoryAux entry.path (.str previous entry.fileName))
107107
else if entry.path.extension = some "html" then
108-
children := children.push <| .str previous (entry.fileName.dropRight ".html".length)
108+
children := children.push <| .str previous (entry.fileName.dropEnd ".html".length).copy
109109
return children
110110

111111
def fromDirectory (dir : System.FilePath) : IO Hierarchy := do
@@ -116,7 +116,7 @@ def fromDirectory (dir : System.FilePath) : IO Hierarchy := do
116116
else if ← entry.path.isDir then
117117
children := children ++ (← fromDirectoryAux entry.path (.mkSimple entry.fileName))
118118
else if entry.path.extension = some "html" then
119-
children := children.push <| .mkSimple (entry.fileName.dropRight ".html".length)
119+
children := children.push <| .mkSimple (entry.fileName.dropEnd ".html".length).copy
120120
return Hierarchy.fromArray children
121121

122122
end Hierarchy

lake-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"subDir": null,
77
"scope": "",
8-
"rev": "933fce7e893f65969714c60cdb4bd8376786044e",
8+
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
99
"name": "Cli",
1010
"manifestFile": "lake-manifest.json",
1111
"inputRev": "main",
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"subDir": null,
1717
"scope": "",
18-
"rev": "84b88f7ac9adf382b9668f852cee82487d616792",
18+
"rev": "cff8377dbe50aae42cbd04213d5b3dacf742c3ba",
1919
"name": "UnicodeBasic",
2020
"manifestFile": "lake-manifest.json",
2121
"inputRev": "main",
@@ -25,7 +25,7 @@
2525
"type": "git",
2626
"subDir": null,
2727
"scope": "",
28-
"rev": "3ab4379b2b92448717de66b7d3e254ac1487aede",
28+
"rev": "f3872ff0d82a43e2ab57595524df3934210f2bb9",
2929
"name": "BibtexQuery",
3030
"manifestFile": "lake-manifest.json",
3131
"inputRev": "master",

lakefile.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ def getGitSubDirectory (directory : System.FilePath := "." ) : IO System.FilePat
3636
let explanation := "Failed to execute git rev-parse --show-prefix"
3737
let err := s!"git exited with code {out.exitCode} while looking for the git subdirectory in {directory}"
3838
throw <| IO.userError <| explanation ++ "\n" ++ err
39-
let subdir := out.stdout.trimRight
39+
let subdir := out.stdout.trimAsciiEnd
4040
-- e.g. if the Lean package is under a directory "myleanpackage",
4141
-- `git rev-parse --show-prefix` would return "myleanpackage/".
4242
-- We drop the trailing path separator.
43-
return if subdir = "" then "." else subdir.dropRight 1
43+
return if subdir == "".toSlice then "." else subdir.dropEnd 1 |>.copy
4444

4545
/--
4646
Obtain the Github URL of a project by parsing the origin remote.
@@ -55,7 +55,7 @@ def getGitRemoteUrl (directory : System.FilePath := "." ) (remote : String := "o
5555
let explanation := "Failed to find a git remote in your project, consider reading: https://github.com/leanprover/doc-gen4#source-locations"
5656
let err := s!"git exited with code {out.exitCode} while looking for the git remote in {directory}"
5757
throw <| IO.userError <| explanation ++ "\n" ++ err
58-
return out.stdout.trimRight
58+
return out.stdout.trimAsciiEnd.copy
5959

6060
/--
6161
Obtain the git commit hash of the project that is currently getting analyzed.
@@ -68,7 +68,7 @@ def getProjectCommit (directory : System.FilePath := "." ) : IO String := do
6868
}
6969
if out.exitCode != 0 then
7070
throw <| IO.userError <| s!"git exited with code {out.exitCode} while looking for the current commit in {directory}"
71-
return out.stdout.trimRight
71+
return out.stdout.trimAsciiEnd.copy
7272

7373
def filteredPath (path : FilePath) : List String := path.components.filter (· != ".")
7474

@@ -82,11 +82,11 @@ Three link types from git supported:
8282
def getGithubBaseUrl (url : String) : Option String :=
8383
if url.startsWith "[email protected]:" && url.endsWith ".git" then
8484
let url := url.drop "[email protected]:".length
85-
let url := url.dropRight ".git".length
85+
let url := url.dropEnd ".git".length
8686
.some s!"https://github.com/{url}"
8787
else if url.startsWith "https://github.com/" then
8888
if url.endsWith ".git" then
89-
.some <| url.dropRight ".git".length
89+
.some <| url.dropEnd ".git".length |>.copy
9090
else
9191
.some url
9292
else
@@ -115,7 +115,7 @@ package_facet srcUri.github (pkg) : String := Job.async do
115115
s!"Could not interpret Git remote uri {url} as a Github source repo.\n"
116116
++ "See README on source URIs for more details."
117117
let commit ← getProjectCommit pkg.dir
118-
logInfo s!"Found git remote for {pkg.name} at {baseUrl} @ {commit}"
118+
logInfo s!"Found git remote for {pkg.baseName} at {baseUrl} @ {commit}"
119119
let subdir ← getGitSubDirectory pkg.dir
120120
return "/".intercalate <| baseUrl :: "blob" :: commit :: filteredPath (subdir / pkg.config.srcDir)
121121

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.26.0
1+
leanprover/lean4:v4.27.0-rc1

0 commit comments

Comments
 (0)