This is the groundwork for a tactic index in generated documentation, as there was in Lean 3. There are a few challenges to getting this to work well in Lean 4: * There's no natural notion of *tactic identity* - a tactic may be specified by multiple syntax rules (e.g. the pattern-matching version of `intro` is specified apart from the default version, but both are the same from a user perspective) * There's no natural notion of *tactic name* - here, we take the pragmatic choice of using the first keyword atom in the tactic's syntax specification, but this may need to be overridable someday. * Tactics are extensible, but we don't want to allow arbitrary imports to clobber existing tactic docstrings, which could become unpredictable in practice. For tactic identity, this PR introduces the notion of a *tactic alternative*, which is a `syntax` specification that is really "the same as" an existing tactic, but needs to be separate for technical reasons. This provides a notion of tactic identity, which we can use as the basis of a tactic index in generated documentation. Alternative forms of tactics are specified using a new `@[tactic_alt IDENT]` attribute, applied to the new tactic syntax. It is an error to declare a tactic syntax rule to be an alternative of another one that is itself an alternative. Documentation hovers now take alternatives into account, and display the docs for the canonical name. *Tactic tags*, created with the `register_tactic_tag` command, specify tags that may be applied to tactics. This is intended to be used by doc-gen and Verso. Tags may be applied using the `@[tactic_tag TAG1 TAG2 ...]` attribute on a canonical tactic parser, which may be used in any module to facilitate downstream projects introducing tags that apply to pre-existing tactics. Tags may not be removed, but it's fine to redundantly add them. The collection of tags, and the tactics to which they're applied, can be seen using the `#print tactic tags` command. *Extension documentation* provides a structured way to document extensions to tactics. The resulting documentation is gathered into a bulleted list at the bottom of the tactic's docstring. Extensions are added using the `tactic_extension TAC` command. This can be used when adding new interpretations of a tactic via `macro_rules`, when extending some table or search index used by the tactic, or in any other way. It is a command to facilitate its flexible use with various extension mechanisms.
56 lines
2.6 KiB
Text
56 lines
2.6 KiB
Text
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 16, "character": 17}}
|
|
{"range":
|
|
{"start": {"line": 16, "character": 17}, "end": {"line": 16, "character": 27}},
|
|
"contents":
|
|
{"value":
|
|
"```lean\nmy_trivial : Lean.ParserDescr\n```\n***\nAnother `trivial` tactic ",
|
|
"kind": "markdown"}}
|
|
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 19, "character": 15}}
|
|
{"range":
|
|
{"start": {"line": 19, "character": 13}, "end": {"line": 19, "character": 23}},
|
|
"contents":
|
|
{"value":
|
|
"Another `trivial` tactic \n\nExtensions:\n\n * It tries Lean's `trivial`",
|
|
"kind": "markdown"}}
|
|
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 29, "character": 8}}
|
|
{"range":
|
|
{"start": {"line": 29, "character": 2}, "end": {"line": 29, "character": 12}},
|
|
"contents":
|
|
{"value":
|
|
"Another `trivial` tactic \n\nExtensions:\n\n * It tries Lean's `trivial` \n\n * It tries `simp_all`",
|
|
"kind": "markdown"}}
|
|
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 33, "character": 17}}
|
|
{"range":
|
|
{"start": {"line": 33, "character": 17}, "end": {"line": 33, "character": 27}},
|
|
"contents":
|
|
{"value":
|
|
"```lean\nmy_trivial : Lean.ParserDescr\n```\n***\nAnother `trivial` tactic \n\nExtensions:\n\n * It tries Lean's `trivial` \n\n * It tries `simp_all`",
|
|
"kind": "markdown"}}
|
|
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 38, "character": 13}}
|
|
{"range":
|
|
{"start": {"line": 38, "character": 13}, "end": {"line": 38, "character": 23}},
|
|
"contents":
|
|
{"value":
|
|
"Another `trivial` tactic \n\nExtensions:\n\n * It tries Lean's `trivial` \n\n * It tries `simp_all` \n\n * It tries `constructor`",
|
|
"kind": "markdown"}}
|
|
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 54, "character": 8}}
|
|
{"range":
|
|
{"start": {"line": 54, "character": 2}, "end": {"line": 54, "character": 12}},
|
|
"contents":
|
|
{"value":
|
|
"Another `trivial` tactic \n\nExtensions:\n\n * It tries Lean's `trivial` \n\n * It tries `simp_all` \n\n * It tries `constructor` \n\n * It tries some useful things:\n * `omega`\n * `simp_arith [*]`",
|
|
"kind": "markdown"}}
|
|
{"textDocument": {"uri": "file:///hoverTacticExt.lean"},
|
|
"position": {"line": 59, "character": 8}}
|
|
{"range":
|
|
{"start": {"line": 59, "character": 2}, "end": {"line": 59, "character": 14}},
|
|
"contents":
|
|
{"value":
|
|
"Another `trivial` tactic \n\nExtensions:\n\n * It tries Lean's `trivial` \n\n * It tries `simp_all` \n\n * It tries `constructor` \n\n * It tries some useful things:\n * `omega`\n * `simp_arith [*]`",
|
|
"kind": "markdown"}}
|