(pieces: CodePiece[])
| 183 | } |
| 184 | |
| 185 | function linkPieces(pieces: CodePiece[]): string { |
| 186 | const tagsPieces = pieces.filter((p) => p.type === PIECE_TYPE.TAG); |
| 187 | if (tagsPieces.length !== 1) { |
| 188 | throw new CodeGeneratorError('Only one tag definition required', tagsPieces); |
| 189 | } |
| 190 | const tagName = tagsPieces[0].value; |
| 191 | |
| 192 | const beforeParts = pieces |
| 193 | .filter((p) => p.type === PIECE_TYPE.BEFORE) |
| 194 | .map((p) => p.value) |
| 195 | .join(''); |
| 196 | |
| 197 | const afterParts = pieces |
| 198 | .filter((p) => p.type === PIECE_TYPE.AFTER) |
| 199 | .map((p) => p.value) |
| 200 | .join(''); |
| 201 | |
| 202 | const childrenParts = pieces |
| 203 | .filter((p) => p.type === PIECE_TYPE.CHILDREN) |
| 204 | .map((p) => p.value) |
| 205 | .join(''); |
| 206 | |
| 207 | let attrsParts = pieces |
| 208 | .filter((p) => p.type === PIECE_TYPE.ATTR) |
| 209 | .map((p) => p.value) |
| 210 | .join(' '); |
| 211 | |
| 212 | attrsParts = attrsParts ? ` ${attrsParts}` : ''; |
| 213 | |
| 214 | if (childrenParts) { |
| 215 | return `${beforeParts}<${tagName}${attrsParts}>${childrenParts}</${tagName}>${afterParts}`; |
| 216 | } |
| 217 | |
| 218 | return `${beforeParts}<${tagName}${attrsParts} />${afterParts}`; |
| 219 | } |
| 220 | |
| 221 | function generateNodeSchema( |
| 222 | nodeItem: IPublicTypeNodeSchema, |
no test coverage detected
searching dependent graphs…