Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delimiters should go on their own line in multiline docs #475

Open
wants to merge 1 commit into
base: lean4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions templates/contribute/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Every definition and major theorem is required to have a doc string.
(Doc strings on lemmas are also encouraged, particularly if the lemma has any mathematical content
or might be useful in another file.)
These are introduced using `/--` and closed by `-/` above the definition, with either newlines or
single spaces between the markers and the text.
single spaces between the markers and the text. When they require multiple lines, the delimiters should go on their own line.
They can contain Markdown and LaTeX as well: see the next section. If a doc string is a complete
sentence, then it should end in a period. Named theorems, such as the **mean value theorem** should be bold faced (i.e., with
two asterisks before and after).
Expand All @@ -96,17 +96,21 @@ Doc strings should convey the mathematical meaning of the definition. They are a
slightly about the actual implementation. The following is a doc string example:

```lean
/-- If `q ≠ 0`, the `p`-adic norm of a rational `q` is `p ^ (-padicValRat p q)`.
If `q = 0`, the `p`-adic norm of `q` is `0`. -/
/--
If `q ≠ 0`, the `p`-adic norm of a rational `q` is `p ^ (-padicValRat p q)`.
If `q = 0`, the `p`-adic norm of `q` is `0`.
-/
def padicNorm (p : ℕ) (q : ℚ) : ℚ :=
if q = 0 then 0 else (p : ℚ) ^ (-padicValRat p q)
```

An example that is slightly lying but still describes the mathematical content would be:

```lean
/-- `padicValRat` defines the valuation of a rational `q` to be the valuation of `q.num` minus the
valuation of `q.den`. If `q = 0` or `p = 1`, then `padicValRat p q` defaults to `0`. -/
/--
`padicValRat` defines the valuation of a rational `q` to be the valuation of `q.num` minus the
valuation of `q.den`. If `q = 0` or `p = 1`, then `padicValRat p q` defaults to `0`.
-/
def padicValRat (p : ℕ) (q : ℚ) : ℤ :=
padicValInt p q.num - padicValNat p q.den
```
Expand Down Expand Up @@ -195,8 +199,10 @@ namespace Name

/-! ### Declarations about `name` -/

/-- Find the largest prefix `n` of a `Name` such that `f n != none`, then replace this prefix
with the value of `f n`. -/
/--
Find the largest prefix `n` of a `Name` such that `f n != none`, then replace this prefix
with the value of `f n`.
-/
def mapPrefix (f : Name → Option Name) (n : Name) : Name := Id.run do
if let some n' := f n then return n'
match n with
Expand Down