(babel)
| 353 | }; |
| 354 | let docs = ``; |
| 355 | const plugin = function (babel) { |
| 356 | const t = babel.types; |
| 357 | const moduleExports = t.memberExpression(t.identifier('module'), t.identifier('exports')); |
| 358 | return { |
| 359 | visitor: { |
| 360 | ImportDeclaration: function (path) { |
| 361 | path.remove(); |
| 362 | }, |
| 363 | Program: function (path) { |
| 364 | // Inject the parser's loader |
| 365 | path.unshiftContainer('body', makeRequire('parsers', './parsers', t)); |
| 366 | }, |
| 367 | ExportDeclaration: function (path) { |
| 368 | // Export declaration on an interface |
| 369 | if ( |
| 370 | path.node && |
| 371 | path.node.declaration && |
| 372 | path.node.declaration.type == 'InterfaceDeclaration' |
| 373 | ) { |
| 374 | const { results, comments } = inject(t, doInterface(path.node.declaration)); |
| 375 | const id = path.node.declaration.id.name; |
| 376 | const exports = t.memberExpression(moduleExports, t.identifier(id)); |
| 377 | docs += `/**\n * @interface ${id}\n${comments} */\n\n`; |
| 378 | path.replaceWith(t.assignmentExpression('=', exports, t.objectExpression(results))); |
| 379 | } |
| 380 | }, |
| 381 | }, |
| 382 | }; |
| 383 | }; |
| 384 | |
| 385 | const auxiliaryCommentBefore = ` |
| 386 | **** GENERATED CODE **** |
nothing calls this directly
no test coverage detected
searching dependent graphs…