feat: allow separating sample code and doc-comments

This commit is contained in:
Shunsuke Shibayama 2023-02-17 20:37:15 +09:00
parent 0c579fa6fb
commit 51cae591a3
15 changed files with 135 additions and 79 deletions

View file

@ -1,18 +1,12 @@
'''
Return the absolute value of the argument.
```erg
assert abs(-1) == 1
assert abs(3+4Im) == 5
```
'''
'''japanese
引数の絶対値を返す
```erg
'''
'''erg
assert abs(-1) == 1
assert abs(3+4Im) == 5
```
'''
.abs: (x: Num) -> Nat
@ -20,11 +14,10 @@ assert abs(3+4Im) == 5
Return `True` if `x == True` for all values `x` in the `iterable`.
If the `iterable` is empty, return `True`.
```erg
'''
'''erg
assert all [1, 2].map(x -> x > 0)
assert all []
```
'''
.all: (iterable: Iterable Bool) -> Bool
@ -32,11 +25,10 @@ assert all []
Return `True` if `x == True` for any value `x` in the `iterable`.
If the `iterable` is empty, return `False`.
```erg
'''
'''erg
assert any [-1, 1, 2].map(x -> x < 0)
assert not any []
```
'''
.any: (iterable: Iterable Bool) -> Bool
@ -47,22 +39,16 @@ As repr(), return a string containing a printable representation of an
object, but escape the non-ASCII characters in the string returned by
repr() using \\x, \\u or \\U escapes. This generates a string similar
to that returned by repr() in Python 2.
```erg
assert ascii("a") == "'a'"
assert ascii("") == "'\\u3042'"
```
'''
'''japanese
オブジェクトのASCII表現を返す
repr()と同じようにオブジェクトの表現を文字列で返すがrepr()で返される文字列の非ASCII文字は\\x\\u\\Uエスケープでエスケープされる
これはPython 2でのrepr()と似た文字列を生成する
```erg
'''
'''erg
assert ascii("a") == "'a'"
assert ascii("") == "'\\u3042'"
```
'''
.ascii: (obj: Obj) -> Str