UNPKG

solidity-ast

Version:
32 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execall = exports.parseNatSpec = void 0; function parseNatSpec(node) { var _a, _b, _c; const doc = typeof node.documentation === 'string' ? node.documentation : (_b = (_a = node.documentation) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : ''; const res = []; for (const { groups } of execall(/^\s*(@(?<tag>(custom:)?[a-z][a-z-]*)?\s+)?(?<args>((?!^\s@\w+)[^])*)/m, doc)) { if (groups) { res.push({ tag: groups.tag, args: (_c = groups.args) !== null && _c !== void 0 ? _c : '', }); } } return res; } exports.parseNatSpec = parseNatSpec; function* execall(re, text) { re = new RegExp(re, re.flags + (re.sticky ? '' : 'y')); while (true) { const match = re.exec(text); if (match && match[0] !== '') { yield match; } else { break; } } } exports.execall = execall; //# sourceMappingURL=parse-natspec.js.map