Skip to content

Commit e72bf59

Browse files
feat: more metadata for Verso docstrings (#10560)
This PR adds highlighted Lean code to Verso docstrings and fixes smaller quality-of-life issues.
1 parent 343328b commit e72bf59

File tree

3 files changed

+377
-135
lines changed

3 files changed

+377
-135
lines changed

src/Lean/Elab/DocString.lean

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,23 +1171,21 @@ register_builtin_option doc.verso.suggestions : Bool := {
11711171
-- during bootstrapping, the names in question may not yet be defined, so builtin
11721172
-- names need special handling.
11731173
private def suggestionName (name : Name) : TermElabM Name := do
1174-
try
1175-
if (← getEnv).contains name then
1176-
unresolveNameGlobalAvoidingLocals name
1177-
else
1178-
builtinFallback
1179-
catch
1180-
| _ => builtinFallback
1181-
where
1182-
builtinFallback := do
1183-
let name' ←
1184-
if (← builtinDocRoles.get).contains name then pure (some name)
1185-
else if (← builtinDocCodeBlocks.get).contains name then pure (some name)
1186-
else pure none
1187-
match name' with
1188-
| some (.str _ s) => return .str .anonymous s
1189-
| some n => return n
1190-
| none => return name
1174+
let name' ←
1175+
-- Builtin expander names never need namespacing
1176+
if (← builtinDocRoles.get).contains name then pure (some name)
1177+
else if (← builtinDocCodeBlocks.get).contains name then pure (some name)
1178+
else pure none
1179+
match name' with
1180+
| some (.str _ s) => return .str .anonymous s
1181+
| some n => return n
1182+
| none =>
1183+
-- If it exists, unresolve it
1184+
if (← getEnv).contains name then
1185+
unresolveNameGlobalAvoidingLocals name
1186+
else
1187+
-- Fall back to doing nothing
1188+
pure name
11911189

11921190
private def sortSuggestions (ss : Array Meta.Hint.Suggestion) : Array Meta.Hint.Suggestion :=
11931191
let cmp : (x y : Meta.Tactic.TryThis.SuggestionText) → Bool

0 commit comments

Comments
 (0)