-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #815 from lean-ja/Seasawher/issue284
`[inherit_doc]` を紹介する
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/- # inherit_doc | ||
`inherit_doc` 属性を指定すると、既存の定数などのドキュメントコメントを使いまわすことができます。 | ||
-/ | ||
import Lean | ||
|
||
open Lean | ||
|
||
/-- 最初に与えた doc コメント -/ | ||
def greet := "hello" | ||
|
||
-- `greet` のドキュメントコメントを引き継ぐ | ||
@[inherit_doc greet] abbrev greet' := greet | ||
|
||
section | ||
|
||
open Elab.Command | ||
|
||
/-- ドキュメントコメントを取得して表示するコマンド -/ | ||
elab "#doc " x:ident : command => do | ||
let name ← liftCoreM do realizeGlobalConstNoOverload x | ||
if let some s ← findDocString? (← getEnv) name then | ||
logInfo m!"{s}" | ||
|
||
end | ||
|
||
/-- info: 最初に与えた doc コメント -/ | ||
#guard_msgs in #doc greet' | ||
|
||
/- `inherit_doc` を使用するのは、記法を導入する際であることが多いでしょう。この場合、ドキュメントコメントの継承元を指定する必要がありません。 -/ | ||
|
||
/-- `⊔` という記号のための型クラス -/ | ||
class Sup (α : Type) where | ||
/-- 最小上界、上限 -/ | ||
sup : α → α → α | ||
|
||
@[inherit_doc] infixl:68 " ⊔ " => Sup.sup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters