Skip to content

Adding filePath to parser results #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2021

Conversation

fforres
Copy link
Contributor

@fforres fforres commented Apr 30, 2021

The parser is able to analyze and return multiple exported components per module/file.

Once we parse multiple files on a single run (reactDocgenTS.parse(arrayOfFiles)) it is non trivial to parse what module a component corresponds to.

In our case, we want to use the filePath to extract some data on the file context (git, projects, etc) to enrich the data returned by the parser.

Worked around this initially by setting a custom componentNameResolver that returns the name and the filename instead of a string (And then updating some types), but it's not ideal, or a future-safe idea for the matter)

{....}
componentNameResolver: (exp, source) => {
  	const name = getComponentName(exp, source)
	return { name, fileName: source.fileName }
}
{....}

@fforres fforres marked this pull request as ready for review April 30, 2021 01:25
@fforres
Copy link
Contributor Author

fforres commented Apr 30, 2021

cc @pvasek or @brianconnoly for a review :)

@fforres fforres changed the title Adding path to return type Adding filePath to parser results Apr 30, 2021
@pvasek
Copy link
Collaborator

pvasek commented May 5, 2021

@fforres Thanks for your PR. It seems reasonable to add it but could you cover it with unit tests?

@fforres
Copy link
Contributor Author

fforres commented May 5, 2021

Hi @pvasek will do, and update here as soon as I do :)
Great project btw :D

@fforres
Copy link
Contributor Author

fforres commented May 28, 2021

Updated with some tests @pvasek :)
Sorry it took me some time, things have been hectic

@pvasek
Copy link
Collaborator

pvasek commented May 31, 2021

@fforres no worries. Sorry, I didn't notice before but could you exclude yarn.lock file from the PR? We don't use yarn here.

@fforres
Copy link
Contributor Author

fforres commented May 31, 2021

Oh shoot! 🤦‍♂️

@fforres
Copy link
Contributor Author

fforres commented May 31, 2021

I'm not near a computer, but I'll get it done ASAP :)

@fforres
Copy link
Contributor Author

fforres commented Jun 7, 2021

Updated @pvasek

@pvasek pvasek merged commit 33a1ab6 into styleguidist:master Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants