-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
feat: Generate JSON file with TypeDoc #207
Conversation
✔️ Deploy Preview for vigilant-wescoff-04e480 ready! 🔨 Explore the source changes: dcad3ac 🔍 Inspect the deploy log: https://app.netlify.com/sites/vigilant-wescoff-04e480/deploys/61e61f54a819b20007c59a94 😎 Browse the preview: https://deploy-preview-207--vigilant-wescoff-04e480.netlify.app |
import { Address } from '@faker-js/faker';
const cityName = Address.city(); It's sadly not that simple Lines 97 to 114 in a973ee1
Here you can see that city is relying on definitions and the datetype module. Line 332 in a973ee1
Also modules like e.g. Beside that it would break the whole projects compatibility. So we cannot work on that before v7 or later. For now we should try to find another way to generate docs out of the existing code. I will test this out a bit later this day. |
We already export the global Faker instance. export const faker: Faker = new Faker({
locales: require('./locales'),
});
export const address = faker.address;
[...] Not sure how useful that is though. |
Added a plugin to generate the documentation in markdown. For now I generate it under There is a VuePress plugin available to integrate all this with VuePress, but sadly VitePress doesn't support plugins the same way, they integrated plugins in "themes". I am really not familiar with those projects so can't really help with that. So we have 2 solutions I guess:
|
I (personally) would like to choose the hard / second way here, because we would like to bring and push VitePress and the Vite ecosystem forward. All the problems we now find will help potentially thousands other devs to not have these issues in the future. |
I already opened an issue here to see if we can contribute to @tgreyuk repo so more people will profit from this. So far, I was able to integrate some of the generated |
@@ -45,7 +45,8 @@ | |||
"format": "prettier --write .", | |||
"lint": "echo 'TODO eslint'", | |||
"test": "vitest", | |||
"coverage": "vitest --coverage" | |||
"coverage": "vitest --coverage", | |||
"typedoc": "npx esno scripts/typedoc.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave out the npx
"typedoc": "npx esno scripts/typedoc.ts" | |
"typedoc": "esno scripts/typedoc.ts" |
@@ -78,13 +79,18 @@ | |||
"prettier": "2.5.1", | |||
"simple-git-hooks": "~2.7.0", | |||
"through2": "2.0.0", | |||
"ts-node": "^10.4.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use esno
"ts-node": "^10.4.0", |
"typedoc": "^0.22.11", | ||
"typedoc-plugin-markdown": "^3.11.12", | ||
"typedoc-plugin-missing-exports": "^0.22.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For safetyness we should use ~
ranges
"typedoc": "^0.22.11", | |
"typedoc-plugin-markdown": "^3.11.12", | |
"typedoc-plugin-missing-exports": "^0.22.6", | |
"typedoc": "~0.22.11", | |
"typedoc-plugin-markdown": "~3.11.12", | |
"typedoc-plugin-missing-exports": "~0.22.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After you have done this, you need to regenerate the pnpm-lock.yaml
and commit it
It's also a good idea to rm -Rf node_modules pnpm-lock.yaml
before using pnpm install
to really generate a fresh lock file
"typescript": "~4.5.4", | ||
"vinyl-buffer": "^1.0.1", | ||
"vinyl-source-stream": "^2.0.0", | ||
"vinyl-transform": "^1.0.0", | ||
"vite": "~2.7.13", | ||
"vitepress": "^0.21.4", | ||
"vitest": "~0.1.24" | ||
"vitest": "~0.1.24", | ||
"vuepress-plugin-typedoc": "^0.10.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will not work with vitepress?
As you wrote in the comments, we may need to come up with something on our own or find an equivalent
Or just automate the files our self
Maybe talk to @ST-DDT, he is doing currently really nice automation scripts 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, just tell me what needs to be automated.
I continued this PR in #289. |
This can be closed and will continue here: #289 |
I rebased from main as the other branch was too far behind and also because in the meantime I deleted it from my fork to have a clean fork.
Now, here's the catch:
TypeDoc generates documentation only from directly exported types from the entrypoint:
TypeStrong/typedoc#1657
So our sub-classes, like
Address
, are not included in the documentation except if they are exported fromindex.ts
. Not sure if this is desirable.There are workarounds, but I did not try that yet: https://github.com/Gerrit0/typedoc-plugin-missing-exports
As in
Faker
we instantiate all those sub-classes:We could imagine exporting these instances, so ideally we could then access them doing:
This is up for discussion.