type-fest icon indicating copy to clipboard operation
type-fest copied to clipboard

Proposal: `readme.md` builder with examples links to TS Playground

Open skarab42 opened this issue 2 years ago • 5 comments

Following the hint made by @fregante in #428, I propose a readme generator for the API part.

@sindresorhus I did a POC and you can see the generated readme there.

To generate the markdown I use the TS compiler so no additional dependencies to get the summaries, tags and examples, the only library that is added is lz-string which is the same one that is used by the TS Playground to generate the share links.

In addition to generating the links for the examples, this would allow us to not worry about adding new types to the readme and always have a version that matches the code.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

skarab42 avatar Aug 31 '22 10:08 skarab42

@sindresorhus Any thoughts on this?

skarab42 avatar Sep 29 '22 06:09 skarab42

I think it's a great idea 👍

  1. I didn't check, but it would be nice if a type could appear in multiple categories if it has multiple categories defined.
  2. You need to ensure that all the types sources use the description from the readme.
  3. source | example should be capitalized
  4. Categories: => Categories
  5. Is it really useful to show the type count in the categories section? Feels like noise to me.
  6. We should remove the Template literal category. It was only there previously because we had to document them as only supporting the new TS version.

sindresorhus avatar Sep 29 '22 08:09 sindresorhus

@sindresorhus https://github.com/tommy-mitchell/type-fest/tree/feat-readme-builder

I've been working on expanding this, converting the scripts to TypeScript and using liquidjs for the readme template. I've also added eslint-formatter-pretty for formatting warnings while generating the readme:

image

Thoughts? Haven't changed anything with the type categories or added missing examples/summaries, etc.

tommy-mitchell avatar Aug 14 '23 00:08 tommy-mitchell

@tommy-mitchell Looks great 👍

Nitpick: I would make it TS Playground => Playground

sindresorhus avatar Aug 14 '23 13:08 sindresorhus

The code in the inline examples are missing indentation:

Screenshot 2023-08-14 at 15 17 03

sindresorhus avatar Aug 14 '23 13:08 sindresorhus