@gtkx/codegen 1.0.0-rc.1 → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysis/descriptor-render.d.ts +20 -11
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +296 -152
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +37 -34
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +34 -30
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +16 -16
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +139 -84
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +14 -13
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +104 -53
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +6 -5
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +71 -29
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.d.ts +5 -5
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +70 -63
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +12 -11
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +192 -123
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts +6 -9
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +69 -133
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/pipeline.d.ts +10 -7
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +81 -53
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +21 -19
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +80 -71
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +6 -6
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +126 -84
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +29 -5
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +69 -13
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +18 -0
- package/dist/gi.d.ts.map +1 -0
- package/dist/gi.js +23 -0
- package/dist/gi.js.map +1 -0
- package/dist/gir/ancestry.d.ts +4 -3
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +12 -15
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/callback.d.ts +6 -11
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +6 -7
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +7 -5
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +14 -12
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +3 -3
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +7 -6
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +8 -3
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +30 -7
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +6 -3
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +23 -7
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +2 -1
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +26 -10
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +5 -3
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +41 -28
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/library.d.ts +17 -11
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +116 -92
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +10 -10
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +21 -20
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/nullable-overrides.d.ts +3 -0
- package/dist/gir/nullable-overrides.d.ts.map +1 -0
- package/dist/gir/nullable-overrides.js +5 -0
- package/dist/gir/nullable-overrides.js.map +1 -0
- package/dist/gir/parameter.d.ts +14 -12
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +27 -18
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +12 -13
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +50 -40
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +5 -4
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +4 -3
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +5 -4
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +10 -9
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +5 -4
- package/dist/gir/record.d.ts.map +1 -1
- package/dist/gir/record.js +13 -12
- package/dist/gir/record.js.map +1 -1
- package/dist/gir/size.d.ts +6 -5
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +49 -47
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +17 -15
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +5 -1
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.d.ts +3 -2
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +36 -25
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +3 -2
- package/dist/gir/type.d.ts.map +1 -1
- package/dist/gir/type.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts +28 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +44 -0
- package/dist/jsx.js.map +1 -0
- package/dist/khronos/args.d.ts +7 -7
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +88 -67
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/jsdoc.d.ts +4 -4
- package/dist/khronos/jsdoc.d.ts.map +1 -1
- package/dist/khronos/jsdoc.js +29 -16
- package/dist/khronos/jsdoc.js.map +1 -1
- package/dist/khronos/model.d.ts +8 -7
- package/dist/khronos/model.d.ts.map +1 -1
- package/dist/khronos/model.js +94 -59
- package/dist/khronos/model.js.map +1 -1
- package/dist/khronos/modules.d.ts +4 -3
- package/dist/khronos/modules.d.ts.map +1 -1
- package/dist/khronos/modules.js +40 -25
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/param-pair.d.ts +11 -0
- package/dist/khronos/param-pair.d.ts.map +1 -0
- package/dist/khronos/param-pair.js +6 -0
- package/dist/khronos/param-pair.js.map +1 -0
- package/dist/khronos/parse.d.ts +7 -8
- package/dist/khronos/parse.d.ts.map +1 -1
- package/dist/khronos/parse.js +17 -16
- package/dist/khronos/parse.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +4 -4
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +97 -56
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +11 -10
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +109 -45
- package/dist/khronos/plan.js.map +1 -1
- package/dist/khronos/render.d.ts +5 -4
- package/dist/khronos/render.d.ts.map +1 -1
- package/dist/khronos/render.js +106 -59
- package/dist/khronos/render.js.map +1 -1
- package/dist/khronos/select.d.ts +4 -4
- package/dist/khronos/select.d.ts.map +1 -1
- package/dist/khronos/select.js +30 -19
- package/dist/khronos/select.js.map +1 -1
- package/dist/react/element-config.d.ts +20 -0
- package/dist/react/element-config.d.ts.map +1 -0
- package/dist/react/element-config.js +64 -0
- package/dist/react/element-config.js.map +1 -0
- package/dist/runner.d.ts +19 -10
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +48 -43
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +5 -3
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +24 -22
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/async.d.ts +2 -1
- package/dist/store/gi/async.d.ts.map +1 -1
- package/dist/store/gi/async.js +28 -24
- package/dist/store/gi/async.js.map +1 -1
- package/dist/store/gi/callables.d.ts +26 -20
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +157 -100
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts +3 -2
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +6 -3
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class.d.ts +2 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +86 -47
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/companion.d.ts +2 -1
- package/dist/store/gi/companion.d.ts.map +1 -1
- package/dist/store/gi/companion.js +8 -5
- package/dist/store/gi/companion.js.map +1 -1
- package/dist/store/gi/constant.d.ts +3 -2
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +25 -8
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/constructor-props.d.ts +3 -2
- package/dist/store/gi/constructor-props.d.ts.map +1 -1
- package/dist/store/gi/constructor-props.js +17 -10
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/enum.d.ts +3 -2
- package/dist/store/gi/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +14 -11
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts +5 -4
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +48 -23
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts +4 -4
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +15 -11
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.d.ts +2 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +36 -18
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/item-comparators.d.ts +3 -2
- package/dist/store/gi/item-comparators.d.ts.map +1 -1
- package/dist/store/gi/item-comparators.js +33 -21
- package/dist/store/gi/item-comparators.js.map +1 -1
- package/dist/store/gi/method.d.ts +13 -13
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +188 -130
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +7 -6
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +26 -13
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts +2 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +38 -23
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts +2 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +6 -4
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +11 -10
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +86 -60
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts +3 -2
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +40 -28
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +9 -8
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +187 -99
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +6 -5
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +75 -39
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts +2 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +15 -16
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +3 -3
- package/dist/store/gi/registration.d.ts.map +1 -1
- package/dist/store/gi/registration.js +3 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +2 -2
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +43 -22
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/runtime-override.d.ts +2 -1
- package/dist/store/gi/runtime-override.d.ts.map +1 -1
- package/dist/store/gi/runtime-override.js +6 -3
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.d.ts +3 -2
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +113 -66
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +15 -0
- package/dist/store/gi/value-marshalable.d.ts.map +1 -0
- package/dist/store/gi/value-marshalable.js +66 -0
- package/dist/store/gi/value-marshalable.js.map +1 -0
- package/dist/store/gi/vtable.d.ts +2 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +60 -30
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +5 -4
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +4 -2
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +23 -0
- package/dist/store/jsx/element-components.d.ts.map +1 -0
- package/dist/store/jsx/element-components.js +86 -0
- package/dist/store/jsx/element-components.js.map +1 -0
- package/dist/store/jsx/element-prop-imports.d.ts +17 -0
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -0
- package/dist/store/jsx/element-prop-imports.js +15 -0
- package/dist/store/jsx/element-prop-imports.js.map +1 -0
- package/dist/store/jsx/element-prop-types.d.ts +10 -0
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -0
- package/dist/store/jsx/element-prop-types.js +41 -0
- package/dist/store/jsx/element-prop-types.js.map +1 -0
- package/dist/store/jsx/gir-index.d.ts +16 -0
- package/dist/store/jsx/gir-index.d.ts.map +1 -0
- package/dist/store/jsx/gir-index.js +33 -0
- package/dist/store/jsx/gir-index.js.map +1 -0
- package/dist/store/jsx/intrinsic-elements.d.ts +26 -0
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -0
- package/dist/store/jsx/intrinsic-elements.js +127 -0
- package/dist/store/jsx/intrinsic-elements.js.map +1 -0
- package/dist/store/{react → jsx}/jsx.d.ts +2 -4
- package/dist/store/jsx/jsx.d.ts.map +1 -0
- package/dist/store/{react → jsx}/jsx.js +110 -71
- package/dist/store/jsx/jsx.js.map +1 -0
- package/dist/store/jsx/metadata.d.ts +4 -0
- package/dist/store/jsx/metadata.d.ts.map +1 -0
- package/dist/store/{react → jsx}/metadata.js +148 -69
- package/dist/store/jsx/metadata.js.map +1 -0
- package/dist/store/jsx/omitted-props.d.ts +10 -0
- package/dist/store/jsx/omitted-props.d.ts.map +1 -0
- package/dist/store/jsx/omitted-props.js +22 -0
- package/dist/store/jsx/omitted-props.js.map +1 -0
- package/dist/store/jsx/pipeline.d.ts +23 -0
- package/dist/store/jsx/pipeline.d.ts.map +1 -0
- package/dist/store/{react → jsx}/pipeline.js +38 -15
- package/dist/store/jsx/pipeline.js.map +1 -0
- package/dist/store/{react → jsx}/props.d.ts +9 -12
- package/dist/store/jsx/props.d.ts.map +1 -0
- package/dist/store/jsx/props.js +153 -0
- package/dist/store/jsx/props.js.map +1 -0
- package/dist/store/jsx-store.d.ts +5 -3
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +4 -1
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +14 -12
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +9 -7
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts +2 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +12 -6
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/doc.d.ts +2 -1
- package/dist/writer/doc.d.ts.map +1 -1
- package/dist/writer/doc.js +13 -7
- package/dist/writer/doc.js.map +1 -1
- package/dist/writer/emit.d.ts +8 -7
- package/dist/writer/emit.d.ts.map +1 -1
- package/dist/writer/emit.js +13 -10
- package/dist/writer/emit.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts +2 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +29 -18
- package/dist/writer/gtk-doc.js.map +1 -1
- package/dist/writer/imports.d.ts +4 -2
- package/dist/writer/imports.d.ts.map +1 -1
- package/dist/writer/imports.js +35 -24
- package/dist/writer/imports.js.map +1 -1
- package/dist/writer/module.d.ts +3 -2
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +16 -9
- package/dist/writer/module.js.map +1 -1
- package/dist/xml.d.ts +4 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +10 -0
- package/dist/xml.js.map +1 -0
- package/overrides/cairo/context.ts.ejs +7 -7
- package/overrides/cairo/matrix.ts.ejs +2 -2
- package/overrides/cairo/recording-surface.ts.ejs +2 -2
- package/overrides/cairo/region.ts.ejs +1 -1
- package/overrides/cairo/scaled-font.ts.ejs +3 -3
- package/package.json +14 -9
- package/src/analysis/descriptor-render.ts +516 -168
- package/src/analysis/descriptor.ts +162 -125
- package/src/analysis/inheritance.ts +286 -98
- package/src/analysis/param-structure.ts +188 -57
- package/src/analysis/ts-type.ts +113 -34
- package/src/compile.ts +103 -76
- package/src/docs/api-reference.ts +337 -146
- package/src/docs/element-page.ts +137 -150
- package/src/docs/pipeline.ts +135 -73
- package/src/docs/render.ts +151 -87
- package/src/docs/symbol-page.ts +268 -123
- package/src/fingerprint.ts +138 -26
- package/src/gi.ts +35 -0
- package/src/gir/ancestry.ts +26 -14
- package/src/gir/callback.ts +10 -15
- package/src/gir/class.ts +20 -16
- package/src/gir/enum.ts +9 -7
- package/src/gir/field.ts +37 -8
- package/src/gir/function.ts +33 -9
- package/src/gir/gir-path.ts +36 -12
- package/src/gir/libraries.ts +59 -33
- package/src/gir/library.ts +200 -97
- package/src/gir/namespace.ts +42 -26
- package/src/gir/nullable-overrides.ts +5 -0
- package/src/gir/parameter.ts +80 -42
- package/src/gir/parse.ts +102 -47
- package/src/gir/primitives.ts +25 -23
- package/src/gir/property.ts +13 -11
- package/src/gir/record.ts +16 -14
- package/src/gir/size.ts +91 -58
- package/src/gir/type-id.ts +33 -18
- package/src/gir/type-ref.ts +62 -26
- package/src/gir/type.ts +10 -8
- package/src/index.ts +8 -0
- package/src/jsx.ts +75 -0
- package/src/khronos/args.ts +158 -89
- package/src/khronos/jsdoc.ts +67 -29
- package/src/khronos/model.ts +154 -53
- package/src/khronos/modules.ts +67 -27
- package/src/khronos/param-pair.ts +14 -0
- package/src/khronos/parse.ts +37 -17
- package/src/khronos/pipeline.ts +193 -90
- package/src/khronos/plan.ts +235 -86
- package/src/khronos/render.ts +208 -71
- package/src/khronos/select.ts +48 -18
- package/src/react/element-config.ts +97 -0
- package/src/runner.ts +100 -57
- package/src/store/compile-store.ts +32 -26
- package/src/store/gi/async.ts +48 -21
- package/src/store/gi/callables.ts +339 -136
- package/src/store/gi/callback.ts +13 -4
- package/src/store/gi/class.ts +186 -64
- package/src/store/gi/companion.ts +15 -6
- package/src/store/gi/constant.ts +42 -8
- package/src/store/gi/constructor-props.ts +42 -16
- package/src/store/gi/enum.ts +28 -13
- package/src/store/gi/function.ts +88 -24
- package/src/store/gi/gtype-binding.ts +31 -18
- package/src/store/gi/interface.ts +101 -36
- package/src/store/gi/item-comparators.ts +74 -26
- package/src/store/gi/method.ts +377 -159
- package/src/store/gi/param-marshal.ts +38 -15
- package/src/store/gi/pipeline.ts +72 -22
- package/src/store/gi/properties.ts +16 -5
- package/src/store/gi/property-accessor.ts +192 -84
- package/src/store/gi/record-constructor.ts +70 -33
- package/src/store/gi/record-field-accessor.ts +415 -167
- package/src/store/gi/record-layout.ts +130 -43
- package/src/store/gi/record.ts +29 -15
- package/src/store/gi/registration.ts +15 -9
- package/src/store/gi/return-wrap.ts +71 -23
- package/src/store/gi/runtime-override.ts +13 -3
- package/src/store/gi/signal.ts +244 -104
- package/src/store/gi/value-marshalable.ts +96 -0
- package/src/store/gi/vtable.ts +117 -41
- package/src/store/gi-store.ts +26 -13
- package/src/store/jsx/element-components.ts +152 -0
- package/src/store/jsx/element-prop-imports.ts +24 -0
- package/src/store/jsx/element-prop-types.ts +59 -0
- package/src/store/jsx/gir-index.ts +62 -0
- package/src/store/jsx/intrinsic-elements.ts +253 -0
- package/src/store/{react → jsx}/jsx.ts +213 -99
- package/src/store/jsx/metadata.ts +385 -0
- package/src/store/jsx/omitted-props.ts +32 -0
- package/src/store/jsx/pipeline.ts +148 -0
- package/src/store/jsx/props.ts +262 -0
- package/src/store/jsx-store.ts +15 -3
- package/src/store/store-fs.ts +36 -20
- package/src/writer/context.ts +25 -6
- package/src/writer/doc.ts +19 -5
- package/src/writer/emit.ts +20 -11
- package/src/writer/gtk-doc.ts +48 -21
- package/src/writer/imports.ts +63 -28
- package/src/writer/module.ts +35 -11
- package/src/xml.ts +12 -0
- package/dist/store/gi/class-struct-record.d.ts +0 -9
- package/dist/store/gi/class-struct-record.d.ts.map +0 -1
- package/dist/store/gi/class-struct-record.js +0 -34
- package/dist/store/gi/class-struct-record.js.map +0 -1
- package/dist/store/react/built-ins.d.ts +0 -9
- package/dist/store/react/built-ins.d.ts.map +0 -1
- package/dist/store/react/built-ins.js +0 -226
- package/dist/store/react/built-ins.js.map +0 -1
- package/dist/store/react/element-components.d.ts +0 -15
- package/dist/store/react/element-components.d.ts.map +0 -1
- package/dist/store/react/element-components.js +0 -92
- package/dist/store/react/element-components.js.map +0 -1
- package/dist/store/react/element-prop-types.d.ts +0 -19
- package/dist/store/react/element-prop-types.d.ts.map +0 -1
- package/dist/store/react/element-prop-types.js +0 -244
- package/dist/store/react/element-prop-types.js.map +0 -1
- package/dist/store/react/element-props.d.ts +0 -4
- package/dist/store/react/element-props.d.ts.map +0 -1
- package/dist/store/react/element-props.js +0 -178
- package/dist/store/react/element-props.js.map +0 -1
- package/dist/store/react/gir-index.d.ts +0 -25
- package/dist/store/react/gir-index.d.ts.map +0 -1
- package/dist/store/react/gir-index.js +0 -55
- package/dist/store/react/gir-index.js.map +0 -1
- package/dist/store/react/intrinsic-elements.d.ts +0 -26
- package/dist/store/react/intrinsic-elements.d.ts.map +0 -1
- package/dist/store/react/intrinsic-elements.js +0 -107
- package/dist/store/react/intrinsic-elements.js.map +0 -1
- package/dist/store/react/jsx.d.ts.map +0 -1
- package/dist/store/react/jsx.js.map +0 -1
- package/dist/store/react/metadata.d.ts +0 -4
- package/dist/store/react/metadata.d.ts.map +0 -1
- package/dist/store/react/metadata.js.map +0 -1
- package/dist/store/react/pipeline.d.ts +0 -14
- package/dist/store/react/pipeline.d.ts.map +0 -1
- package/dist/store/react/pipeline.js.map +0 -1
- package/dist/store/react/props.d.ts.map +0 -1
- package/dist/store/react/props.js +0 -133
- package/dist/store/react/props.js.map +0 -1
- package/overrides/gtk/constants.ts.ejs +0 -3
- package/overrides/gtk/index.ts.ejs +0 -2
- package/src/store/gi/class-struct-record.ts +0 -40
- package/src/store/react/built-ins.ts +0 -260
- package/src/store/react/element-components.ts +0 -138
- package/src/store/react/element-prop-types.ts +0 -280
- package/src/store/react/element-props.ts +0 -204
- package/src/store/react/gir-index.ts +0 -85
- package/src/store/react/intrinsic-elements.ts +0 -161
- package/src/store/react/metadata.ts +0 -197
- package/src/store/react/pipeline.ts +0 -90
- package/src/store/react/props.ts +0 -197
package/src/docs/pipeline.ts
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
+
import { sortStringsBy } from "@gtkx/utils";
|
|
1
2
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
|
-
import
|
|
4
|
-
import { sortStringsBy } from "@gtkx/utils";
|
|
5
|
-
import { computeFingerprint, FINGERPRINT_FILENAME, isStoreFresh } from "../fingerprint.js";
|
|
4
|
+
import { computeGiFingerprint, FINGERPRINT_FILENAME, isGiStoreFresh } from "../fingerprint.js";
|
|
6
5
|
import { Library } from "../gir/library.js";
|
|
7
6
|
import { namespaceDirectory } from "../gir/namespace.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { type ElementProps, setElementProps } from "../store/jsx/element-prop-imports.js";
|
|
8
|
+
import { collectIntrinsicElementClasses, type GlibNamedClass } from "../store/jsx/intrinsic-elements.js";
|
|
9
|
+
import { type OmittedProps, setOmittedProps } from "../store/jsx/omitted-props.js";
|
|
10
|
+
import { createElementPageContext, type ElementPageContext, renderElementPage } from "./element-page.js";
|
|
10
11
|
import { elementSlug, firstSentence, namespaceOrder } from "./render.js";
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
type DocsElementLink = {
|
|
13
14
|
text: string;
|
|
14
15
|
link: string;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
type DocsNamespace = {
|
|
18
19
|
name: string;
|
|
19
20
|
directory: string;
|
|
20
21
|
link: string;
|
|
21
22
|
elements: DocsElementLink[];
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
type DocsOptions = {
|
|
25
26
|
libraries: string[];
|
|
26
27
|
girPath: string[];
|
|
27
28
|
outDir: string;
|
|
28
29
|
basePath?: string;
|
|
29
|
-
|
|
30
|
+
props?: ElementProps;
|
|
31
|
+
omitProps?: OmittedProps;
|
|
30
32
|
force?: boolean;
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -34,22 +36,42 @@ type DocsManifest = {
|
|
|
34
36
|
namespaces: DocsNamespace[];
|
|
35
37
|
};
|
|
36
38
|
|
|
39
|
+
type GeneratedDocs = {
|
|
40
|
+
pages: { path: string; content: string }[];
|
|
41
|
+
namespaces: DocsNamespace[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type Page = { path: string; content: string };
|
|
45
|
+
type NamespacePages = { docs: DocsNamespace; pages: Page[] };
|
|
46
|
+
|
|
47
|
+
type DocsResult = {
|
|
48
|
+
regenerated: boolean;
|
|
49
|
+
namespaces: DocsNamespace[];
|
|
50
|
+
};
|
|
51
|
+
|
|
37
52
|
const MANIFEST_FILENAME = "manifest.json";
|
|
38
53
|
|
|
39
54
|
const namespaceIndexPage = (namespace: DocsNamespace, elements: GlibNamedClass[]): string => {
|
|
40
55
|
const rows = elements.map((entry, index) => {
|
|
41
56
|
const link = namespace.elements[index]?.link ?? "";
|
|
42
|
-
const description = firstSentence(entry.klass.doc).replaceAll("|",
|
|
57
|
+
const description = firstSentence(entry.klass.doc).replaceAll("|", String.raw`\|`);
|
|
58
|
+
|
|
43
59
|
return `| [${entry.glibName}](${link}) | ${description} |`;
|
|
44
60
|
});
|
|
61
|
+
|
|
62
|
+
const description =
|
|
63
|
+
`Reference pages for the ${String(namespace.elements.length)} JSX elements in ` +
|
|
64
|
+
`the ${namespace.name} namespace.`;
|
|
65
|
+
|
|
45
66
|
return [
|
|
46
67
|
"---",
|
|
47
|
-
`description: ${JSON.stringify(
|
|
68
|
+
`description: ${JSON.stringify(description)}`,
|
|
48
69
|
"---",
|
|
49
70
|
"",
|
|
50
71
|
`# ${namespace.name} elements`,
|
|
51
72
|
"",
|
|
52
|
-
`Elements in this namespace are imported from \`@gtkx/jsx/${namespace.directory}\`; the matching
|
|
73
|
+
`Elements in this namespace are imported from \`@gtkx/jsx/${namespace.directory}\`; the matching ` +
|
|
74
|
+
`classes, enums, and functions are imported from \`@gtkx/gi/${namespace.directory}\`.`,
|
|
53
75
|
"",
|
|
54
76
|
"| Element | Description |",
|
|
55
77
|
"| --- | --- |",
|
|
@@ -60,21 +82,27 @@ const namespaceIndexPage = (namespace: DocsNamespace, elements: GlibNamedClass[]
|
|
|
60
82
|
|
|
61
83
|
const rootIndexPage = (namespaces: DocsNamespace[], libraries: string[]): string => {
|
|
62
84
|
const rows = namespaces.map(
|
|
63
|
-
(ns) => `| [${ns.name}](${ns.link}) | \`@gtkx/jsx/${ns.directory}\` | ${ns.elements.length} |`,
|
|
85
|
+
(ns) => `| [${ns.name}](${ns.link}) | \`@gtkx/jsx/${ns.directory}\` | ${String(ns.elements.length)} |`,
|
|
64
86
|
);
|
|
87
|
+
|
|
65
88
|
const librariesList = libraries.map((library) => `\`${library}\``).join(", ");
|
|
89
|
+
|
|
66
90
|
return [
|
|
67
91
|
"---",
|
|
68
|
-
|
|
92
|
+
"description: \"Generated reference documentation for every JSX element in this project's GIR libraries.\"",
|
|
69
93
|
"---",
|
|
70
94
|
"",
|
|
71
95
|
"# Element Reference",
|
|
72
96
|
"",
|
|
73
|
-
|
|
97
|
+
"This reference documents every JSX element generated from the GObject-Introspection data for " +
|
|
98
|
+
`${librariesList}, together with the namespaces they pull in. It is produced by \`gtkx docs\` ` +
|
|
99
|
+
"using the same pipeline that generates the `@gtkx/jsx` and `@gtkx/gi` bindings, so every page " +
|
|
100
|
+
"matches the types your editor sees.",
|
|
74
101
|
"",
|
|
75
102
|
"Each element page lists:",
|
|
76
103
|
"",
|
|
77
|
-
"- **Props** derived from GObject properties, plus the element props GTKX adds (such as `children`
|
|
104
|
+
"- **Props** derived from GObject properties, plus the element props GTKX adds (such as `children` " +
|
|
105
|
+
"and named slots), with types, defaults, and upstream documentation.",
|
|
78
106
|
"- **Signals** as `on<Signal>` handler props with their exact handler signatures.",
|
|
79
107
|
"- **Methods** available on the underlying instance through the `ref` prop.",
|
|
80
108
|
"",
|
|
@@ -87,96 +115,130 @@ const rootIndexPage = (namespaces: DocsNamespace[], libraries: string[]): string
|
|
|
87
115
|
].join("\n");
|
|
88
116
|
};
|
|
89
117
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
namespaces: DocsNamespace[];
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const generatePages = (options: DocsOptions, basePath: string, library: Library): GeneratedDocs => {
|
|
96
|
-
const intrinsicElements = collectIntrinsicElementClasses(library);
|
|
118
|
+
const groupElementsByNamespace = (elements: GlibNamedClass[]): Map<string, GlibNamedClass[]> => {
|
|
119
|
+
const byNamespace: Map<string, GlibNamedClass[]> = new Map();
|
|
97
120
|
|
|
98
|
-
const
|
|
99
|
-
for (const entry of intrinsicElements) {
|
|
121
|
+
for (const entry of elements) {
|
|
100
122
|
const list = byNamespace.get(entry.namespace.name) ?? [];
|
|
101
123
|
list.push(entry);
|
|
102
124
|
byNamespace.set(entry.namespace.name, list);
|
|
103
125
|
}
|
|
104
126
|
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
return byNamespace;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const buildElementLinks = (elements: GlibNamedClass[], basePath: string): Map<string, string> => {
|
|
131
|
+
const linkByGlibName: Map<string, string> = new Map();
|
|
132
|
+
|
|
133
|
+
for (const entry of elements) {
|
|
107
134
|
const directory = namespaceDirectory(entry.namespace);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
135
|
+
const link = `${basePath}/${directory}/${elementSlug(entry.klass.name)}`;
|
|
136
|
+
|
|
137
|
+
if (linkByGlibName.values().some((existing) => existing === link)) {
|
|
138
|
+
throw new Error(`Docs page slug collision for ${entry.glibName} at ${link}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
112
141
|
linkByGlibName.set(entry.glibName, link);
|
|
113
142
|
}
|
|
114
143
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
);
|
|
144
|
+
return linkByGlibName;
|
|
145
|
+
};
|
|
118
146
|
|
|
119
|
-
|
|
147
|
+
const namespacePages = (input: {
|
|
148
|
+
name: string;
|
|
149
|
+
elements: GlibNamedClass[];
|
|
150
|
+
basePath: string;
|
|
151
|
+
linkByGlibName: Map<string, string>;
|
|
152
|
+
pageContext: ElementPageContext;
|
|
153
|
+
}): NamespacePages => {
|
|
154
|
+
const { name, elements, basePath, linkByGlibName, pageContext } = input;
|
|
155
|
+
const directory = name.toLowerCase();
|
|
156
|
+
|
|
157
|
+
const docs: DocsNamespace = {
|
|
158
|
+
name,
|
|
159
|
+
directory,
|
|
160
|
+
link: `${basePath}/${directory}/`,
|
|
161
|
+
elements: elements.map((entry) => ({ text: entry.glibName, link: linkByGlibName.get(entry.glibName) ?? "" })),
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const pages: Page[] = elements.map((entry) => ({
|
|
165
|
+
path: `${directory}/${elementSlug(entry.klass.name)}.md`,
|
|
166
|
+
content: renderElementPage(entry, pageContext),
|
|
167
|
+
}));
|
|
168
|
+
|
|
169
|
+
pages.push({ path: `${directory}/index.md`, content: namespaceIndexPage(docs, elements) });
|
|
170
|
+
|
|
171
|
+
return { docs, pages };
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const generatePages = (options: DocsOptions, basePath: string, library: Library): GeneratedDocs => {
|
|
175
|
+
const intrinsicElements = collectIntrinsicElementClasses(library);
|
|
176
|
+
const byNamespace = groupElementsByNamespace(intrinsicElements);
|
|
177
|
+
const linkByGlibName = buildElementLinks(intrinsicElements, basePath);
|
|
178
|
+
const pageContext = createElementPageContext(library, (glibName: string) => linkByGlibName.get(glibName));
|
|
179
|
+
const pages: Page[] = [];
|
|
120
180
|
const namespaces: DocsNamespace[] = [];
|
|
121
|
-
const orderedNames = sortStringsBy(
|
|
181
|
+
const orderedNames = sortStringsBy(byNamespace.keys(), namespaceOrder);
|
|
182
|
+
|
|
122
183
|
for (const name of orderedNames) {
|
|
123
184
|
const elements = sortStringsBy(byNamespace.get(name) ?? [], (entry) => entry.glibName);
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
directory,
|
|
128
|
-
link: `${basePath}/${directory}/`,
|
|
129
|
-
elements: elements.map((entry) => ({
|
|
130
|
-
text: entry.glibName,
|
|
131
|
-
link: linkByGlibName.get(entry.glibName) ?? "",
|
|
132
|
-
})),
|
|
133
|
-
};
|
|
134
|
-
for (const entry of elements) {
|
|
135
|
-
const slug = elementSlug(entry.klass.name);
|
|
136
|
-
pages.push({ path: `${directory}/${slug}.md`, content: renderElementPage(entry, pageContext) });
|
|
137
|
-
}
|
|
138
|
-
pages.push({ path: `${directory}/index.md`, content: namespaceIndexPage(namespaceDocs, elements) });
|
|
139
|
-
namespaces.push(namespaceDocs);
|
|
185
|
+
const result = namespacePages({ name, elements, basePath, linkByGlibName, pageContext });
|
|
186
|
+
pages.push(...result.pages);
|
|
187
|
+
namespaces.push(result.docs);
|
|
140
188
|
}
|
|
189
|
+
|
|
141
190
|
pages.push({ path: "index.md", content: rootIndexPage(namespaces, options.libraries) });
|
|
191
|
+
|
|
142
192
|
return { pages, namespaces };
|
|
143
193
|
};
|
|
144
194
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
195
|
+
const cachedDocsResult = (options: DocsOptions, manifestPath: string): DocsResult | undefined => {
|
|
196
|
+
if (options.force === true || !isGiStoreFresh(options.outDir, options.libraries, options.girPath)) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!existsSync(manifestPath)) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as DocsManifest;
|
|
205
|
+
|
|
206
|
+
return { regenerated: false, namespaces: manifest.namespaces };
|
|
148
207
|
};
|
|
149
208
|
|
|
150
|
-
|
|
209
|
+
const writePages = (outDir: string, pages: Page[]): void => {
|
|
210
|
+
for (const page of pages) {
|
|
211
|
+
const target = join(outDir, page.path);
|
|
212
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
213
|
+
writeFileSync(target, page.content);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const writeDocs = (options: DocsOptions): DocsResult => {
|
|
218
|
+
setElementProps(options.props ?? {});
|
|
219
|
+
setOmittedProps(options.omitProps ?? {});
|
|
151
220
|
const basePath = options.basePath ?? "/reference";
|
|
152
|
-
const elementProps = options.elementProps ?? {};
|
|
153
221
|
const manifestPath = join(options.outDir, MANIFEST_FILENAME);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
222
|
+
const cached = cachedDocsResult(options, manifestPath);
|
|
223
|
+
|
|
224
|
+
if (cached !== undefined) {
|
|
225
|
+
return cached;
|
|
159
226
|
}
|
|
160
227
|
|
|
161
228
|
const library = Library.load(options.libraries, options.girPath);
|
|
162
229
|
const { pages, namespaces } = generatePages(options, basePath, library);
|
|
163
|
-
|
|
164
230
|
rmSync(options.outDir, { recursive: true, force: true });
|
|
165
231
|
mkdirSync(options.outDir, { recursive: true });
|
|
166
|
-
|
|
167
|
-
const target = join(options.outDir, page.path);
|
|
168
|
-
mkdirSync(dirname(target), { recursive: true });
|
|
169
|
-
writeFileSync(target, page.content);
|
|
170
|
-
}
|
|
232
|
+
writePages(options.outDir, pages);
|
|
171
233
|
const manifest: DocsManifest = { namespaces };
|
|
172
234
|
writeFileSync(manifestPath, JSON.stringify(manifest));
|
|
235
|
+
|
|
173
236
|
writeFileSync(
|
|
174
237
|
join(options.outDir, FINGERPRINT_FILENAME),
|
|
175
|
-
JSON.stringify(
|
|
176
|
-
value: computeFingerprint(library.girFiles, options.libraries, elementProps),
|
|
177
|
-
girFiles: library.girFiles,
|
|
178
|
-
libraries: options.libraries,
|
|
179
|
-
}),
|
|
238
|
+
JSON.stringify(computeGiFingerprint(library.girFiles, options.libraries, options.girPath)),
|
|
180
239
|
);
|
|
240
|
+
|
|
181
241
|
return { regenerated: true, namespaces };
|
|
182
242
|
};
|
|
243
|
+
|
|
244
|
+
export { writeDocs, type DocsElementLink, type DocsNamespace, type DocsOptions, type DocsResult };
|
package/src/docs/render.ts
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { collectInheritedMethods, conflictRename } from "../analysis/inheritance.js";
|
|
3
|
-
import { renderHandlerParameters, renderHandlerResultType } from "../analysis/param-structure.js";
|
|
4
|
-
import { renderBaseTypeFor, type TsTypeTarget } from "../analysis/ts-type.js";
|
|
1
|
+
import { pascalCase, sortStringsBy } from "@gtkx/utils";
|
|
5
2
|
import type { GirClass } from "../gir/class.js";
|
|
6
3
|
import type { GirFunction } from "../gir/function.js";
|
|
7
4
|
import type { Library } from "../gir/library.js";
|
|
8
5
|
import type { GirNamespace } from "../gir/namespace.js";
|
|
9
|
-
import type {
|
|
6
|
+
import type { GirCallable } from "../gir/parameter.js";
|
|
10
7
|
import type { TypeId } from "../gir/type-id.js";
|
|
11
|
-
import {
|
|
8
|
+
import { collectInheritedMethods, conflictRename } from "../analysis/inheritance.js";
|
|
9
|
+
import { renderHandlerParameters, renderHandlerResultType } from "../analysis/param-structure.js";
|
|
10
|
+
import { recordTypeTarget, renderBaseType, type TsTypeTarget } from "../analysis/ts-type.js";
|
|
11
|
+
import { dedupeCallables, instanceScope, renderInstanceMethodSignature } from "../store/gi/callables.js";
|
|
12
12
|
import { methodExportName } from "../store/gi/method.js";
|
|
13
13
|
import { ModuleContext } from "../writer/context.js";
|
|
14
14
|
import { gtkDocToMarkdown } from "../writer/gtk-doc.js";
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
type SignatureEntry = {
|
|
17
|
+
name: string;
|
|
18
|
+
signature: string;
|
|
19
|
+
doc: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type OriginSignatureEntry = SignatureEntry & { origin: string | undefined };
|
|
23
|
+
|
|
24
|
+
const DOCS_DEFAULT_VALUES: Record<string, string> = { TRUE: "true", FALSE: "false", NULL: "null" };
|
|
25
|
+
const FENCE_LINE = /^\s*(```|~~~)/;
|
|
26
|
+
const HEADING_LINE = /^#{1,5}\s/;
|
|
27
|
+
const LEADING_NAMESPACES = ["Gtk", "Adw"];
|
|
28
|
+
const DOCS_SIGNATURE_NAMESPACE = "$docs";
|
|
29
|
+
|
|
30
|
+
const docsTarget = (library: Library): TsTypeTarget =>
|
|
31
|
+
recordTypeTarget(
|
|
32
|
+
library,
|
|
33
|
+
(name) => `${name.namespaceName}.${name.typeName}`,
|
|
34
|
+
() => "GObject.Type",
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const renderDocsType = (library: Library, ref: TypeId | undefined, isNullable: boolean): string => {
|
|
38
|
+
const base = renderBaseType(library, docsTarget(library), ref);
|
|
30
39
|
|
|
31
|
-
export const renderDocsType = (library: Library, ref: TypeId | undefined, isNullable: boolean): string => {
|
|
32
|
-
const base = renderBaseTypeFor(library, docsTarget(library), ref);
|
|
33
40
|
return isNullable ? `${base} | null` : base;
|
|
34
41
|
};
|
|
35
42
|
|
|
36
|
-
const renderDocsHandlerResultType = (library: Library, signal:
|
|
43
|
+
const renderDocsHandlerResultType = (library: Library, signal: GirCallable): string =>
|
|
37
44
|
renderHandlerResultType({
|
|
38
45
|
library,
|
|
39
46
|
signal,
|
|
@@ -42,106 +49,127 @@ const renderDocsHandlerResultType = (library: Library, signal: GirSignal): strin
|
|
|
42
49
|
optOut: true,
|
|
43
50
|
});
|
|
44
51
|
|
|
45
|
-
const renderDocsHandlerParameters = (library: Library, signal:
|
|
52
|
+
const renderDocsHandlerParameters = (library: Library, signal: GirCallable): string[] =>
|
|
46
53
|
renderHandlerParameters(signal.parameters, (ref, nullable) => renderDocsType(library, ref, nullable));
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
const renderDocsSignalSignature = (library: Library, signal: GirCallable, selfType: string): string => {
|
|
49
56
|
const params = [...renderDocsHandlerParameters(library, signal), `self: ${selfType}`];
|
|
57
|
+
|
|
50
58
|
return `(${params.join(", ")}) => ${renderDocsHandlerResultType(library, signal)}`;
|
|
51
59
|
};
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
const renderDocsSignalHandlerType = (library: Library, signal: GirCallable): string =>
|
|
54
62
|
`(${renderDocsHandlerParameters(library, signal).join(", ")}) => ${renderDocsHandlerResultType(library, signal)}`;
|
|
55
63
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
export const docsDefaultValue = (value: string): string => DOCS_DEFAULT_VALUES[value] ?? value;
|
|
64
|
+
const docsDefaultValue = (value: string): string => DOCS_DEFAULT_VALUES[value] ?? value;
|
|
59
65
|
|
|
60
66
|
const stripDocMedia = (markdown: string): string =>
|
|
61
67
|
markdown
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
.
|
|
68
|
+
.replaceAll(/<picture[\s\S]*?<\/picture>/g, "")
|
|
69
|
+
.replaceAll(/<video[\s\S]*?(?:<\/video>|\/>)/g, "")
|
|
70
|
+
.replaceAll(/<img[^>]*>/g, "");
|
|
71
|
+
|
|
72
|
+
const demoteLine = (line: string, isInFence: boolean): { text: string; inFence: boolean } => {
|
|
73
|
+
if (FENCE_LINE.test(line)) {
|
|
74
|
+
return { text: line, inFence: !isInFence };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (isInFence) {
|
|
78
|
+
return { text: line, inFence: isInFence };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { text: HEADING_LINE.test(line) ? `#${line}` : line, inFence: isInFence };
|
|
82
|
+
};
|
|
65
83
|
|
|
66
84
|
const demoteHeadings = (markdown: string): string => {
|
|
67
|
-
let
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
.join("\n");
|
|
85
|
+
let isInFence = false;
|
|
86
|
+
const lines: string[] = [];
|
|
87
|
+
|
|
88
|
+
for (const line of markdown.split("\n")) {
|
|
89
|
+
const result = demoteLine(line, isInFence);
|
|
90
|
+
isInFence = result.inFence;
|
|
91
|
+
lines.push(result.text);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return lines.join("\n");
|
|
79
95
|
};
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
const docMarkdown = (doc: string | undefined): string =>
|
|
82
98
|
doc === undefined || doc.length === 0 ? "" : demoteHeadings(stripDocMedia(gtkDocToMarkdown(doc))).trim();
|
|
83
99
|
|
|
84
100
|
const stripMarkdown = (markdown: string): string =>
|
|
85
101
|
markdown
|
|
86
|
-
.
|
|
87
|
-
.
|
|
88
|
-
.
|
|
89
|
-
.
|
|
90
|
-
.
|
|
102
|
+
.replaceAll(/```[\s\S]*?```/g, " ")
|
|
103
|
+
.replaceAll(/`([^`]*)`/g, "$1")
|
|
104
|
+
.replaceAll(/\[([^[\]]*)\]\([^)]*\)/g, "$1")
|
|
105
|
+
.replaceAll(/[*_#>]/g, "")
|
|
106
|
+
.replaceAll(/\s+/g, " ")
|
|
91
107
|
.trim();
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
const firstSentence = (doc: string | undefined): string => {
|
|
94
110
|
const text = stripMarkdown(docMarkdown(doc));
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
|
|
112
|
+
if (text.length === 0) {
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const match = /^.*?[.!?](?=\s|$)/.exec(text);
|
|
97
117
|
const sentence = match?.[0] ?? text;
|
|
118
|
+
|
|
98
119
|
return sentence.length > 220 ? `${sentence.slice(0, 217)}...` : sentence;
|
|
99
120
|
};
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
const elementSlug = (className: string): string =>
|
|
102
123
|
className
|
|
103
|
-
.
|
|
104
|
-
.
|
|
124
|
+
.replaceAll(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
125
|
+
.replaceAll(/([A-Z])(?=[A-Z][a-z])/g, "$1-")
|
|
105
126
|
.toLowerCase();
|
|
106
127
|
|
|
107
|
-
|
|
128
|
+
const implementsLine = (names: string[]): string[] => {
|
|
129
|
+
if (names.length === 0) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const quotedNames = names.map((name) => `\`${name}\``).join(", ");
|
|
134
|
+
|
|
135
|
+
return [`Implements ${quotedNames}.`];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const joinSections = (sections: string[]): string =>
|
|
108
139
|
`${sections.filter((section) => section.length > 0).join("\n\n")}\n`;
|
|
109
140
|
|
|
110
|
-
|
|
141
|
+
const metaBlock = (name: string, meta: string, doc: string): string => {
|
|
111
142
|
const lines = [`### \`${name}\``, "", meta];
|
|
112
|
-
|
|
143
|
+
|
|
144
|
+
if (doc.length > 0) {
|
|
145
|
+
lines.push("", doc);
|
|
146
|
+
}
|
|
147
|
+
|
|
113
148
|
return lines.join("\n");
|
|
114
149
|
};
|
|
115
150
|
|
|
116
|
-
|
|
151
|
+
const signatureBlock = (name: string, signature: string, notes: string[]): string => {
|
|
117
152
|
const lines = [`### \`${name}\``, "", `\`\`\`ts\n${signature}\n\`\`\``];
|
|
153
|
+
|
|
118
154
|
for (const note of notes) {
|
|
119
|
-
if (note.length > 0)
|
|
155
|
+
if (note.length > 0) {
|
|
156
|
+
lines.push("", note);
|
|
157
|
+
}
|
|
120
158
|
}
|
|
159
|
+
|
|
121
160
|
return lines.join("\n");
|
|
122
161
|
};
|
|
123
162
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
export const namespaceOrder = (name: string): string => {
|
|
163
|
+
const namespaceOrder = (name: string): string => {
|
|
127
164
|
const index = LEADING_NAMESPACES.indexOf(name);
|
|
128
|
-
return index === -1 ? `1${name}` : `0${index}`;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const DOCS_SIGNATURE_NAMESPACE = "$docs";
|
|
132
|
-
|
|
133
|
-
export const docsSignatureContext = (namespace: GirNamespace, library: Library): ModuleContext =>
|
|
134
|
-
new ModuleContext({ ...namespace, name: DOCS_SIGNATURE_NAMESPACE }, library);
|
|
135
165
|
|
|
136
|
-
|
|
137
|
-
name: string;
|
|
138
|
-
signature: string;
|
|
139
|
-
doc: string;
|
|
166
|
+
return index === -1 ? `1${name}` : `0${String(index)}`;
|
|
140
167
|
};
|
|
141
168
|
|
|
142
|
-
|
|
169
|
+
const docsSignatureContext = (namespace: GirNamespace, library: Library): ModuleContext =>
|
|
170
|
+
new ModuleContext({ ...namespace, name: DOCS_SIGNATURE_NAMESPACE }, library);
|
|
143
171
|
|
|
144
|
-
|
|
172
|
+
const originSignatureBlocks = (entries: OriginSignatureEntry[]): string[] =>
|
|
145
173
|
sortStringsBy(entries, (item) => item.name).map((item) =>
|
|
146
174
|
signatureBlock(item.name, item.signature, [
|
|
147
175
|
item.origin === undefined ? "" : `From \`${item.origin}\`.`,
|
|
@@ -149,43 +177,79 @@ export const originSignatureBlocks = (entries: OriginSignatureEntry[]): string[]
|
|
|
149
177
|
]),
|
|
150
178
|
);
|
|
151
179
|
|
|
152
|
-
|
|
180
|
+
const classMethodEntries = (library: Library, namespace: GirNamespace, klass: GirClass): SignatureEntry[] => {
|
|
153
181
|
const realContext = new ModuleContext(namespace, library);
|
|
154
182
|
const signatureContext = docsSignatureContext(namespace, library);
|
|
155
|
-
const className =
|
|
183
|
+
const className = pascalCase(klass.name);
|
|
156
184
|
const inherited = collectInheritedMethods(realContext, klass);
|
|
157
|
-
|
|
185
|
+
|
|
186
|
+
return instanceMethodEntries(signatureContext, klass, (method) =>
|
|
158
187
|
conflictRename(realContext, method, inherited, className),
|
|
159
188
|
);
|
|
160
189
|
};
|
|
161
190
|
|
|
162
|
-
|
|
191
|
+
const methodsSectionBlocks = (entries: SignatureEntry[], intro: string): string[] =>
|
|
163
192
|
entries.length === 0
|
|
164
193
|
? []
|
|
165
194
|
: ["## Methods", intro, ...entries.map((item) => signatureBlock(item.name, item.signature, [item.doc]))];
|
|
166
195
|
|
|
167
|
-
|
|
196
|
+
const instanceMethodEntries = (
|
|
168
197
|
signatureContext: ModuleContext,
|
|
169
|
-
|
|
198
|
+
klass: GirClass,
|
|
170
199
|
rename: (fn: GirFunction) => string | undefined,
|
|
171
200
|
): SignatureEntry[] => {
|
|
172
|
-
const deduped = dedupeCallables(methods);
|
|
173
|
-
|
|
201
|
+
const deduped = dedupeCallables(klass.methods);
|
|
202
|
+
|
|
203
|
+
const scope = instanceScope(pascalCase(klass.name), {
|
|
204
|
+
constructors: dedupeCallables(klass.constructors),
|
|
205
|
+
functions: dedupeCallables(klass.functions),
|
|
206
|
+
methods: deduped,
|
|
207
|
+
});
|
|
208
|
+
|
|
174
209
|
const entries: SignatureEntry[] = [];
|
|
210
|
+
|
|
175
211
|
for (const method of deduped) {
|
|
176
212
|
const nameOverride = rename(method);
|
|
213
|
+
|
|
177
214
|
const rendered = renderInstanceMethodSignature(
|
|
178
215
|
signatureContext,
|
|
179
216
|
{ ...method, doc: undefined },
|
|
180
|
-
|
|
217
|
+
scope,
|
|
181
218
|
nameOverride,
|
|
182
219
|
);
|
|
183
|
-
|
|
220
|
+
|
|
221
|
+
if (rendered === undefined) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
184
225
|
entries.push({
|
|
185
226
|
name: nameOverride ?? methodExportName(method),
|
|
186
227
|
signature: rendered.trim().replace(/;$/, ""),
|
|
187
228
|
doc: docMarkdown(method.doc),
|
|
188
229
|
});
|
|
189
230
|
}
|
|
231
|
+
|
|
190
232
|
return sortStringsBy(entries, (entry) => entry.name);
|
|
191
233
|
};
|
|
234
|
+
|
|
235
|
+
export {
|
|
236
|
+
renderDocsType,
|
|
237
|
+
renderDocsSignalSignature,
|
|
238
|
+
renderDocsSignalHandlerType,
|
|
239
|
+
docsDefaultValue,
|
|
240
|
+
docMarkdown,
|
|
241
|
+
firstSentence,
|
|
242
|
+
elementSlug,
|
|
243
|
+
implementsLine,
|
|
244
|
+
joinSections,
|
|
245
|
+
metaBlock,
|
|
246
|
+
signatureBlock,
|
|
247
|
+
namespaceOrder,
|
|
248
|
+
docsSignatureContext,
|
|
249
|
+
originSignatureBlocks,
|
|
250
|
+
classMethodEntries,
|
|
251
|
+
methodsSectionBlocks,
|
|
252
|
+
instanceMethodEntries,
|
|
253
|
+
type SignatureEntry,
|
|
254
|
+
type OriginSignatureEntry,
|
|
255
|
+
};
|