This PR adds a `recommended_spelling` command, which can be used for recording the recommended spelling of a notation (for example, that the recommended spelling of `∧` in identifiers is `and`). This information is then appended to the relevant docstrings for easy lookup. The function `Lean.Elab.Term.Doc.allRecommendedSpellings` may be used to obtain a list of all recommended spellings, for example to create a table that is part of a style guide. In the future, it might be desirable to be able to partition such a table into smaller tables by category. This can be added in a future PR. The implementation is heavily inspired by #4490.
32 lines
1.2 KiB
Text
32 lines
1.2 KiB
Text
/-
|
|
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
Authors: Leonardo de Moura
|
|
-/
|
|
prelude
|
|
import Lean.DocString.Extension
|
|
import Lean.Parser.Tactic.Doc
|
|
import Lean.Parser.Term.Doc
|
|
|
|
set_option linter.missingDocs true
|
|
|
|
-- This module contains the main query interface for docstrings, which assembles user-visible
|
|
-- docstrings.
|
|
-- The module `Lean.DocString.Extension` contains the underlying data.
|
|
|
|
namespace Lean
|
|
open Lean.Parser.Tactic.Doc
|
|
open Lean.Parser.Term.Doc
|
|
|
|
/--
|
|
Finds the docstring for a name, taking tactic alternate forms and documentation extensions into
|
|
account.
|
|
|
|
Use `Lean.findSimpleDocString?` to look up the raw docstring without resolving alternate forms or
|
|
including extensions.
|
|
-/
|
|
def findDocString? (env : Environment) (declName : Name) (includeBuiltin := true) : IO (Option String) := do
|
|
let declName := alternativeOfTactic env declName |>.getD declName
|
|
let exts := getTacticExtensionString env declName
|
|
let spellings := getRecommendedSpellingString env declName
|
|
return (← findSimpleDocString? env declName (includeBuiltin := includeBuiltin)).map (· ++ exts ++ spellings)
|