ScriptableMC-Engine icon indicating copy to clipboard operation
ScriptableMC-Engine copied to clipboard

TypeScriptLibraryExporter documentation support

Open astorks opened this issue 5 years ago • 7 comments

Since we have access to the bukkit JavaDocs we should be able to generate documentation comments automatically. Need to research more.

astorks avatar Jan 23 '20 02:01 astorks

https://github.com/paul-hammant/paranamer

astorks avatar Jan 24 '20 06:01 astorks

https://github.com/paul-hammant/paranamer

Paranamer is now implemented to help with some parameter names. Although full documentation would be nice at least for the bukkit api.

https://github.com/javaparser/javaparser

astorks avatar Jan 25 '20 06:01 astorks

I have a Bukkit API ts declaration already. Partially auto-generated.

https://github.com/Magikcraft/scriptcraft-types

It’s on npm as well.

I think it also contains the ScriptCraft API typings too, which you won’t want if you are not using ScriptCraft.

I have a npm module loading require implementation as well, which is a patch on Walter’s require implementation. It’s in @Magikcraft/MagikCraft in the SMA/js folder.

jwulf avatar Feb 23 '20 01:02 jwulf

I’ll dig out the generation code. It works by scraping the bukkit api docs and doing a ghetto transform to TS (Non-AST aware text tansform). Gets about 90% of the way there. The other 10%, plus crawling the site is manual, but we can probably fix that up.

jwulf avatar Feb 23 '20 01:02 jwulf

I'm actually already generating a typescript library via java reflection. I'm just thinking about using the javadocs support to help comment the typescript code better.

I'd definitely be interested in the generation code though as it may help with parsing the java docs. Thanks

astorks avatar Feb 23 '20 03:02 astorks

No kidding straight outta the ghetto:

https://github.com/jwulf/bukkit-api-scraper/blob/master/index.ts

jwulf avatar Feb 24 '20 19:02 jwulf

haha, all good. Thanks, I'm sure mine isn't too much better currently:

https://github.com/astorks/ScriptableMC-Engine/blob/dev/ScriptableMC-Tools-TS/src/main/kotlin/com/pixlfox/scriptablemc/TypescriptLibraryExporter.kt

Being able to pull reflection data directly from the jar is nice though, I just wish argument names where saved properly in the java bytecode instead of arg0, arg1.... That's why I'm looking into the javadocs as well as code comments.

Anyway I'm thinking about cleaning it up and making it a standalone project so you could just set up a build script and pass the spigot api jar and any additional jars and it would generate a typescript project.

astorks avatar Feb 24 '20 19:02 astorks