@gtkx/codegen 1.0.0-rc.1 → 1.0.0-rc.2
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 +18 -11
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +275 -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 +69 -23
- 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 +194 -121
- 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 +68 -133
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/pipeline.d.ts +8 -7
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +79 -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 +28 -5
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +66 -13
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +13 -0
- package/dist/gi.d.ts.map +1 -0
- package/dist/gi.js +21 -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 +3 -2
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +39 -27
- 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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts +26 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +40 -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 +17 -0
- package/dist/react/element-config.d.ts.map +1 -0
- package/dist/react/element-config.js +61 -0
- package/dist/react/element-config.js.map +1 -0
- package/dist/runner.d.ts +17 -10
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +45 -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 +162 -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-struct-record.d.ts +4 -3
- package/dist/store/gi/class-struct-record.d.ts.map +1 -1
- package/dist/store/gi/class-struct-record.js +33 -15
- package/dist/store/gi/class-struct-record.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 +50 -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 +187 -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 +36 -25
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +8 -8
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +171 -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 +19 -13
- 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/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 +27 -0
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -0
- package/dist/store/jsx/intrinsic-elements.js +128 -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/pipeline.d.ts +21 -0
- package/dist/store/jsx/pipeline.d.ts.map +1 -0
- package/dist/store/{react → jsx}/pipeline.js +36 -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 +158 -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 +15 -9
- package/src/analysis/descriptor-render.ts +484 -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 +112 -26
- package/src/compile.ts +103 -76
- package/src/docs/api-reference.ts +340 -144
- package/src/docs/element-page.ts +137 -146
- package/src/docs/pipeline.ts +132 -73
- package/src/docs/render.ts +151 -87
- package/src/docs/symbol-page.ts +268 -123
- package/src/fingerprint.ts +127 -29
- package/src/gi.ts +26 -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 +56 -31
- 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 +7 -0
- package/src/jsx.ts +70 -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 +91 -0
- package/src/runner.ts +93 -57
- package/src/store/compile-store.ts +32 -26
- package/src/store/gi/async.ts +48 -21
- package/src/store/gi/callables.ts +345 -136
- package/src/store/gi/callback.ts +13 -4
- package/src/store/gi/class-struct-record.ts +49 -17
- 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 +90 -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 +376 -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 +62 -30
- package/src/store/gi/record-field-accessor.ts +380 -167
- package/src/store/gi/record-layout.ts +130 -43
- package/src/store/gi/record.ts +37 -14
- 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/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 +262 -0
- package/src/store/{react → jsx}/jsx.ts +213 -99
- package/src/store/jsx/metadata.ts +385 -0
- package/src/store/jsx/pipeline.ts +145 -0
- package/src/store/jsx/props.ts +274 -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/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/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,32 @@
|
|
|
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 { createElementPageContext, type ElementPageContext, renderElementPage } from "./element-page.js";
|
|
10
10
|
import { elementSlug, firstSentence, namespaceOrder } from "./render.js";
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type DocsElementLink = {
|
|
13
13
|
text: string;
|
|
14
14
|
link: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
type DocsNamespace = {
|
|
18
18
|
name: string;
|
|
19
19
|
directory: string;
|
|
20
20
|
link: string;
|
|
21
21
|
elements: DocsElementLink[];
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
type DocsOptions = {
|
|
25
25
|
libraries: string[];
|
|
26
26
|
girPath: string[];
|
|
27
27
|
outDir: string;
|
|
28
28
|
basePath?: string;
|
|
29
|
-
|
|
29
|
+
props?: ElementProps;
|
|
30
30
|
force?: boolean;
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -34,22 +34,42 @@ type DocsManifest = {
|
|
|
34
34
|
namespaces: DocsNamespace[];
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
type GeneratedDocs = {
|
|
38
|
+
pages: { path: string; content: string }[];
|
|
39
|
+
namespaces: DocsNamespace[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type Page = { path: string; content: string };
|
|
43
|
+
type NamespacePages = { docs: DocsNamespace; pages: Page[] };
|
|
44
|
+
|
|
45
|
+
type DocsResult = {
|
|
46
|
+
regenerated: boolean;
|
|
47
|
+
namespaces: DocsNamespace[];
|
|
48
|
+
};
|
|
49
|
+
|
|
37
50
|
const MANIFEST_FILENAME = "manifest.json";
|
|
38
51
|
|
|
39
52
|
const namespaceIndexPage = (namespace: DocsNamespace, elements: GlibNamedClass[]): string => {
|
|
40
53
|
const rows = elements.map((entry, index) => {
|
|
41
54
|
const link = namespace.elements[index]?.link ?? "";
|
|
42
|
-
const description = firstSentence(entry.klass.doc).replaceAll("|",
|
|
55
|
+
const description = firstSentence(entry.klass.doc).replaceAll("|", String.raw`\|`);
|
|
56
|
+
|
|
43
57
|
return `| [${entry.glibName}](${link}) | ${description} |`;
|
|
44
58
|
});
|
|
59
|
+
|
|
60
|
+
const description =
|
|
61
|
+
`Reference pages for the ${String(namespace.elements.length)} JSX elements in ` +
|
|
62
|
+
`the ${namespace.name} namespace.`;
|
|
63
|
+
|
|
45
64
|
return [
|
|
46
65
|
"---",
|
|
47
|
-
`description: ${JSON.stringify(
|
|
66
|
+
`description: ${JSON.stringify(description)}`,
|
|
48
67
|
"---",
|
|
49
68
|
"",
|
|
50
69
|
`# ${namespace.name} elements`,
|
|
51
70
|
"",
|
|
52
|
-
`Elements in this namespace are imported from \`@gtkx/jsx/${namespace.directory}\`; the matching
|
|
71
|
+
`Elements in this namespace are imported from \`@gtkx/jsx/${namespace.directory}\`; the matching ` +
|
|
72
|
+
`classes, enums, and functions are imported from \`@gtkx/gi/${namespace.directory}\`.`,
|
|
53
73
|
"",
|
|
54
74
|
"| Element | Description |",
|
|
55
75
|
"| --- | --- |",
|
|
@@ -60,21 +80,27 @@ const namespaceIndexPage = (namespace: DocsNamespace, elements: GlibNamedClass[]
|
|
|
60
80
|
|
|
61
81
|
const rootIndexPage = (namespaces: DocsNamespace[], libraries: string[]): string => {
|
|
62
82
|
const rows = namespaces.map(
|
|
63
|
-
(ns) => `| [${ns.name}](${ns.link}) | \`@gtkx/jsx/${ns.directory}\` | ${ns.elements.length} |`,
|
|
83
|
+
(ns) => `| [${ns.name}](${ns.link}) | \`@gtkx/jsx/${ns.directory}\` | ${String(ns.elements.length)} |`,
|
|
64
84
|
);
|
|
85
|
+
|
|
65
86
|
const librariesList = libraries.map((library) => `\`${library}\``).join(", ");
|
|
87
|
+
|
|
66
88
|
return [
|
|
67
89
|
"---",
|
|
68
|
-
|
|
90
|
+
"description: \"Generated reference documentation for every JSX element in this project's GIR libraries.\"",
|
|
69
91
|
"---",
|
|
70
92
|
"",
|
|
71
93
|
"# Element Reference",
|
|
72
94
|
"",
|
|
73
|
-
|
|
95
|
+
"This reference documents every JSX element generated from the GObject-Introspection data for " +
|
|
96
|
+
`${librariesList}, together with the namespaces they pull in. It is produced by \`gtkx docs\` ` +
|
|
97
|
+
"using the same pipeline that generates the `@gtkx/jsx` and `@gtkx/gi` bindings, so every page " +
|
|
98
|
+
"matches the types your editor sees.",
|
|
74
99
|
"",
|
|
75
100
|
"Each element page lists:",
|
|
76
101
|
"",
|
|
77
|
-
"- **Props** derived from GObject properties, plus the element props GTKX adds (such as `children`
|
|
102
|
+
"- **Props** derived from GObject properties, plus the element props GTKX adds (such as `children` " +
|
|
103
|
+
"and named slots), with types, defaults, and upstream documentation.",
|
|
78
104
|
"- **Signals** as `on<Signal>` handler props with their exact handler signatures.",
|
|
79
105
|
"- **Methods** available on the underlying instance through the `ref` prop.",
|
|
80
106
|
"",
|
|
@@ -87,96 +113,129 @@ const rootIndexPage = (namespaces: DocsNamespace[], libraries: string[]): string
|
|
|
87
113
|
].join("\n");
|
|
88
114
|
};
|
|
89
115
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
namespaces: DocsNamespace[];
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const generatePages = (options: DocsOptions, basePath: string, library: Library): GeneratedDocs => {
|
|
96
|
-
const intrinsicElements = collectIntrinsicElementClasses(library);
|
|
116
|
+
const groupElementsByNamespace = (elements: GlibNamedClass[]): Map<string, GlibNamedClass[]> => {
|
|
117
|
+
const byNamespace: Map<string, GlibNamedClass[]> = new Map();
|
|
97
118
|
|
|
98
|
-
const
|
|
99
|
-
for (const entry of intrinsicElements) {
|
|
119
|
+
for (const entry of elements) {
|
|
100
120
|
const list = byNamespace.get(entry.namespace.name) ?? [];
|
|
101
121
|
list.push(entry);
|
|
102
122
|
byNamespace.set(entry.namespace.name, list);
|
|
103
123
|
}
|
|
104
124
|
|
|
105
|
-
|
|
106
|
-
|
|
125
|
+
return byNamespace;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const buildElementLinks = (elements: GlibNamedClass[], basePath: string): Map<string, string> => {
|
|
129
|
+
const linkByGlibName: Map<string, string> = new Map();
|
|
130
|
+
|
|
131
|
+
for (const entry of elements) {
|
|
107
132
|
const directory = namespaceDirectory(entry.namespace);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
const link = `${basePath}/${directory}/${elementSlug(entry.klass.name)}`;
|
|
134
|
+
|
|
135
|
+
if (linkByGlibName.values().some((existing) => existing === link)) {
|
|
136
|
+
throw new Error(`Docs page slug collision for ${entry.glibName} at ${link}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
112
139
|
linkByGlibName.set(entry.glibName, link);
|
|
113
140
|
}
|
|
114
141
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
);
|
|
142
|
+
return linkByGlibName;
|
|
143
|
+
};
|
|
118
144
|
|
|
119
|
-
|
|
145
|
+
const namespacePages = (input: {
|
|
146
|
+
name: string;
|
|
147
|
+
elements: GlibNamedClass[];
|
|
148
|
+
basePath: string;
|
|
149
|
+
linkByGlibName: Map<string, string>;
|
|
150
|
+
pageContext: ElementPageContext;
|
|
151
|
+
}): NamespacePages => {
|
|
152
|
+
const { name, elements, basePath, linkByGlibName, pageContext } = input;
|
|
153
|
+
const directory = name.toLowerCase();
|
|
154
|
+
|
|
155
|
+
const docs: DocsNamespace = {
|
|
156
|
+
name,
|
|
157
|
+
directory,
|
|
158
|
+
link: `${basePath}/${directory}/`,
|
|
159
|
+
elements: elements.map((entry) => ({ text: entry.glibName, link: linkByGlibName.get(entry.glibName) ?? "" })),
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const pages: Page[] = elements.map((entry) => ({
|
|
163
|
+
path: `${directory}/${elementSlug(entry.klass.name)}.md`,
|
|
164
|
+
content: renderElementPage(entry, pageContext),
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
pages.push({ path: `${directory}/index.md`, content: namespaceIndexPage(docs, elements) });
|
|
168
|
+
|
|
169
|
+
return { docs, pages };
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const generatePages = (options: DocsOptions, basePath: string, library: Library): GeneratedDocs => {
|
|
173
|
+
const intrinsicElements = collectIntrinsicElementClasses(library);
|
|
174
|
+
const byNamespace = groupElementsByNamespace(intrinsicElements);
|
|
175
|
+
const linkByGlibName = buildElementLinks(intrinsicElements, basePath);
|
|
176
|
+
const pageContext = createElementPageContext(library, (glibName: string) => linkByGlibName.get(glibName));
|
|
177
|
+
const pages: Page[] = [];
|
|
120
178
|
const namespaces: DocsNamespace[] = [];
|
|
121
|
-
const orderedNames = sortStringsBy(
|
|
179
|
+
const orderedNames = sortStringsBy(byNamespace.keys(), namespaceOrder);
|
|
180
|
+
|
|
122
181
|
for (const name of orderedNames) {
|
|
123
182
|
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);
|
|
183
|
+
const result = namespacePages({ name, elements, basePath, linkByGlibName, pageContext });
|
|
184
|
+
pages.push(...result.pages);
|
|
185
|
+
namespaces.push(result.docs);
|
|
140
186
|
}
|
|
187
|
+
|
|
141
188
|
pages.push({ path: "index.md", content: rootIndexPage(namespaces, options.libraries) });
|
|
189
|
+
|
|
142
190
|
return { pages, namespaces };
|
|
143
191
|
};
|
|
144
192
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
193
|
+
const cachedDocsResult = (options: DocsOptions, manifestPath: string): DocsResult | undefined => {
|
|
194
|
+
if (options.force === true || !isGiStoreFresh(options.outDir, options.libraries, options.girPath)) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!existsSync(manifestPath)) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as DocsManifest;
|
|
203
|
+
|
|
204
|
+
return { regenerated: false, namespaces: manifest.namespaces };
|
|
148
205
|
};
|
|
149
206
|
|
|
150
|
-
|
|
207
|
+
const writePages = (outDir: string, pages: Page[]): void => {
|
|
208
|
+
for (const page of pages) {
|
|
209
|
+
const target = join(outDir, page.path);
|
|
210
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
211
|
+
writeFileSync(target, page.content);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const writeDocs = (options: DocsOptions): DocsResult => {
|
|
216
|
+
setElementProps(options.props ?? {});
|
|
151
217
|
const basePath = options.basePath ?? "/reference";
|
|
152
|
-
const elementProps = options.elementProps ?? {};
|
|
153
218
|
const manifestPath = join(options.outDir, MANIFEST_FILENAME);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
219
|
+
const cached = cachedDocsResult(options, manifestPath);
|
|
220
|
+
|
|
221
|
+
if (cached !== undefined) {
|
|
222
|
+
return cached;
|
|
159
223
|
}
|
|
160
224
|
|
|
161
225
|
const library = Library.load(options.libraries, options.girPath);
|
|
162
226
|
const { pages, namespaces } = generatePages(options, basePath, library);
|
|
163
|
-
|
|
164
227
|
rmSync(options.outDir, { recursive: true, force: true });
|
|
165
228
|
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
|
-
}
|
|
229
|
+
writePages(options.outDir, pages);
|
|
171
230
|
const manifest: DocsManifest = { namespaces };
|
|
172
231
|
writeFileSync(manifestPath, JSON.stringify(manifest));
|
|
232
|
+
|
|
173
233
|
writeFileSync(
|
|
174
234
|
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
|
-
}),
|
|
235
|
+
JSON.stringify(computeGiFingerprint(library.girFiles, options.libraries, options.girPath)),
|
|
180
236
|
);
|
|
237
|
+
|
|
181
238
|
return { regenerated: true, namespaces };
|
|
182
239
|
};
|
|
240
|
+
|
|
241
|
+
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
|
+
};
|