-
Notifications
You must be signed in to change notification settings - Fork 419
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
docs: add documentation generation #857
Conversation
Your website rocks, and so do you. Thank you so much! We'll have a closer look beginning of next week. |
Some things I found having a shallow look:
|
|
@nikku I did look into this, and I'm finding that it's not possible currently with the way things work. From what I understand, you use your library It doesn't appear that Another alternative would be to use Edit: one more option could be to write a TypeDoc plugin that rewrites the source links then have the link originally point to the .d.ts as if it existed on GitHub (possible via the typedoc config):
I don't see any way to dynamically transform the link (like replacing Edit 2: I created a TypeDoc plugin that links to the GitHub source JavaScript files
With that the docs say @nikku if you like this approach I can add this plugin to the PR. |
@nikku I believe this is because the Edit: also looking further into this, I see the type ModuleDeclaration = import('didi').ModuleDeclaration; As this symbol is not exported, it does not get included in the documentation. Having
If I manually edit the generated /**
* The [didi](https://github.com/nikku/didi) module declaration type.
*/
export type ModuleDeclaration = import('didi').ModuleDeclaration; Then the docs show this: |
I'm not sure what you mean. In the example you provided above, it seems that the link resolution works as follows:
|
Thanks for your follow-ups on this topic. Find some comments attached:
This is my thinking, too. We could do some magic at some point to find back-references to the source code from type definitions. Not impossible, but also not a priority today. Types are strictly validated and non-ambiguous, hence it makes sense to use them as a baseline.
We indeed don't add sourcemaps as you indicated, but it should be possible to add them, linking back to the source code from a type declaration file.
I think we could park this item for now, as generating types with sourcemap sounds like the better solution to me. |
Regarding generation of external API references:
I'm not sure it would help, as just me getting to the |
Point taken, I think it works as expected. Unrelated to this the file is another showcase for how we need to export all types declared (and used), or we'll not get proper documentation for them (#857 (comment), #857 (comment)): |
To summarize what I learned through your investigations:
|
I did some more investigation on
This is something we could accomplish, as the bio-dts foundations support it out of the box.
It is actually worse than this. In fact we'd need to export all transitive types, which is completely unreasonable for larger libraries. Typescript itself, when generating types, does not export transitive types either. Typescript offers a clear contract: Everything that is exposed as public API, and hintable in a code editor shall also be documented. The assumptions that
There exists a plug-in for that, but it only works if external documentation is typedoc, too. Needs to be further assessed (probably simply build our own docs generator). |
Declaration maps are possible, in theory. In practice it takes some work for sources to be properly mapped through our pipeline. |
@joeskeen Thanks again for your work on this topic. We'll close this PR for now as it is not ready to be incorporated; we may use it as a future reference once we tackle documentation generation ourselves, probably by writing our own tool. What we did in the mean time is to invest into advanced typing, cf. bpmn-io/bpmn-js#2153, inside your editor 🤩. |
This PR takes all the awesome code documentation available in JSDoc/TSDoc comments throughout the code base and generates a documentation static site from it using the TypeDoc command-line tool.
A few helpful commands have been added to
package.json
:generate-docs
: Runs TypeDoc and outputs the docs in thedocs
folder (ignored from source control)publish-docs
: Generates the docs, goes into the docs folder, and commits/pushes the docs up to thegh-pages
branch of the repository (by default, goes tobpmn-io/diagram-js
, but you can pass another repository in to publish them elsewhere). To test, I ran this withjoeskeen/diagram-js
and it generated the GitHub Pages site at https://joeskeen.github.io/diagram-jsChanges to the actual content of the documentation is out of scope for this PR, just trying to publish all existing API documentation.
Closes #78