Generating documentation (e.g. JsDoc comments) in JS from KDoc

I’m trying to build a JavaScript library (jscommon) with Kotlin. The resulting library has no documentation (such as JSDOC) which means the users of the library will get no information or auto-complete from their IDE, not even which type of arguments they should pass to the functions. This will make the library very difficult to use.
Is there a way to make the compiler generate such documentation?

Thank you!

1 Like

Any solution yet for this?

Sadly, no.
Here is a post describing what I intended to do and how I got around it (spoiler: I generated a .d.ts file using reflection. It includes only the signatures though): Create a library that compiles to NPM and Jar with Kotlin Multiplatform

1 Like

Thanks, I found your article while looking for a solution but it doesn’t explain how you created the definitions file because the solution was too specific. Can you share more details? Did you use something like ts-generator?

I didn’t use anything special, just printed text to a text file. the .d.ts format is very simple.
The “very specific” part here, is that my script wouldn’t run on every arbitrary script, but focuses on the specific known project structure. You can see the code in the commits history.
I guess that a more generic solution may be found. It was too much time for the task I was working on, however.