Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjbest committed Dec 18, 2023
1 parent 816a700 commit 34f7fa7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
28 changes: 27 additions & 1 deletion Leaff/Diff.lean
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ instance [BEq α] [Hashable α] : ForIn m (SMap α β) (α × β) where
forIn t init f := do
forIn t.map₂ (← forIn t.map₁ init f) f

open private docStringExt in Lean.findDocString?
/-- Copied from `whatsnew` by @gebner and heavily cannibalized -/
def diffExtension (old new : Environment)
(ext : PersistentEnvExtension EnvExtensionEntry EnvExtensionEntry EnvExtensionState) :
Expand All @@ -245,9 +246,34 @@ def diffExtension (old new : Environment)
let newEntries := ext.exportEntriesFn newSt
-- dbg_trace oldEntries.size
-- dbg_trace newEntries.size
-- dbg_trace ext.name
let mut out := []
match ext.name with
| ``Lean.classExtension => do
| `Lean.docStringExt => do
dbg_trace "doc"
dbg_trace (SimplePersistentEnvExtension.getState docStringExt new).toList
for (a, b) in SimplePersistentEnvExtension.getState docStringExt new do
if ¬ (SimplePersistentEnvExtension.getState docStringExt old).contains a then
out := .docAdded a :: out
else
if (SimplePersistentEnvExtension.getState docStringExt old).find! a != b then
out := .docChanged a :: out
for (a, _b) in SimplePersistentEnvExtension.getState docStringExt old do
if ¬ (SimplePersistentEnvExtension.getState docStringExt new).contains a then
out := .docRemoved a :: out
| `Lean.classExtension => do
dbg_trace "doc"
dbg_trace (SimplePersistentEnvExtension.getState classExtension new).outParamMap.toList
-- for (a, b) in SimplePersistentEnvExtension.getState docStringExt new do
-- if ¬ (SimplePersistentEnvExtension.getState docStringExt old).contains a then
-- out := .docAdded a :: out
-- else
-- if (SimplePersistentEnvExtension.getState docStringExt old).find! a != b then
-- out := .docChanged a :: out
-- for (a, _b) in SimplePersistentEnvExtension.getState docStringExt old do
-- if ¬ (SimplePersistentEnvExtension.getState docStringExt new).contains a then
-- out := .docRemoved a :: out
| `Lean.classExtensin => do
-- for mod in [0:old.header.moduleData.size] do
-- (ext.getModuleEntries old mod)
-- IO.println (ext.getModuleEntries old mod).size
Expand Down
2 changes: 1 addition & 1 deletion lake-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{"url": "https://github.com/leanprover/std4.git",
"type": "git",
"subDir": null,
"rev": "d3049643f6dded69eb7ce8124796cb1ec8df8840",
"rev": "fadefd5a532a774dc47d00f9fa0bce3dc47ba2e1",
"name": "std",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.3.0-rc2
leanprover/lean4:v4.4.0-rc1
3 changes: 3 additions & 0 deletions test/TestA.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ theorem sada : Int := 123

structure blah where
(a b : Nat)

/-- magic number-/
def hasdoc : Int := 123
3 changes: 3 additions & 0 deletions test/TestB.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ def sada : Int := 123

class blah where
(a b : Nat)

/-- not so magic number-/
def hasdoc : Int := 123
4 changes: 4 additions & 0 deletions test/main.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Leaff.Diff
import Lean

open Lean

Expand All @@ -9,3 +10,6 @@ def sp : SearchPath :=
-- #eval summarizeDiffImports #[`Mathlib] #[`Mathlib] sp₁ sp₂

#eval summarizeDiffImports #[`test.TestA] #[`test.TestB] sp sp

open private docStringExt in Lean.findDocString?
#check docStringExt

0 comments on commit 34f7fa7

Please sign in to comment.