literate: no way to hide `@[expose] public section`, `@[reducible] def ...`, or a command after a comment

Open
#1,107 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Domain
documentation

Research direction

Start in src/verso-literate-code/VersoLiterateCode.lean at leadingKeywords (lines 539–553), then trace how hide_commands matches command text. Reproduce the three cases from the issue and inspect the literate build or related tests. Done means attributes and comments no longer prevent matching the specified commands, with existing plain-command hiding still working.

Written by the indexing model from the issue text.

Description

In a literate site, hide_commands can't hide a command that starts with an attribute, or one with a comment directly above it. Some common cases:

  • @[expose] public section is boilerplate at the top of many module-system files, and readers don't need to see it. But no hide_commands pattern hides it: neither "public section" nor "section" matches.
  • Declarations with attributes, such as @[reducible] def foo ... or @[simp] theorem bar ..., aren't hidden by "def" or "theorem", even though the same patterns hide the plain def and theorem commands.
  • Commands with a comment above them: a -- comment directly above an otherwise matching command, such as a def or an open, stops it from being hidden.

Reproduction

literate.toml:

hide_commands = ["def", "public section"]

A module in the published library:

module

@[expose] public section

@[reducible] def foo : Nat := 1

def bar : Nat := 2

-- a comment
def baz : Nat := 3

After lake build :literateHtml, only bar is hidden: @[expose] public section, foo and baz all still appear.

Cause

hide_commands matches a command's leading keywords, and leadingKeywords stops at the first token that isn't a keyword:

https://github.com/leanprover/verso/blob/a40afc8c44badcc1e58f060ec70a2aa5cb6243c6/src/verso-literate-code/VersoLiterateCode.lean#L539-L553

A comment directly above a command is part of that command's code, so for all three cases the first token is @[ or --, and there are no leading keywords for any pattern to match.


Perhaps the intent is that this feature is only used to hide custom commands?

Dominant language
Lean
Stars
420
Forks
134
Avg merge
1d 9m
Merged PRs (30d)
46

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from leanprover/verso

All issues in leanprover/verso

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.