glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
12.31k stars 1.07k forks source link

[FEATURE]: xml2typescript using quicktype ( doxygen XLST into typescript definitions) #2630

Open studentutu opened 3 months ago

studentutu commented 3 months ago

XML is widely used for documentation for projects ( doxygen or other auto-documented solutions) They all rely on the same XML schema with different member types, etc.

It would be beneficial to extend the functionality of typescript and add support for the generation of typescript definitions from XML directory ( main index.xml and referenced XML files).

The exact issue and proposal is described here: https://github.com/opencv/opencv/issues/15306

Context (Input, Language)

Doxygen generates XML using the following XML/XSLT, example of generated XML see here https://github.com/studentutu/opencv-wasm-node/tree/master/utils/doxygen_generated_docs .

Input Format: doxygen XML (XSLT) Output Language: typescript definitions

Description

When generating opencv_wasm with specific libraries, we build cpp sources using main cmake, which output target cpp javascript project, built by emscripten with a specified flag.

Currently, each time we rebuild opencv_wasm with different flags, there is no types for typescript generated, all we can do is to look into generated doxygen documentation. We need a strong type for Opencv based on the build target and flags. This will massively benefit OpenCV community and not only, as Doxygen is a very popular tool to generate docs for cpp\older and newer projects.

Current Behaviour / Output

There is an obsolete repo with npm from contributors of DefinitelyTyped for manual type definitions (types/opencvts). But it is obsolete and not suitable for wasm configuration ( or any different configuration), as we need to rebuild opencv from cpp sources directly, which limits opencv_wasm API severely, which is expected and Doxygen provides all the generated API. It is a global issue of missing types for opencv, but thankfully we can always build Doxygen docs.

Currently, we have an alternative - to just see which API available by using the Object.Keys - see here https://github.com/studentutu/opencv-wasm-node/blob/master/utils/generateCvProps.js This however is almost useless, as we always need to pass arguments, which are unknown and we still need to look them up in Doxygen docs.

Proposed Behaviour / Output

Using quicktype we can generate folder of typescript definition from generated doxygen XML folder. Doxygen XML folder contains all of the Doxygen XML schema, which is always consists of compound.xsd, index.xsd and index.xml which have links to all other components ( types).

Solution

Add support to reading Doxygen XML and generating typescript definition folder

Context

The exact issue and proposal is described here: https://github.com/opencv/opencv/issues/15306