|
1 |
- {"version":3,"sources":["index.js"],"names":["Object","defineProperty","exports","value","util_1","require","block_parser_1","source_parser_1","spec_parser_1","tag_1","type_1","name_1","description_1","getParser","startLine","fence","spacing","tokenizers","default","Error","parseSource","parseBlock","parseSpec","joinDescription","getJoiner","notEmpty","line","tokens","description","trim","source","blocks","splitLines","lines","find","undefined","sections","specs","slice","map","push","tags","problems","reduce","acc","spec","concat"],"mappings":"AAAA;;AACAA,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;;AACA,MAAMC,MAAM,GAAGC,OAAH,eAAZ;;AACA,MAAMC,cAAc,GAAGD,OAAH,sBAApB;;AACA,MAAME,eAAe,GAAGF,OAAH,uBAArB;;AACA,MAAMG,aAAa,GAAGH,OAAH,qBAAnB;;AACA,MAAMI,KAAK,GAAGJ,OAAH,wBAAX;;AACA,MAAMK,MAAM,GAAGL,OAAH,yBAAZ;;AACA,MAAMM,MAAM,GAAGN,OAAH,yBAAZ;;AACA,MAAMO,aAAa,GAAGP,OAAH,gCAAnB;;AACA,SAASQ,SAAT,CAAmB;AAAEC,EAAAA,SAAS,GAAG,CAAd;AAAiBC,EAAAA,KAAK,GAAG,KAAzB;AAAgCC,EAAAA,OAAO,GAAG,SAA1C;AAAqDC,EAAAA,UAAU,GAAG,CACjFR,KAAK,CAACS,OAAN,EADiF,EAEjFR,MAAM,CAACQ,OAAP,CAAeF,OAAf,CAFiF,EAGjFL,MAAM,CAACO,OAAP,EAHiF,EAIjFN,aAAa,CAACM,OAAd,CAAsBF,OAAtB,CAJiF;AAAlE,IAKZ,EALP,EAKW;AACP,MAAIF,SAAS,GAAG,CAAZ,IAAiBA,SAAS,GAAG,CAAZ,GAAgB,CAArC,EACI,MAAM,IAAIK,KAAJ,CAAU,mBAAV,CAAN;AACJ,QAAMC,WAAW,GAAGb,eAAe,CAACW,OAAhB,CAAwB;AAAEJ,IAAAA;AAAF,GAAx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ent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst util_1 = require(\"../util\");\nconst block_parser_1 = require(\"./block-parser\");\nconst source_parser_1 = require(\"./source-parser\");\nconst spec_parser_1 = require(\"./spec-parser\");\nconst tag_1 = require(\"./tokenizers/tag\");\nconst type_1 = require(\"./tokenizers/type\");\nconst name_1 = require(\"./tokenizers/name\");\nconst description_1 = require(\"./tokenizers/description\");\nfunction getParser({ startLine = 0, fence = '```', spacing = 'compact', tokenizers = [\n tag_1.default(),\n type_1.default(spacing),\n name_1.default(),\n description_1.default(spacing),\n], } = {}) {\n if (startLine < 0 || startLine % 1 > 0)\n throw new Error('Invalid startLine');\n const parseSource = source_parser_1.default({ startLine });\n const parseBlock = block_parser_1.default({ fence });\n const parseSpec = spec_parser_1.default({ tokenizers });\n const joinDescription = description_1.getJoiner(spacing);\n const notEmpty = (line) => line.tokens.description.trim() != '';\n return function (source) {\n const blocks = [];\n for (const line of util_1.splitLines(source)) {\n const lines = parseSource(line);\n if (lines === null)\n continue;\n if (lines.find(notEmpty) === undefined)\n continue;\n const sections = parseBlock(lines);\n const specs = sections.slice(1).map(parseSpec);\n blocks.push({\n description: joinDescription(sections[0]),\n tags: specs,\n source: lines,\n problems: specs.reduce((acc, spec) => acc.concat(spec.problems), []),\n });\n }\n return blocks;\n };\n}\nexports.default = getParser;\n"],"file":"index.cjs"}
|