Skip to content

feat: docstrings with Verso syntax#10307

Merged
david-christiansen merged 25 commits intoleanprover:masterfrom
david-christiansen:verso-ast
Sep 10, 2025
Merged

feat: docstrings with Verso syntax#10307
david-christiansen merged 25 commits intoleanprover:masterfrom
david-christiansen:verso-ast

Conversation

@david-christiansen
Copy link
Copy Markdown
Contributor

This PR upstreams the Verso parser and adds preliminary support for Verso in docstrings. This will allow the compiler to check examples and cross-references in documentation.

After a stage0 update, a follow-up PR will add the appropriate attributes that allow the feature to be used. The parser tests from Verso also remain to be upstreamed, and user-facing documentation will be added once the feature has been used on more internals.

Comment on lines +11 to +34
attribute [doc_role] Lean.Doc.name
attribute [doc_role] Lean.Doc.kw
attribute [doc_role] Lean.Doc.kw?
attribute [doc_role] Lean.Doc.syntaxCat
attribute [doc_role] Lean.Doc.option
attribute [doc_role] Lean.Doc.attr
attribute [doc_role] Lean.Doc.tactic
attribute [doc_role] Lean.Doc.conv
attribute [doc_code_block] Lean.Doc.lean
attribute [doc_code_block] Lean.Doc.output
attribute [doc_command] Lean.Doc.«open»
attribute [doc_command] Lean.Doc.«set_option»
attribute [doc_role] Lean.Doc.given
attribute [doc_role lean] Lean.Doc.leanTerm
attribute [doc_role] Lean.Doc.manual
attribute [doc_role] Lean.Doc.syntax
attribute [doc_code_suggestions] Lean.Doc.suggestName
attribute [doc_code_suggestions] Lean.Doc.suggestLean
attribute [doc_code_suggestions] Lean.Doc.suggestTactic
attribute [doc_code_suggestions] Lean.Doc.suggestAttr
attribute [doc_code_suggestions] Lean.Doc.suggestOption
attribute [doc_code_suggestions] Lean.Doc.suggestKw
attribute [doc_code_suggestions] Lean.Doc.suggestCat
attribute [doc_code_suggestions] Lean.Doc.suggestSyntax
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines will be deleted after the stage0 update.

add := fun decl stx _ => do
Attribute.Builtin.ensureNoArgs stx
declareBuiltinDocStringAndRanges decl
applicationTime := AttributeApplicationTime.afterCompilation
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afterCompilation attributes are applied after documentation is added, so this is necessary here so the docs will be present.

@david-christiansen david-christiansen marked this pull request as ready for review September 8, 2025 15:43
@david-christiansen david-christiansen added the changelog-language Language features and metaprograms label Sep 8, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 8, 2025
@ghost
Copy link
Copy Markdown

ghost commented Sep 8, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 058f6008c033cf4edf814f13439ad692d9bb38a2 --onto 9923a8d9f8ca0c411d01d0790439ff02dc9dab8c. You can force Mathlib CI using the force-mathlib-ci label. (2025-09-08 16:33:46)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase c75d37f76bd5eca701dc67c1a19c8b7c50207712 --onto 9923a8d9f8ca0c411d01d0790439ff02dc9dab8c. You can force Mathlib CI using the force-mathlib-ci label. (2025-09-09 07:01:39)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 757426b09970c6bfb317eef27ca826909e83015f --onto c75d37f76bd5eca701dc67c1a19c8b7c50207712. You can force Mathlib CI using the force-mathlib-ci label. (2025-09-10 07:08:24)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

leanprover-bot commented Sep 8, 2025

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 058f6008c033cf4edf814f13439ad692d9bb38a2 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-09-08 16:33:48)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase c75d37f76bd5eca701dc67c1a19c8b7c50207712 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-09-09 07:01:41)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 757426b09970c6bfb317eef27ca826909e83015f --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-09-10 07:08:26)

@david-christiansen david-christiansen added the will-merge-soon …unless someone speaks up label Sep 9, 2025
@david-christiansen david-christiansen added this pull request to the merge queue Sep 10, 2025
Merged via the queue into leanprover:master with commit 3e2124b Sep 10, 2025
16 checks passed
kim-em added a commit to leanprover-community/batteries that referenced this pull request Sep 11, 2025
kim-em added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Sep 11, 2025
kim-em added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Sep 11, 2025
kim-em added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Sep 15, 2025
* fix deprecations

* remove upstreamed defs

* two fixes

* fix merge

* fix merge

* revert sqrt changes

* ugh

* fix from nightly-testing

* fix merge

* remove test deleted on master

* fix test

* note about test

* .

* Update lean-toolchain for leanprover/lean4#10194

* chore: bump to nightly-2025-09-02

* adjust to upstream changes

* fix

* fix

* long line

* Use Mathlib's nightly toolchain to run docgen in the nightly test

* simpNF linter

* whitespace

* Update lean-toolchain for testing leanprover/lean4#10217

* Correct the working directory: should be 'docbuild'

* Rework the grind regression report as a nightly-testing regression report

It should still report the same things, but now as one message for all regression kinds

* feat(Cache): download speeds & more info on errors

* fix(Cache): add base download failure message

* fixes

* turn off linter

* adaptation note

* turn off linter.nightlyRegressionSet

* chore: adaptations for nightly-2025-09-02

* Update lean-toolchain for testing leanprover/lean4#10059

* Update lean-toolchain for leanprover/lean4#10217

* chore: bump to nightly-2025-09-03

* Remove the erroring nightly regression report, we'll develop this on another branch.

* fixes

* update LibraryRewrite test

* Update lean-toolchain for leanprover/lean4#10059

* chore: bump to nightly-2025-09-04

* fix

* chore: bump to nightly-2025-09-05

* chore: adaptations for nightly-2025-09-05

* chore: bump to nightly-2025-09-06

* Update lean-toolchain for testing leanprover/lean4#10271

* Adapt to leanprover/lean4#10271

* Bump batteries

* Update lean-toolchain for leanprover/lean4#10271

* chore: bump to nightly-2025-09-07

* nolint unusedArguments

* Merge master into nightly-testing

* chore: bump to nightly-2025-09-08

* fixes

* chore: bump to nightly-2025-09-09

* fix thing

* Update lean-toolchain for testing leanprover/lean4#10306

* temporarily remove test

* adaptation note

* master version of Cache/Requests.lean

* chore: bump to nightly-2025-09-10

* adaptation note

* chore: adaptations for nightly-2025-09-10

* merge lean-pr-testing-10059

* bump toolchain manually??

* restore test

* chore: bump to nightly-2025-09-11

* lake update

* fix

* adaptations for leanprover/lean4#10307

* remove validateDocComment in ToAdditive

* remove upstreamed Function.Injective

* update assert_not_exists

* oops

* comment out DeriveTraversable

* chore: replace some grind attibutes with grind_pattern, to be robust for future heuristic changes

* suggestions from Rob23oba

* lshake --fix

* fix bad shake

* shake --update

* .

* chore: adaptations for nightly-2025-09-11

* chore: bump to nightly-2025-09-12

* Revert "oops"

This reverts commit 517b832.

* Revert "comment out DeriveTraversable"

This reverts commit 0460eb8.

* fix DeriveTraversable

* add `binders` fields

* fix

* fixes

* update manifest

* fixes

* fixes

* fixes

* chore: bump to nightly-2025-09-13

* fixes

* fixes

* fixes

* fixes

* fixes

* fixes

* fixes

* remove adaptation note

* Update lean-toolchain for testing leanprover/lean4#10373

* fixes

* chore: bump to nightly-2025-09-14

* Update lean-toolchain for testing leanprover/lean4#10377

* fix

* fix

* fix

* fix emrge

* update batteries

* chore: adaptations for nightly-2025-09-14

* Merge master into nightly-testing

* Update Mathlib/Data/List/Basic.lean

* Merge master into nightly-testing

* chore: adaptations for nightly-2025-09-14

* chore: bump to nightly-2025-09-15

---------

Co-authored-by: Rob23oba <robin.arnez@web.de>
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com>
Co-authored-by: Kim Morrison <kim@tqft.net>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: Mac Malone <mac@lean-fro.org>
Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com>
Co-authored-by: Paul Reichert <6992158+datokrat@users.noreply.github.com>
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
Co-authored-by: Kyle Miller <kmill31415@gmail.com>
Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com>
david-christiansen added a commit to david-christiansen/lean4 that referenced this pull request Oct 10, 2025
This PR fixes a regression introduced by leanprover#10307, where hovering the
name of an inductive type or constructor in its own declaration didn't
show the docstring. In the process, a bug in docstring handling for
coinductive types was discovered and also fixed. Tests are added to
prevent the regression from repeating in the future.
github-merge-queue bot pushed a commit that referenced this pull request Oct 15, 2025
This PR fixes a regression introduced by #10307, where hovering the name
of an inductive type or constructor in its own declaration didn't show
the docstring. In the process, a bug in docstring handling for
coinductive types was discovered and also fixed. Tests are added to
prevent the regression from repeating in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN will-merge-soon …unless someone speaks up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants