Skip to content

Commit

Permalink
Merge branch 'aiscript-next' into args
Browse files Browse the repository at this point in the history
  • Loading branch information
FineArchs authored Apr 1, 2024
2 parents c8ad88f + 4e4a37e commit a36286e
Show file tree
Hide file tree
Showing 26 changed files with 784 additions and 414 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/[email protected]

- name: Setup Node.js
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
node-version: 20.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/[email protected]

- name: Setup Node.js
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
node-version: 20.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/[email protected]

- name: Setup Node.js
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
node-version: 20.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-nightly-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
ref: ${{ env.BRANCH }}

- name: Setup Node.js
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
node-version: 20.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-nightly-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
ref: ${{ env.BRANCH }}

- name: Setup Node.js
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
node-version: 20.x

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/[email protected]

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -37,4 +37,4 @@ jobs:
CI: true

- name: Upload Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
- **Breaking Change** 多くの予約語を追加。これまで変数名等に使えていた名前に影響が出る可能性があります。
- 省略可能引数と初期値付き引数を追加。引数名に`?`を後置することでその引数は省略可能となります。引数に`=<式>`を後置すると引数に初期値を設定できます。省略可能引数は初期値`null`の引数と同等です。いずれでもない引数が省略されると即時エラーとなります。
- **Breaking Change** 配列及び関数の引数において、空白区切りが使用できなくなりました。`,`または改行が必要です。
- **Breaking Change** 関数同士の比較の実装
- **Breaking Change** `+``!`などの演算子の優先順位に変更があります。新しい順序は[syntax.md](docs/syntax.md#%E6%BC%94%E7%AE%97%E5%AD%90)を参照して下さい。
- **Breaking Change** 組み込み関数`Num:to_hex`は組み込みプロパティ`num#to_hex`に移動しました。

# 未リリース分
- `Core:abort`でプログラムを緊急停止できるように
- `index_of`の配列版を追加
- `str.index_of` `arr.index_of`共に第2引数fromIndexを受け付けるように
- `arr.incl`の引数の型制限を廃止
- `Date:millisecond`を追加
- `arr.fill`, `arr.repeat`, `Arr:create`を追加

# 0.17.0
- `package.json`を修正
Expand Down
17 changes: 9 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
テストはCIにより各コミット/各PRに対して自動で実施されます。
ローカル環境でテストを実施するには、`npm run test`を実行してください。

### tsd
このプロジェクトでは型のテストを行うために[tsd](https://github.com/SamVerschueren/tsd)を導入しています。
Jestによるテストでは「型が期待したものか」というのはチェックすることができません。tsdを使うことで、型が意図したものであることを担保することができます。
tsdによる型テストは[`/test-d`ディレクトリ](./test-d)に置かれます。

テストはCIにより各コミット/各PRに対して自動で実施されます。
ローカル環境でテストを実施するには、`npm run test`を実行してください。

### API Extractor
このプロジェクトでは[API Extractor](https://api-extractor.com/)を導入しています。API ExtractorはAPIレポートを生成する役割を持ちます。
APIレポートはいわばAPIのスナップショットで、このライブラリが外部に公開(export)している各種関数や型の定義が含まれています。`npm run api`コマンドを実行すると、その時点でのレポートが[`/etc`ディレクトリ](./etc)に生成されるようになっています。
Expand Down Expand Up @@ -61,3 +53,12 @@ PRを作成するときのテンプレートに色々書いてあるので読ん
- 期待する振る舞いがテストで担保されているか?
- 抜けやモレは無いか?
- 異常系のチェックは出来ているか?

## PRマージ時の規則
以降の規則は[member](https://github.com/orgs/aiscript-dev/people)が何をしてよいか明示するものであり、何かを禁止するものではありません。(禁止のための条項が必要になれば別に作ります)
- バグ修正、ドキュメントの編集、バージョン更新、dependabotのPRはmember1人の判断でマージしてよい
- ソースコード、テスト、本規則自体の変更は、member 2人以上のapproveを受けてから1日の経過を待ち、非memberを含む反対者が賛成者の半数以下ならマージしてよい
- 上記以外の変更はmember 1人以上のapproveを受けてから1日の経過を待ち、非memberを含む反対者が賛成者の半数以下ならマージしてよい
- リポジトリの所有者(@syuilo)の同意がある場合、以上の規則によらずにマージしてもよい
- 大前提としてすべてのマージはCI Checkを通過し、全てのreviewにPR主から何らかの返答がある必要がある
- 後でrevertになっても泣かない
10 changes: 0 additions & 10 deletions docs/contribution/index.md

This file was deleted.

29 changes: 26 additions & 3 deletions docs/primitive-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Core:range(0,2).push(4) //[0,1,2,4]
### @(_x_: num).to_str(): str
数値を文字列に変換します。

### @(_x_: num).to_hex(): str
数値から16進数の文字列を生成します。

## 文字列
### #(_v_: str).len
Expand Down Expand Up @@ -72,8 +74,11 @@ _splitter_ が与えられなければ一文字づつ区切ります。
### @(_v_: str).replace(_old_: str, _new_: str): str
文字列中の _old__new_ に置換したものを返します。

### @(_v_: str).index_of(_search_: str): num
文字列中から _search_ を検索し、あれば何文字に存在したかを、なければ-1を返します。
### @(_v_: str).index_of(_search_: str, _fromIndex_?: num): num
文字列中から_search_を探し、その添字を返します。
_fromIndex_が指定されていれば、その位置から検索を開始します。
_fromIndex_が負値の時は末尾からの位置(文字列の長さ+_fromIndex_)が使用されます。
該当が無ければ-1を返します。

### @(_v_: str).trim(): str
文字列の前後の空白を取り除いたものを返します。
Expand Down Expand Up @@ -126,7 +131,7 @@ _i_ 番目の文字が存在しない場合は null が返されます。
### @(_v_: arr).slice(_begin_: num, _end_: num): arr
配列の _begin_ 番目から _end_ 番目の部分を切り出して返します。

### @(_v_: arr).incl(_i_: str | num | bool | null): bool
### @(_v_: arr).incl(_i_: value): bool
配列に指定した値が含まれているかどうかを返します。

### @(_v_: arr).map(_func_: fn): arr
Expand All @@ -146,12 +151,19 @@ _initial_ が指定された場合は初回呼び出しの引数が(_initial_, _
### @(_v_: arr).find(_func_: @(_item_: value, _index_: num) { bool }): value
配列から _func_ が true を返すような要素を探し、その値を返します。

### @(_v_: arr).index_of(_val_: value, _fromIndex_?: num): num
配列から_val_と同じ値を探し、その添字を返します。
_fromIndex_が指定されていれば、その位置から検索を開始します。
_fromIndex_が負値の時は末尾からの位置(配列の長さ+_fromIndex_)が使用されます。
該当が無ければ-1を返します。

### @(_v_: arr).reverse(): null
**【この操作は配列を書き換えます】**
配列を反転させます。

### @(_v_: arr).copy(): arr
配列のコピーを生成します。
シャローコピーであり、配列やオブジェクトの参照は維持されます。

### @(_v_: arr).sort(_comp_: @(_a_: value, _b_: value)): arr
**【この操作は配列を書き換えます】**
Expand All @@ -163,6 +175,17 @@ _initial_ が指定された場合は初回呼び出しの引数が(_initial_, _
数値の並び替えでは`Core:sub`を渡すことで昇順、`@(a,b){b-a}`を渡すことで降順ソートができます。
文字列用の比較関数として`Str:lt`(昇順), `Str:gt`(降順)が用意されています。詳しくは[std.md](std.md#-str)をご覧下さい。

### @(_v_: arr).fill(_val_?: value, _fromIndex_?: num, _toIndex_?: num): arr
**【この操作は配列を書き換えます】**
配列の _fromIndex_ から _toIndex_ までの範囲の要素を _val_ で置き換えます。
_val_ 省略時は`null`で置き換えます。
_fromIndex_ および _toIndex_ に関する挙動は`arr.slice`に準拠します。

### @(_v_: arr).repeat(_times_: num): arr
配列を _times_ 回繰り返した配列を作成します。
`arr.copy`同様シャローコピーであり、配列やオブジェクトの参照は維持されます。
_times_ には0以上の整数値を指定します。それ以外ではエラーになります。

## エラー型
### #(_v_: error).name
型: `str`
Expand Down
22 changes: 15 additions & 7 deletions docs/std.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ AiScriptのバージョンです。
### @Core:to_str(_v_: value): str
値を表す文字列を取得します。

### @Core:sleep(_time_: value): void
### @Core:sleep(_time_: num): void
指定時間(ミリ秒)待機します。
## :: Util

### @Core:abort(_message_: str): never
プログラムを緊急停止します。

## :: Util
### @Util:uuid(): str
新しいUUIDを生成します。

## :: Json

### @Json:stringify(_v_: value): str
JSONを生成します。

Expand All @@ -53,7 +55,6 @@ JSONをパースします。 引数がJSONとしてパース可能性でない
文字列がJSONとしてパース可能であるかの判定を行います。歴史的理由により存在しています

## :: Date

### @Date:now(): num
現在時刻を取得します。

Expand Down Expand Up @@ -87,15 +88,17 @@ _date_ を渡した場合、_date_に対応する分、
_date_ を渡した場合、_date_に対応する秒、
渡していない場合は現在時刻の秒が返されます。

### @Date:millisecond(_date_?: num): num
現在時刻のミリ秒を取得します。
_date_ を渡した場合、_date_に対応するミリ秒、
渡していない場合は現在時刻のミリ秒が返されます。

### @Date:parse(_date_: str): num

## :: Math
数が多いため専用のページになっています。→[std-math.md](std-math.md)

## :: Num
### @Num:to_hex(_x_: num): str
数値から16進数の文字列を生成します。

### @Num:from_hex(_hex_: str): num
16進数の文字列から数値を生成します。

Expand Down Expand Up @@ -125,6 +128,11 @@ _codePoints_の各要素は 0 以上、10FFFF<sub>16</sub> 以下である必要
UTF-8のバイト列を表す数値の配列から文字を生成します。
_bytes_の各要素は 0 以上、255 以下である必要があります。

## :: Arr
### @Arr:create(_length_: num, _initial_?: value): arr
長さが`length`の配列を作成します。
配列は _initial_ が与えられていれば _initial_ 、でなければ`null`で埋められます。

## :: Obj
### @Obj:keys(_v_: obj): arr
### @Obj:vals(_v_: obj): arr
Expand Down
12 changes: 10 additions & 2 deletions etc/aiscript.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type AddAssign = NodeBase & {
};

// @public (undocumented)
export const AISCRIPT_VERSION: "0.17.0";
export const AISCRIPT_VERSION: "0.18.0";

// @public (undocumented)
abstract class AiScriptError extends Error {
Expand Down Expand Up @@ -66,6 +66,13 @@ class AiScriptTypeError extends AiScriptError {
name: string;
}

// @public
class AiScriptUserError extends AiScriptRuntimeError {
constructor(message: string, info?: any);
// (undocumented)
name: string;
}

// @public (undocumented)
type And = NodeBase & {
type: 'and';
Expand Down Expand Up @@ -239,7 +246,8 @@ declare namespace errors {
AiScriptTypeError,
AiScriptNamespaceError,
AiScriptRuntimeError,
AiScriptIndexOutOfRangeError
AiScriptIndexOutOfRangeError,
AiScriptUserError
}
}
export { errors }
Expand Down
Loading

0 comments on commit a36286e

Please sign in to comment.