in lib/parser.js [946:984]
api() {
// api = "api" apiName "(" [ params ] ")" [returnType] apiBody [ returns ]
const begin = this.getIndex();
this.matchWord(Tag.ID, 'api');
const apiName = this.look;
this.match(Tag.ID);
this.match('(');
const params = this.params();
this.match(')');
this.match(':');
const returnType = this.baseType();
const apiBody = this.apiBody();
let end = apiBody.tokenRange[1];
var returnBody;
if (this.isWord(Tag.ID, 'returns')) {
// 可选的
this.move();
returnBody = this.returnBody();
end = returnBody.tokenRange[1];
}
var runtimeBody;
if (this.isWord(Tag.ID, 'runtime')) {
this.move();
runtimeBody = this.object();
end = runtimeBody.tokenRange[1];
}
return {
type: 'api',
apiName: apiName,
params: params,
returnType: returnType,
apiBody: apiBody,
returns: returnBody,
runtimeBody: runtimeBody,
tokenRange: [begin, end]
};
}