gcanti / docs-ts

A zero-config documentation tool for my TypeScript projects
https://gcanti.github.io/docs-ts/
MIT License
101 stars 17 forks source link

Simplify @example import replacement #35

Closed m-bock closed 3 years ago

m-bock commented 3 years ago

We need to assure many possible import statements are replaced correctly:

As writing out tests manually for all those combinations would be a bit too much. I tried to abstract the tests a bit to reduce boilerplate. Since Jest 26 there is a feature available that works well for this purpose: https://jestjs.io/docs/api#testeachtablename-fn-timeout

For this I had to upgrade Jest and and adjust a few places in the codebase to make the tests work with the new version.

Finally the actual implementation of the replacement logic is a single regex and one replacement call.

IMax153 commented 3 years ago

This PR LGTM at this point, I would just like @gcanti to review prior to merging since we are resolving a bug here.

IMax153 commented 3 years ago

Thanks @thought2, @gcanti, and @gillchristian! PR is merged 👍

gcanti commented 3 years ago

Released, thank you 👍

m-bock commented 3 years ago

nice! And thanks for the invite to collaborate!