alexprey / sveltedoc-parser

Generate a JSON documentation for a Svelte (https://github.com/sveltejs/svelte) component
https://www.npmjs.com/package/sveltedoc-parser
MIT License
90 stars 7 forks source link

Support external refereferences for event parsing #48

Open alexprey opened 3 years ago

alexprey commented 3 years ago

Actually the following code returns ****undefined-event**** for dispatched event.

import { EVENT } from 'shared/events';
dispatch(EVENT.MODAL.CLOSE);

This issue is not key goal of the library, but it will be good if we can solve that.

I propose to implement special API to resolve event name in this case. We can implement two-leveled API:

FileResolve API

/**
 * @param importPath import path from js file that should be resolved
 * @return content of the target file
 */
function resolve(importPath: string): string;

IdentifierEvaluator API

/**
 * Resolve JS part related to identifier of event to constant string.
 * TBD
 */
function resolve(identifier): string;

Let's discuss that