@gtkx/codegen 0.21.0 → 1.0.0-rc.1
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/README.md +173 -0
- package/dist/analysis/descriptor-render.d.ts +18 -0
- package/dist/analysis/descriptor-render.d.ts.map +1 -0
- package/dist/analysis/descriptor-render.js +297 -0
- package/dist/analysis/descriptor-render.js.map +1 -0
- package/dist/analysis/descriptor.d.ts +59 -0
- package/dist/analysis/descriptor.d.ts.map +1 -0
- package/dist/analysis/descriptor.js +123 -0
- package/dist/analysis/descriptor.js.map +1 -0
- package/dist/analysis/inheritance.d.ts +38 -0
- package/dist/analysis/inheritance.d.ts.map +1 -0
- package/dist/analysis/inheritance.js +193 -0
- package/dist/analysis/inheritance.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +26 -0
- package/dist/analysis/param-structure.d.ts.map +1 -0
- package/dist/analysis/param-structure.js +107 -0
- package/dist/analysis/param-structure.js.map +1 -0
- package/dist/analysis/ts-type.d.ts +19 -0
- package/dist/analysis/ts-type.d.ts.map +1 -0
- package/dist/analysis/ts-type.js +65 -0
- package/dist/analysis/ts-type.js.map +1 -0
- package/dist/compile.d.ts +18 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +123 -0
- package/dist/compile.js.map +1 -0
- package/dist/docs/api-reference.d.ts +66 -0
- package/dist/docs/api-reference.d.ts.map +1 -0
- package/dist/docs/api-reference.js +299 -0
- package/dist/docs/api-reference.js.map +1 -0
- package/dist/docs/element-page.d.ts +15 -0
- package/dist/docs/element-page.d.ts.map +1 -0
- package/dist/docs/element-page.js +221 -0
- package/dist/docs/element-page.js.map +1 -0
- package/dist/docs/pipeline.d.ts +25 -0
- package/dist/docs/pipeline.d.ts.map +1 -0
- package/dist/docs/pipeline.js +130 -0
- package/dist/docs/pipeline.js.map +1 -0
- package/dist/docs/render.d.ts +32 -0
- package/dist/docs/render.d.ts.map +1 -0
- package/dist/docs/render.js +134 -0
- package/dist/docs/render.js.map +1 -0
- package/dist/docs/symbol-page.d.ts +41 -0
- package/dist/docs/symbol-page.d.ts.map +1 -0
- package/dist/docs/symbol-page.js +338 -0
- package/dist/docs/symbol-page.js.map +1 -0
- package/dist/fingerprint.d.ts +6 -26
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +30 -18
- package/dist/fingerprint.js.map +1 -1
- package/dist/gir/ancestry.d.ts +9 -0
- package/dist/gir/ancestry.d.ts.map +1 -0
- package/dist/gir/ancestry.js +29 -0
- package/dist/gir/ancestry.js.map +1 -0
- package/dist/gir/callback.d.ts +9 -10
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +17 -16
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +22 -43
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +11 -23
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +13 -31
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +7 -14
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +10 -23
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +12 -18
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +11 -42
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +7 -20
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +2 -0
- package/dist/gir/gir-path.d.ts.map +1 -0
- package/dist/gir/gir-path.js +41 -0
- package/dist/gir/gir-path.js.map +1 -0
- package/dist/gir/libraries.d.ts +4 -0
- package/dist/gir/libraries.d.ts.map +1 -0
- package/dist/gir/libraries.js +62 -0
- package/dist/gir/libraries.js.map +1 -0
- package/dist/gir/library.d.ts +37 -0
- package/dist/gir/library.d.ts.map +1 -0
- package/dist/gir/library.js +218 -0
- package/dist/gir/library.js.map +1 -0
- package/dist/gir/namespace.d.ts +36 -50
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +46 -36
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +25 -69
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +36 -57
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +6 -70
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +32 -80
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +3 -34
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +19 -35
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +16 -25
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +12 -9
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +27 -0
- package/dist/gir/record.d.ts.map +1 -0
- package/dist/gir/record.js +25 -0
- package/dist/gir/record.js.map +1 -0
- package/dist/gir/size.d.ts +10 -57
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +0 -25
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +49 -0
- package/dist/gir/type-id.d.ts.map +1 -0
- package/dist/gir/type-id.js +8 -0
- package/dist/gir/type-id.js.map +1 -0
- package/dist/gir/type-ref.d.ts +3 -77
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +35 -65
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +33 -0
- package/dist/gir/type.d.ts.map +1 -0
- package/dist/gir/type.js +2 -0
- package/dist/gir/type.js.map +1 -0
- package/dist/index.d.ts +5 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/dist/khronos/args.d.ts +30 -0
- package/dist/khronos/args.d.ts.map +1 -0
- package/dist/khronos/args.js +150 -0
- package/dist/khronos/args.js.map +1 -0
- package/dist/khronos/jsdoc.d.ts +21 -0
- package/dist/khronos/jsdoc.d.ts.map +1 -0
- package/dist/khronos/jsdoc.js +59 -0
- package/dist/khronos/jsdoc.js.map +1 -0
- package/dist/khronos/model.d.ts +37 -0
- package/dist/khronos/model.d.ts.map +1 -0
- package/dist/khronos/model.js +132 -0
- package/dist/khronos/model.js.map +1 -0
- package/dist/khronos/modules.d.ts +11 -0
- package/dist/khronos/modules.d.ts.map +1 -0
- package/dist/khronos/modules.js +58 -0
- package/dist/khronos/modules.js.map +1 -0
- package/dist/khronos/parse.d.ts +9 -0
- package/dist/khronos/parse.d.ts.map +1 -0
- package/dist/khronos/parse.js +61 -0
- package/dist/khronos/parse.js.map +1 -0
- package/dist/khronos/pipeline.d.ts +24 -0
- package/dist/khronos/pipeline.d.ts.map +1 -0
- package/dist/khronos/pipeline.js +182 -0
- package/dist/khronos/pipeline.js.map +1 -0
- package/dist/khronos/plan.d.ts +80 -0
- package/dist/khronos/plan.d.ts.map +1 -0
- package/dist/khronos/plan.js +136 -0
- package/dist/khronos/plan.js.map +1 -0
- package/dist/khronos/render.d.ts +16 -0
- package/dist/khronos/render.d.ts.map +1 -0
- package/dist/khronos/render.js +158 -0
- package/dist/khronos/render.js.map +1 -0
- package/dist/khronos/select.d.ts +15 -0
- package/dist/khronos/select.d.ts.map +1 -0
- package/dist/khronos/select.js +45 -0
- package/dist/khronos/select.js.map +1 -0
- package/dist/runner.d.ts +29 -47
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +78 -53
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +9 -0
- package/dist/store/compile-store.d.ts.map +1 -0
- package/dist/store/compile-store.js +38 -0
- package/dist/store/compile-store.js.map +1 -0
- package/dist/store/gi/async.d.ts +4 -0
- package/dist/store/gi/async.d.ts.map +1 -0
- package/dist/store/gi/async.js +41 -0
- package/dist/store/gi/async.js.map +1 -0
- package/dist/store/gi/callables.d.ts +36 -0
- package/dist/store/gi/callables.d.ts.map +1 -0
- package/dist/store/gi/callables.js +202 -0
- package/dist/store/gi/callables.js.map +1 -0
- package/dist/store/gi/callback.d.ts +4 -0
- package/dist/store/gi/callback.d.ts.map +1 -0
- package/dist/store/gi/callback.js +14 -0
- package/dist/store/gi/callback.js.map +1 -0
- package/dist/store/gi/class-struct-record.d.ts +9 -0
- package/dist/store/gi/class-struct-record.d.ts.map +1 -0
- package/dist/store/gi/class-struct-record.js +34 -0
- package/dist/store/gi/class-struct-record.js.map +1 -0
- package/dist/store/gi/class.d.ts +4 -0
- package/dist/store/gi/class.d.ts.map +1 -0
- package/dist/store/gi/class.js +169 -0
- package/dist/store/gi/class.js.map +1 -0
- package/dist/store/gi/companion.d.ts +4 -0
- package/dist/store/gi/companion.d.ts.map +1 -0
- package/dist/store/gi/companion.js +13 -0
- package/dist/store/gi/companion.js.map +1 -0
- package/dist/store/gi/constant.d.ts +5 -0
- package/dist/store/gi/constant.d.ts.map +1 -0
- package/dist/store/gi/constant.js +18 -0
- package/dist/store/gi/constant.js.map +1 -0
- package/dist/store/gi/constructor-props.d.ts +5 -0
- package/dist/store/gi/constructor-props.d.ts.map +1 -0
- package/dist/store/gi/constructor-props.js +64 -0
- package/dist/store/gi/constructor-props.js.map +1 -0
- package/dist/store/gi/enum.d.ts +5 -0
- package/dist/store/gi/enum.d.ts.map +1 -0
- package/dist/store/gi/enum.js +38 -0
- package/dist/store/gi/enum.js.map +1 -0
- package/dist/store/gi/function.d.ts +8 -0
- package/dist/store/gi/function.d.ts.map +1 -0
- package/dist/store/gi/function.js +87 -0
- package/dist/store/gi/function.js.map +1 -0
- package/dist/store/gi/gtype-binding.d.ts +10 -0
- package/dist/store/gi/gtype-binding.d.ts.map +1 -0
- package/dist/store/gi/gtype-binding.js +20 -0
- package/dist/store/gi/gtype-binding.js.map +1 -0
- package/dist/store/gi/interface.d.ts +4 -0
- package/dist/store/gi/interface.d.ts.map +1 -0
- package/dist/store/gi/interface.js +99 -0
- package/dist/store/gi/interface.js.map +1 -0
- package/dist/store/gi/item-comparators.d.ts +6 -0
- package/dist/store/gi/item-comparators.d.ts.map +1 -0
- package/dist/store/gi/item-comparators.js +76 -0
- package/dist/store/gi/item-comparators.js.map +1 -0
- package/dist/store/gi/method.d.ts +24 -0
- package/dist/store/gi/method.d.ts.map +1 -0
- package/dist/store/gi/method.js +279 -0
- package/dist/store/gi/method.js.map +1 -0
- package/dist/store/gi/param-marshal.d.ts +9 -0
- package/dist/store/gi/param-marshal.d.ts.map +1 -0
- package/dist/store/gi/param-marshal.js +37 -0
- package/dist/store/gi/param-marshal.js.map +1 -0
- package/dist/store/gi/pipeline.d.ts +4 -0
- package/dist/store/gi/pipeline.d.ts.map +1 -0
- package/dist/store/gi/pipeline.js +80 -0
- package/dist/store/gi/pipeline.js.map +1 -0
- package/dist/store/gi/properties.d.ts +5 -0
- package/dist/store/gi/properties.d.ts.map +1 -0
- package/dist/store/gi/properties.js +30 -0
- package/dist/store/gi/properties.js.map +1 -0
- package/dist/store/gi/property-accessor.d.ts +26 -0
- package/dist/store/gi/property-accessor.d.ts.map +1 -0
- package/dist/store/gi/property-accessor.js +132 -0
- package/dist/store/gi/property-accessor.js.map +1 -0
- package/dist/store/gi/record-constructor.d.ts +5 -0
- package/dist/store/gi/record-constructor.d.ts.map +1 -0
- package/dist/store/gi/record-constructor.js +65 -0
- package/dist/store/gi/record-constructor.js.map +1 -0
- package/dist/store/gi/record-field-accessor.d.ts +25 -0
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -0
- package/dist/store/gi/record-field-accessor.js +288 -0
- package/dist/store/gi/record-field-accessor.js.map +1 -0
- package/dist/store/gi/record-layout.d.ts +14 -0
- package/dist/store/gi/record-layout.d.ts.map +1 -0
- package/dist/store/gi/record-layout.js +96 -0
- package/dist/store/gi/record-layout.js.map +1 -0
- package/dist/store/gi/record.d.ts +4 -0
- package/dist/store/gi/record.d.ts.map +1 -0
- package/dist/store/gi/record.js +59 -0
- package/dist/store/gi/record.js.map +1 -0
- package/dist/store/gi/registration.d.ts +16 -0
- package/dist/store/gi/registration.d.ts.map +1 -0
- package/dist/store/gi/registration.js +20 -0
- package/dist/store/gi/registration.js.map +1 -0
- package/dist/store/gi/return-wrap.d.ts +10 -0
- package/dist/store/gi/return-wrap.d.ts.map +1 -0
- package/dist/store/gi/return-wrap.js +46 -0
- package/dist/store/gi/return-wrap.js.map +1 -0
- package/dist/store/gi/runtime-override.d.ts +3 -0
- package/dist/store/gi/runtime-override.d.ts.map +1 -0
- package/dist/{writers → store/gi}/runtime-override.js +0 -15
- package/dist/store/gi/runtime-override.js.map +1 -0
- package/dist/store/gi/signal.d.ts +5 -0
- package/dist/store/gi/signal.d.ts.map +1 -0
- package/dist/store/gi/signal.js +233 -0
- package/dist/store/gi/signal.js.map +1 -0
- package/dist/store/gi/vtable.d.ts +4 -0
- package/dist/store/gi/vtable.d.ts.map +1 -0
- package/dist/store/gi/vtable.js +78 -0
- package/dist/store/gi/vtable.js.map +1 -0
- package/dist/store/gi-store.d.ts +9 -0
- package/dist/store/gi-store.d.ts.map +1 -0
- package/dist/store/gi-store.js +57 -0
- package/dist/store/gi-store.js.map +1 -0
- package/dist/store/jsx-store.d.ts +5 -0
- package/dist/store/jsx-store.d.ts.map +1 -0
- package/dist/store/jsx-store.js +23 -0
- package/dist/store/jsx-store.js.map +1 -0
- package/dist/store/react/built-ins.d.ts +9 -0
- package/dist/store/react/built-ins.d.ts.map +1 -0
- package/dist/store/react/built-ins.js +226 -0
- package/dist/store/react/built-ins.js.map +1 -0
- package/dist/store/react/element-components.d.ts +15 -0
- package/dist/store/react/element-components.d.ts.map +1 -0
- package/dist/store/react/element-components.js +92 -0
- package/dist/store/react/element-components.js.map +1 -0
- package/dist/store/react/element-prop-types.d.ts +19 -0
- package/dist/store/react/element-prop-types.d.ts.map +1 -0
- package/dist/store/react/element-prop-types.js +244 -0
- package/dist/store/react/element-prop-types.js.map +1 -0
- package/dist/store/react/element-props.d.ts +4 -0
- package/dist/store/react/element-props.d.ts.map +1 -0
- package/dist/store/react/element-props.js +178 -0
- package/dist/store/react/element-props.js.map +1 -0
- package/dist/store/react/gir-index.d.ts +25 -0
- package/dist/store/react/gir-index.d.ts.map +1 -0
- package/dist/store/react/gir-index.js +55 -0
- package/dist/store/react/gir-index.js.map +1 -0
- package/dist/store/react/intrinsic-elements.d.ts +26 -0
- package/dist/store/react/intrinsic-elements.d.ts.map +1 -0
- package/dist/store/react/intrinsic-elements.js +107 -0
- package/dist/store/react/intrinsic-elements.js.map +1 -0
- package/dist/store/react/jsx.d.ts +18 -0
- package/dist/store/react/jsx.d.ts.map +1 -0
- package/dist/store/react/jsx.js +203 -0
- package/dist/store/react/jsx.js.map +1 -0
- package/dist/store/react/metadata.d.ts +4 -0
- package/dist/store/react/metadata.d.ts.map +1 -0
- package/dist/store/react/metadata.js +174 -0
- package/dist/store/react/metadata.js.map +1 -0
- package/dist/store/react/pipeline.d.ts +14 -0
- package/dist/store/react/pipeline.d.ts.map +1 -0
- package/dist/store/react/pipeline.js +60 -0
- package/dist/store/react/pipeline.js.map +1 -0
- package/dist/store/react/props.d.ts +36 -0
- package/dist/store/react/props.d.ts.map +1 -0
- package/dist/store/react/props.js +133 -0
- package/dist/store/react/props.js.map +1 -0
- package/dist/store/store-fs.d.ts +41 -0
- package/dist/store/store-fs.d.ts.map +1 -0
- package/dist/store/store-fs.js +71 -0
- package/dist/store/store-fs.js.map +1 -0
- package/dist/writer/context.d.ts +16 -0
- package/dist/writer/context.d.ts.map +1 -0
- package/dist/writer/context.js +44 -0
- package/dist/writer/context.js.map +1 -0
- package/dist/writer/doc.d.ts +2 -0
- package/dist/writer/doc.d.ts.map +1 -0
- package/dist/writer/doc.js +12 -0
- package/dist/writer/doc.js.map +1 -0
- package/dist/writer/emit.d.ts +8 -0
- package/dist/writer/emit.d.ts.map +1 -0
- package/dist/writer/emit.js +21 -0
- package/dist/writer/emit.js.map +1 -0
- package/dist/writer/gtk-doc.d.ts +2 -0
- package/dist/writer/gtk-doc.d.ts.map +1 -0
- package/dist/writer/gtk-doc.js +67 -0
- package/dist/writer/gtk-doc.js.map +1 -0
- package/dist/writer/imports.d.ts +10 -0
- package/dist/writer/imports.d.ts.map +1 -0
- package/dist/writer/imports.js +50 -0
- package/dist/writer/imports.js.map +1 -0
- package/dist/writer/module.d.ts +15 -0
- package/dist/writer/module.d.ts.map +1 -0
- package/dist/writer/module.js +46 -0
- package/dist/writer/module.js.map +1 -0
- package/overrides/cairo/context.ts.ejs +1269 -0
- package/overrides/cairo/font-face.ts.ejs +151 -0
- package/overrides/cairo/font-options.ts.ejs +199 -0
- package/overrides/cairo/image-surface.ts.ejs +132 -0
- package/overrides/cairo/index.ts.ejs +22 -0
- package/overrides/cairo/matrix.ts.ejs +171 -0
- package/overrides/cairo/pattern.ts.ejs +476 -0
- package/overrides/cairo/recording-surface.ts.ejs +102 -0
- package/overrides/cairo/region.ts.ejs +237 -0
- package/overrides/cairo/scaled-font.ts.ejs +330 -0
- package/overrides/cairo/surface.ts.ejs +296 -0
- package/overrides/gdk/index.ts.ejs +2 -0
- package/overrides/gdk/rgba.ts.ejs +11 -0
- package/overrides/gobject/index.ts.ejs +29 -0
- package/overrides/gobject/object.ts.ejs +51 -0
- package/overrides/gobject/value.ts.ejs +17 -0
- package/overrides/graphene/index.ts.ejs +2 -0
- package/overrides/graphene/structs.ts.ejs +37 -0
- package/overrides/gtk/constants.ts.ejs +3 -0
- package/overrides/gtk/index.ts.ejs +2 -0
- package/package.json +15 -15
- package/src/analysis/descriptor-render.ts +407 -0
- package/src/analysis/descriptor.ts +263 -0
- package/src/analysis/inheritance.ts +242 -0
- package/src/analysis/param-structure.ts +127 -0
- package/src/analysis/ts-type.ts +88 -0
- package/src/compile.ts +152 -0
- package/src/docs/api-reference.ts +361 -0
- package/src/docs/element-page.ts +290 -0
- package/src/docs/pipeline.ts +182 -0
- package/src/docs/render.ts +191 -0
- package/src/docs/symbol-page.ts +444 -0
- package/src/fingerprint.ts +40 -29
- package/src/gir/ancestry.ts +41 -0
- package/src/gir/callback.ts +25 -22
- package/src/gir/class.ts +31 -57
- package/src/gir/enum.ts +20 -38
- package/src/gir/field.ts +21 -36
- package/src/gir/function.ts +17 -56
- package/src/gir/gir-path.ts +49 -0
- package/src/gir/libraries.ts +77 -0
- package/src/gir/library.ts +248 -0
- package/src/gir/namespace.ts +85 -80
- package/src/gir/parameter.ts +64 -93
- package/src/gir/parse.ts +43 -95
- package/src/gir/primitives.ts +23 -45
- package/src/gir/property.ts +27 -29
- package/src/gir/record.ts +53 -0
- package/src/gir/size.ts +9 -56
- package/src/gir/type-id.ts +49 -0
- package/src/gir/type-ref.ts +35 -140
- package/src/gir/type.ts +16 -0
- package/src/index.ts +20 -15
- package/src/khronos/args.ts +202 -0
- package/src/khronos/jsdoc.ts +76 -0
- package/src/khronos/model.ts +166 -0
- package/src/khronos/modules.ts +75 -0
- package/src/khronos/parse.ts +66 -0
- package/src/khronos/pipeline.ts +234 -0
- package/src/khronos/plan.ts +191 -0
- package/src/khronos/registry/LICENSE +202 -0
- package/src/khronos/registry/gl.xml +47748 -0
- package/src/khronos/render.ts +193 -0
- package/src/khronos/select.ts +67 -0
- package/src/runner.ts +112 -75
- package/src/store/compile-store.ts +49 -0
- package/src/store/gi/async.ts +42 -0
- package/src/store/gi/callables.ts +309 -0
- package/src/store/gi/callback.ts +15 -0
- package/src/store/gi/class-struct-record.ts +40 -0
- package/src/store/gi/class.ts +212 -0
- package/src/store/gi/companion.ts +13 -0
- package/src/store/gi/constant.ts +24 -0
- package/src/store/gi/constructor-props.ts +82 -0
- package/src/store/gi/enum.ts +49 -0
- package/src/store/gi/function.ts +107 -0
- package/src/store/gi/gtype-binding.ts +33 -0
- package/src/store/gi/interface.ts +157 -0
- package/src/store/gi/item-comparators.ts +90 -0
- package/src/store/gi/method.ts +417 -0
- package/src/store/gi/param-marshal.ts +48 -0
- package/src/store/gi/pipeline.ts +85 -0
- package/src/store/gi/properties.ts +39 -0
- package/src/store/gi/property-accessor.ts +194 -0
- package/src/store/gi/record-constructor.ts +87 -0
- package/src/store/gi/record-field-accessor.ts +394 -0
- package/src/store/gi/record-layout.ts +134 -0
- package/src/store/gi/record.ts +66 -0
- package/src/store/gi/registration.ts +38 -0
- package/src/store/gi/return-wrap.ts +52 -0
- package/src/store/gi/runtime-override.ts +36 -0
- package/src/store/gi/signal.ts +310 -0
- package/src/store/gi/vtable.ts +99 -0
- package/src/store/gi-store.ts +79 -0
- package/src/store/jsx-store.ts +27 -0
- package/src/store/react/built-ins.ts +260 -0
- package/src/store/react/element-components.ts +138 -0
- package/src/store/react/element-prop-types.ts +280 -0
- package/src/store/react/element-props.ts +204 -0
- package/src/store/react/gir-index.ts +85 -0
- package/src/store/react/intrinsic-elements.ts +161 -0
- package/src/store/react/jsx.ts +294 -0
- package/src/store/react/metadata.ts +197 -0
- package/src/store/react/pipeline.ts +90 -0
- package/src/store/react/props.ts +197 -0
- package/src/store/store-fs.ts +112 -0
- package/src/writer/context.ts +48 -0
- package/src/writer/doc.ts +11 -0
- package/src/writer/emit.ts +26 -0
- package/src/writer/gtk-doc.ts +74 -0
- package/src/writer/imports.ts +59 -0
- package/src/writer/module.ts +45 -0
- package/LICENSE +0 -373
- package/dist/dsl/context.d.ts +0 -104
- package/dist/dsl/context.d.ts.map +0 -1
- package/dist/dsl/context.js +0 -140
- package/dist/dsl/context.js.map +0 -1
- package/dist/dsl/emit.d.ts +0 -28
- package/dist/dsl/emit.d.ts.map +0 -1
- package/dist/dsl/emit.js +0 -41
- package/dist/dsl/emit.js.map +0 -1
- package/dist/dsl/identifier.d.ts +0 -28
- package/dist/dsl/identifier.d.ts.map +0 -1
- package/dist/dsl/identifier.js +0 -45
- package/dist/dsl/identifier.js.map +0 -1
- package/dist/dsl/imports.d.ts +0 -58
- package/dist/dsl/imports.d.ts.map +0 -1
- package/dist/dsl/imports.js +0 -107
- package/dist/dsl/imports.js.map +0 -1
- package/dist/dsl/module.d.ts +0 -53
- package/dist/dsl/module.d.ts.map +0 -1
- package/dist/dsl/module.js +0 -76
- package/dist/dsl/module.js.map +0 -1
- package/dist/ffi/pipeline.d.ts +0 -19
- package/dist/ffi/pipeline.d.ts.map +0 -1
- package/dist/ffi/pipeline.js +0 -107
- package/dist/ffi/pipeline.js.map +0 -1
- package/dist/gi-store.d.ts +0 -34
- package/dist/gi-store.d.ts.map +0 -1
- package/dist/gi-store.js +0 -154
- package/dist/gi-store.js.map +0 -1
- package/dist/gir/boxed.d.ts +0 -66
- package/dist/gir/boxed.d.ts.map +0 -1
- package/dist/gir/boxed.js +0 -49
- package/dist/gir/boxed.js.map +0 -1
- package/dist/gir/qualified-name.d.ts +0 -37
- package/dist/gir/qualified-name.d.ts.map +0 -1
- package/dist/gir/qualified-name.js +0 -39
- package/dist/gir/qualified-name.js.map +0 -1
- package/dist/gir/qualify.d.ts +0 -32
- package/dist/gir/qualify.d.ts.map +0 -1
- package/dist/gir/qualify.js +0 -60
- package/dist/gir/qualify.js.map +0 -1
- package/dist/gir/repository.d.ts +0 -82
- package/dist/gir/repository.d.ts.map +0 -1
- package/dist/gir/repository.js +0 -122
- package/dist/gir/repository.js.map +0 -1
- package/dist/gir/signal.d.ts +0 -22
- package/dist/gir/signal.d.ts.map +0 -1
- package/dist/gir/signal.js +0 -20
- package/dist/gir/signal.js.map +0 -1
- package/dist/jsx-store.d.ts +0 -22
- package/dist/jsx-store.d.ts.map +0 -1
- package/dist/jsx-store.js +0 -40
- package/dist/jsx-store.js.map +0 -1
- package/dist/react/compounds-meta.d.ts +0 -18
- package/dist/react/compounds-meta.d.ts.map +0 -1
- package/dist/react/compounds-meta.js +0 -93
- package/dist/react/compounds-meta.js.map +0 -1
- package/dist/react/compounds.d.ts +0 -27
- package/dist/react/compounds.d.ts.map +0 -1
- package/dist/react/compounds.js +0 -164
- package/dist/react/compounds.js.map +0 -1
- package/dist/react/internal.d.ts +0 -14
- package/dist/react/internal.d.ts.map +0 -1
- package/dist/react/internal.js +0 -79
- package/dist/react/internal.js.map +0 -1
- package/dist/react/jsx.d.ts +0 -22
- package/dist/react/jsx.d.ts.map +0 -1
- package/dist/react/jsx.js +0 -134
- package/dist/react/jsx.js.map +0 -1
- package/dist/react/pipeline.d.ts +0 -13
- package/dist/react/pipeline.d.ts.map +0 -1
- package/dist/react/pipeline.js +0 -25
- package/dist/react/pipeline.js.map +0 -1
- package/dist/react/props.d.ts +0 -38
- package/dist/react/props.d.ts.map +0 -1
- package/dist/react/props.js +0 -231
- package/dist/react/props.js.map +0 -1
- package/dist/react/slot-props.d.ts +0 -10
- package/dist/react/slot-props.d.ts.map +0 -1
- package/dist/react/slot-props.js +0 -56
- package/dist/react/slot-props.js.map +0 -1
- package/dist/react/widgets.d.ts +0 -83
- package/dist/react/widgets.d.ts.map +0 -1
- package/dist/react/widgets.js +0 -152
- package/dist/react/widgets.js.map +0 -1
- package/dist/store-fs.d.ts +0 -109
- package/dist/store-fs.d.ts.map +0 -1
- package/dist/store-fs.js +0 -98
- package/dist/store-fs.js.map +0 -1
- package/dist/transpile.d.ts +0 -32
- package/dist/transpile.d.ts.map +0 -1
- package/dist/transpile.js +0 -63
- package/dist/transpile.js.map +0 -1
- package/dist/typecheck-store.d.ts +0 -41
- package/dist/typecheck-store.d.ts.map +0 -1
- package/dist/typecheck-store.js +0 -102
- package/dist/typecheck-store.js.map +0 -1
- package/dist/writers/alias.d.ts +0 -13
- package/dist/writers/alias.d.ts.map +0 -1
- package/dist/writers/alias.js +0 -17
- package/dist/writers/alias.js.map +0 -1
- package/dist/writers/async.d.ts +0 -22
- package/dist/writers/async.d.ts.map +0 -1
- package/dist/writers/async.js +0 -48
- package/dist/writers/async.js.map +0 -1
- package/dist/writers/boxed-constructor.d.ts +0 -26
- package/dist/writers/boxed-constructor.d.ts.map +0 -1
- package/dist/writers/boxed-constructor.js +0 -85
- package/dist/writers/boxed-constructor.js.map +0 -1
- package/dist/writers/boxed-field-accessor.d.ts +0 -18
- package/dist/writers/boxed-field-accessor.d.ts.map +0 -1
- package/dist/writers/boxed-field-accessor.js +0 -260
- package/dist/writers/boxed-field-accessor.js.map +0 -1
- package/dist/writers/boxed-layout.d.ts +0 -27
- package/dist/writers/boxed-layout.d.ts.map +0 -1
- package/dist/writers/boxed-layout.js +0 -128
- package/dist/writers/boxed-layout.js.map +0 -1
- package/dist/writers/boxed.d.ts +0 -20
- package/dist/writers/boxed.d.ts.map +0 -1
- package/dist/writers/boxed.js +0 -71
- package/dist/writers/boxed.js.map +0 -1
- package/dist/writers/callables.d.ts +0 -124
- package/dist/writers/callables.d.ts.map +0 -1
- package/dist/writers/callables.js +0 -283
- package/dist/writers/callables.js.map +0 -1
- package/dist/writers/callback.d.ts +0 -16
- package/dist/writers/callback.d.ts.map +0 -1
- package/dist/writers/callback.js +0 -38
- package/dist/writers/callback.js.map +0 -1
- package/dist/writers/class-struct-record.d.ts +0 -31
- package/dist/writers/class-struct-record.d.ts.map +0 -1
- package/dist/writers/class-struct-record.js +0 -67
- package/dist/writers/class-struct-record.js.map +0 -1
- package/dist/writers/class-struct.d.ts +0 -22
- package/dist/writers/class-struct.d.ts.map +0 -1
- package/dist/writers/class-struct.js +0 -85
- package/dist/writers/class-struct.js.map +0 -1
- package/dist/writers/class.d.ts +0 -16
- package/dist/writers/class.d.ts.map +0 -1
- package/dist/writers/class.js +0 -307
- package/dist/writers/class.js.map +0 -1
- package/dist/writers/constant.d.ts +0 -15
- package/dist/writers/constant.d.ts.map +0 -1
- package/dist/writers/constant.js +0 -23
- package/dist/writers/constant.js.map +0 -1
- package/dist/writers/constants.d.ts +0 -15
- package/dist/writers/constants.d.ts.map +0 -1
- package/dist/writers/constants.js +0 -23
- package/dist/writers/constants.js.map +0 -1
- package/dist/writers/constructor-props.d.ts +0 -32
- package/dist/writers/constructor-props.d.ts.map +0 -1
- package/dist/writers/constructor-props.js +0 -110
- package/dist/writers/constructor-props.js.map +0 -1
- package/dist/writers/enum.d.ts +0 -21
- package/dist/writers/enum.d.ts.map +0 -1
- package/dist/writers/enum.js +0 -48
- package/dist/writers/enum.js.map +0 -1
- package/dist/writers/function.d.ts +0 -40
- package/dist/writers/function.d.ts.map +0 -1
- package/dist/writers/function.js +0 -127
- package/dist/writers/function.js.map +0 -1
- package/dist/writers/gtype-binding.d.ts +0 -19
- package/dist/writers/gtype-binding.d.ts.map +0 -1
- package/dist/writers/gtype-binding.js +0 -40
- package/dist/writers/gtype-binding.js.map +0 -1
- package/dist/writers/inheritance.d.ts +0 -48
- package/dist/writers/inheritance.d.ts.map +0 -1
- package/dist/writers/inheritance.js +0 -90
- package/dist/writers/inheritance.js.map +0 -1
- package/dist/writers/interface.d.ts +0 -16
- package/dist/writers/interface.d.ts.map +0 -1
- package/dist/writers/interface.js +0 -155
- package/dist/writers/interface.js.map +0 -1
- package/dist/writers/method.d.ts +0 -150
- package/dist/writers/method.d.ts.map +0 -1
- package/dist/writers/method.js +0 -510
- package/dist/writers/method.js.map +0 -1
- package/dist/writers/param-classify.d.ts +0 -93
- package/dist/writers/param-classify.d.ts.map +0 -1
- package/dist/writers/param-classify.js +0 -163
- package/dist/writers/param-classify.js.map +0 -1
- package/dist/writers/property-accessor.d.ts +0 -19
- package/dist/writers/property-accessor.d.ts.map +0 -1
- package/dist/writers/property-accessor.js +0 -117
- package/dist/writers/property-accessor.js.map +0 -1
- package/dist/writers/registration.d.ts +0 -27
- package/dist/writers/registration.d.ts.map +0 -1
- package/dist/writers/registration.js +0 -30
- package/dist/writers/registration.js.map +0 -1
- package/dist/writers/return-wrap.d.ts +0 -39
- package/dist/writers/return-wrap.d.ts.map +0 -1
- package/dist/writers/return-wrap.js +0 -152
- package/dist/writers/return-wrap.js.map +0 -1
- package/dist/writers/runtime-override.d.ts +0 -18
- package/dist/writers/runtime-override.d.ts.map +0 -1
- package/dist/writers/runtime-override.js.map +0 -1
- package/dist/writers/signal.d.ts +0 -21
- package/dist/writers/signal.d.ts.map +0 -1
- package/dist/writers/signal.js +0 -260
- package/dist/writers/signal.js.map +0 -1
- package/dist/writers/ts-type.d.ts +0 -50
- package/dist/writers/ts-type.d.ts.map +0 -1
- package/dist/writers/ts-type.js +0 -75
- package/dist/writers/ts-type.js.map +0 -1
- package/dist/writers/types-ts.d.ts +0 -27
- package/dist/writers/types-ts.d.ts.map +0 -1
- package/dist/writers/types-ts.js +0 -97
- package/dist/writers/types-ts.js.map +0 -1
- package/dist/writers/value.d.ts +0 -89
- package/dist/writers/value.d.ts.map +0 -1
- package/dist/writers/value.js +0 -402
- package/dist/writers/value.js.map +0 -1
- package/src/dsl/context.ts +0 -146
- package/src/dsl/emit.ts +0 -42
- package/src/dsl/identifier.ts +0 -52
- package/src/dsl/imports.ts +0 -109
- package/src/dsl/module.ts +0 -75
- package/src/ffi/pipeline.ts +0 -113
- package/src/gi-store.ts +0 -199
- package/src/gir/boxed.ts +0 -94
- package/src/gir/qualified-name.ts +0 -55
- package/src/gir/qualify.ts +0 -64
- package/src/gir/repository.ts +0 -149
- package/src/gir/signal.ts +0 -36
- package/src/jsx-store.ts +0 -53
- package/src/react/compounds-meta.ts +0 -99
- package/src/react/compounds.ts +0 -204
- package/src/react/internal.ts +0 -91
- package/src/react/jsx.ts +0 -155
- package/src/react/pipeline.ts +0 -29
- package/src/react/props.ts +0 -307
- package/src/react/slot-props.ts +0 -57
- package/src/react/widgets.ts +0 -185
- package/src/store-fs.ts +0 -157
- package/src/transpile.ts +0 -80
- package/src/typecheck-store.ts +0 -136
- package/src/writers/alias.ts +0 -19
- package/src/writers/async.ts +0 -44
- package/src/writers/boxed-constructor.ts +0 -105
- package/src/writers/boxed-field-accessor.ts +0 -306
- package/src/writers/boxed-layout.ts +0 -166
- package/src/writers/boxed.ts +0 -77
- package/src/writers/callables.ts +0 -339
- package/src/writers/callback.ts +0 -40
- package/src/writers/class-struct-record.ts +0 -75
- package/src/writers/class-struct.ts +0 -96
- package/src/writers/class.ts +0 -384
- package/src/writers/constant.ts +0 -29
- package/src/writers/constructor-props.ts +0 -130
- package/src/writers/enum.ts +0 -53
- package/src/writers/function.ts +0 -136
- package/src/writers/gtype-binding.ts +0 -48
- package/src/writers/inheritance.ts +0 -104
- package/src/writers/interface.ts +0 -168
- package/src/writers/method.ts +0 -678
- package/src/writers/param-classify.ts +0 -178
- package/src/writers/property-accessor.ts +0 -139
- package/src/writers/registration.ts +0 -42
- package/src/writers/return-wrap.ts +0 -180
- package/src/writers/runtime-override.ts +0 -59
- package/src/writers/signal.ts +0 -318
- package/src/writers/ts-type.ts +0 -115
- package/src/writers/value.ts +0 -485
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import type { ElementProp } from "@gtkx/config";
|
|
2
|
+
import { sortStrings, sortStringsBy, toPascalCase } from "@gtkx/utils";
|
|
3
|
+
import { Library } from "../gir/library.js";
|
|
4
|
+
import { type GirNamespace, namespaceDirectory } from "../gir/namespace.js";
|
|
5
|
+
import { dedupeCallables, isEmittableCallable } from "../store/gi/callables.js";
|
|
6
|
+
import { isClassStructRecord } from "../store/gi/class-struct-record.js";
|
|
7
|
+
import { namespaceFunctionExportName } from "../store/gi/function.js";
|
|
8
|
+
import { collectIntrinsicElementClasses, type GlibNamedClass } from "../store/react/intrinsic-elements.js";
|
|
9
|
+
import { createElementPageContext, type ElementPageContext, renderElementPage } from "./element-page.js";
|
|
10
|
+
import { docsSignatureContext, firstSentence, namespaceOrder } from "./render.js";
|
|
11
|
+
import { type GiSymbolEntry, renderSymbolPage, type SymbolPageOptions } from "./symbol-page.js";
|
|
12
|
+
|
|
13
|
+
export type ApiReferenceOptions = {
|
|
14
|
+
libraries: string[];
|
|
15
|
+
girPath: string[];
|
|
16
|
+
elementProps?: Record<string, ElementProp[]>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ApiSymbolKind = GiSymbolEntry["kind"] | "element";
|
|
20
|
+
|
|
21
|
+
export const API_SYMBOL_KINDS: ApiSymbolKind[] = [
|
|
22
|
+
"element",
|
|
23
|
+
"class",
|
|
24
|
+
"interface",
|
|
25
|
+
"record",
|
|
26
|
+
"enum",
|
|
27
|
+
"callback",
|
|
28
|
+
"alias",
|
|
29
|
+
"function",
|
|
30
|
+
"constant",
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export type ApiSymbol = {
|
|
34
|
+
namespace: string;
|
|
35
|
+
name: string;
|
|
36
|
+
kind: ApiSymbolKind;
|
|
37
|
+
summary: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type ApiNamespaceSummary = {
|
|
41
|
+
name: string;
|
|
42
|
+
importPath: string;
|
|
43
|
+
symbols: number;
|
|
44
|
+
elements: number;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ApiLookupResult =
|
|
48
|
+
| { outcome: "page"; symbol: ApiSymbol; markdown: string }
|
|
49
|
+
| { outcome: "ambiguous"; candidates: ApiSymbol[] }
|
|
50
|
+
| { outcome: "notFound" };
|
|
51
|
+
|
|
52
|
+
export type ApiSearchOptions = {
|
|
53
|
+
query: string;
|
|
54
|
+
namespace?: string;
|
|
55
|
+
kinds?: ApiSymbolKind[];
|
|
56
|
+
limit?: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type ElementEntry = {
|
|
60
|
+
kind: "element";
|
|
61
|
+
namespace: GirNamespace;
|
|
62
|
+
name: string;
|
|
63
|
+
doc: string | undefined;
|
|
64
|
+
element: GlibNamedClass;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type SymbolEntry = GiSymbolEntry | ElementEntry;
|
|
68
|
+
|
|
69
|
+
const KIND_SECTION_TITLES: Record<ApiSymbolKind, string> = {
|
|
70
|
+
element: "JSX elements",
|
|
71
|
+
class: "Classes",
|
|
72
|
+
interface: "Interfaces",
|
|
73
|
+
record: "Records",
|
|
74
|
+
enum: "Enums",
|
|
75
|
+
callback: "Callbacks",
|
|
76
|
+
alias: "Aliases",
|
|
77
|
+
function: "Functions",
|
|
78
|
+
constant: "Constants",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const DEFAULT_SEARCH_LIMIT = 20;
|
|
82
|
+
|
|
83
|
+
const compareNames = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
|
|
84
|
+
|
|
85
|
+
class ApiReference {
|
|
86
|
+
private library: Library;
|
|
87
|
+
private libraries: string[];
|
|
88
|
+
private elementContext: ElementPageContext;
|
|
89
|
+
private entries: SymbolEntry[] = [];
|
|
90
|
+
private byQualified = new Map<string, SymbolEntry[]>();
|
|
91
|
+
private byName = new Map<string, SymbolEntry[]>();
|
|
92
|
+
private byNamespace = new Map<string, SymbolEntry[]>();
|
|
93
|
+
private elementsByClass = new Map<string, string>();
|
|
94
|
+
|
|
95
|
+
constructor(options: ApiReferenceOptions) {
|
|
96
|
+
this.libraries = options.libraries;
|
|
97
|
+
this.library = Library.load(options.libraries, options.girPath);
|
|
98
|
+
this.elementContext = createElementPageContext(this.library, options.elementProps ?? {}, () => undefined);
|
|
99
|
+
this.buildIndex();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get girFiles(): string[] {
|
|
103
|
+
return this.library.girFiles;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private add(entry: SymbolEntry): void {
|
|
107
|
+
this.entries.push(entry);
|
|
108
|
+
const push = (map: Map<string, SymbolEntry[]>, key: string): void => {
|
|
109
|
+
const list = map.get(key) ?? [];
|
|
110
|
+
list.push(entry);
|
|
111
|
+
map.set(key, list);
|
|
112
|
+
};
|
|
113
|
+
push(this.byQualified, `${entry.namespace.name}.${entry.name}`.toLowerCase());
|
|
114
|
+
push(this.byName, entry.name.toLowerCase());
|
|
115
|
+
push(this.byNamespace, entry.namespace.name);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private buildIndex(): void {
|
|
119
|
+
for (const namespace of this.library.namespaces.values()) {
|
|
120
|
+
this.indexNamespace(namespace);
|
|
121
|
+
}
|
|
122
|
+
for (const element of collectIntrinsicElementClasses(this.library)) {
|
|
123
|
+
this.add({
|
|
124
|
+
kind: "element",
|
|
125
|
+
namespace: element.namespace,
|
|
126
|
+
name: element.glibName,
|
|
127
|
+
doc: element.klass.doc,
|
|
128
|
+
element,
|
|
129
|
+
});
|
|
130
|
+
this.elementsByClass.set(`${element.namespace.name}.${element.klass.name}`, element.glibName);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private indexNamespace(namespace: GirNamespace): void {
|
|
135
|
+
const entries = [
|
|
136
|
+
...classEntries(namespace),
|
|
137
|
+
...recordEntries(this.library, namespace),
|
|
138
|
+
...valueEntries(namespace),
|
|
139
|
+
];
|
|
140
|
+
for (const entry of entries) {
|
|
141
|
+
this.add(entry);
|
|
142
|
+
}
|
|
143
|
+
this.indexFunctions(namespace);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private indexFunctions(namespace: GirNamespace): void {
|
|
147
|
+
if (namespace.sharedLibrary === undefined) return;
|
|
148
|
+
const docsContext = docsSignatureContext(namespace, this.library);
|
|
149
|
+
for (const fn of dedupeCallables(namespace.functions)) {
|
|
150
|
+
if (!isEmittableCallable(docsContext, fn)) continue;
|
|
151
|
+
const cIdentifier = fn.cIdentifier;
|
|
152
|
+
if (cIdentifier === undefined) continue;
|
|
153
|
+
const name = namespaceFunctionExportName(cIdentifier, fn.name, namespace.cSymbolPrefixes);
|
|
154
|
+
this.add({ kind: "function", namespace, name, doc: fn.doc, fn });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private toApiSymbol(entry: SymbolEntry): ApiSymbol {
|
|
159
|
+
return {
|
|
160
|
+
namespace: entry.namespace.name,
|
|
161
|
+
name: entry.name,
|
|
162
|
+
kind: entry.kind,
|
|
163
|
+
summary: firstSentence(entry.doc),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private symbolPageOptions(): SymbolPageOptions {
|
|
168
|
+
return {
|
|
169
|
+
library: this.library,
|
|
170
|
+
elementNameFor: (namespaceName, className) => this.elementsByClass.get(`${namespaceName}.${className}`),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private renderPage(entry: SymbolEntry): string {
|
|
175
|
+
if (entry.kind === "element") return renderElementPage(entry.element, this.elementContext);
|
|
176
|
+
return renderSymbolPage(entry, this.symbolPageOptions());
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private findNamespace(name: string): GirNamespace | undefined {
|
|
180
|
+
const lower = name.toLowerCase();
|
|
181
|
+
for (const namespace of this.library.namespaces.values()) {
|
|
182
|
+
if (namespace.name.toLowerCase() === lower) return namespace;
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
lookup(query: string, kind?: ApiSymbolKind): ApiLookupResult {
|
|
188
|
+
const trimmed = query.trim();
|
|
189
|
+
if (trimmed.length === 0) return { outcome: "notFound" };
|
|
190
|
+
const qualified = trimmed.includes(".");
|
|
191
|
+
const map = qualified ? this.byQualified : this.byName;
|
|
192
|
+
let candidates = map.get(trimmed.toLowerCase()) ?? [];
|
|
193
|
+
if (kind !== undefined) candidates = candidates.filter((entry) => entry.kind === kind);
|
|
194
|
+
if (candidates.length > 1) {
|
|
195
|
+
const exact = candidates.filter((entry) =>
|
|
196
|
+
qualified ? `${entry.namespace.name}.${entry.name}` === trimmed : entry.name === trimmed,
|
|
197
|
+
);
|
|
198
|
+
if (exact.length > 0) candidates = exact;
|
|
199
|
+
}
|
|
200
|
+
const entry = candidates[0];
|
|
201
|
+
if (entry === undefined) return { outcome: "notFound" };
|
|
202
|
+
if (candidates.length > 1) {
|
|
203
|
+
return { outcome: "ambiguous", candidates: candidates.map((candidate) => this.toApiSymbol(candidate)) };
|
|
204
|
+
}
|
|
205
|
+
return { outcome: "page", symbol: this.toApiSymbol(entry), markdown: this.renderPage(entry) };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
search(options: ApiSearchOptions): ApiSymbol[] {
|
|
209
|
+
const query = options.query.trim().toLowerCase();
|
|
210
|
+
if (query.length === 0) return [];
|
|
211
|
+
const limit = Math.max(1, Math.floor(options.limit ?? DEFAULT_SEARCH_LIMIT));
|
|
212
|
+
const namespaceFilter = options.namespace?.toLowerCase();
|
|
213
|
+
const scored: { score: number; entry: SymbolEntry }[] = [];
|
|
214
|
+
for (const entry of this.entries) {
|
|
215
|
+
if (namespaceFilter !== undefined && entry.namespace.name.toLowerCase() !== namespaceFilter) continue;
|
|
216
|
+
if (options.kinds !== undefined && !options.kinds.includes(entry.kind)) continue;
|
|
217
|
+
const score = searchScore(entry, query);
|
|
218
|
+
if (score === 0) continue;
|
|
219
|
+
scored.push({ score, entry });
|
|
220
|
+
}
|
|
221
|
+
scored.sort(
|
|
222
|
+
(a, b) =>
|
|
223
|
+
b.score - a.score ||
|
|
224
|
+
a.entry.name.length - b.entry.name.length ||
|
|
225
|
+
compareNames(a.entry.name, b.entry.name) ||
|
|
226
|
+
compareNames(namespaceOrder(a.entry.namespace.name), namespaceOrder(b.entry.namespace.name)) ||
|
|
227
|
+
compareNames(a.entry.kind, b.entry.kind),
|
|
228
|
+
);
|
|
229
|
+
return scored.slice(0, limit).map((item) => this.toApiSymbol(item.entry));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
namespaces(): ApiNamespaceSummary[] {
|
|
233
|
+
const summaries = [...this.byNamespace.entries()].map(([name, entries]) => ({
|
|
234
|
+
name,
|
|
235
|
+
importPath: `@gtkx/gi/${namespaceDirectory({ name })}`,
|
|
236
|
+
symbols: entries.filter((entry) => entry.kind !== "element").length,
|
|
237
|
+
elements: entries.filter((entry) => entry.kind === "element").length,
|
|
238
|
+
}));
|
|
239
|
+
return sortStringsBy(summaries, (summary) => namespaceOrder(summary.name));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
symbolNames(namespaceName: string): string[] {
|
|
243
|
+
const namespace = this.findNamespace(namespaceName);
|
|
244
|
+
if (namespace === undefined) return [];
|
|
245
|
+
const entries = this.byNamespace.get(namespace.name) ?? [];
|
|
246
|
+
return sortStrings(entries.map((entry) => entry.name));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
overview(): string {
|
|
250
|
+
const rows = this.namespaces().map(
|
|
251
|
+
(summary) => `| ${summary.name} | \`${summary.importPath}\` | ${summary.symbols} | ${summary.elements} |`,
|
|
252
|
+
);
|
|
253
|
+
const librariesList = this.libraries.map((library) => `\`${library}\``).join(", ");
|
|
254
|
+
return [
|
|
255
|
+
"# API Reference",
|
|
256
|
+
"",
|
|
257
|
+
`Generated bindings for ${librariesList} and the namespaces they pull in. Classes, interfaces, records, enums, callbacks, aliases, functions, and constants are imported from \`@gtkx/gi/<namespace>\`; JSX elements are imported from \`@gtkx/jsx/<namespace>\`.`,
|
|
258
|
+
"",
|
|
259
|
+
"Every symbol has a reference page addressed by its qualified name (for example `Gtk.Button`, `Gtk.Orientation`, `GLib.idleAdd`) and every JSX element by its element name (for example `GtkButton`).",
|
|
260
|
+
"",
|
|
261
|
+
"| Namespace | Import | Symbols | JSX elements |",
|
|
262
|
+
"| --- | --- | --- | --- |",
|
|
263
|
+
...rows,
|
|
264
|
+
"",
|
|
265
|
+
].join("\n");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
namespaceOverview(name: string): string | undefined {
|
|
269
|
+
const namespace = this.findNamespace(name);
|
|
270
|
+
if (namespace === undefined) return undefined;
|
|
271
|
+
const entries = this.byNamespace.get(namespace.name) ?? [];
|
|
272
|
+
const directory = namespaceDirectory(namespace);
|
|
273
|
+
const lines = [
|
|
274
|
+
`# ${namespace.name}`,
|
|
275
|
+
"",
|
|
276
|
+
`\`\`\`ts\nimport * as ${namespace.name} from "@gtkx/gi/${directory}";\n\`\`\``,
|
|
277
|
+
];
|
|
278
|
+
for (const kind of API_SYMBOL_KINDS) {
|
|
279
|
+
const names = entries.filter((entry) => entry.kind === kind).map((entry) => entry.name);
|
|
280
|
+
if (names.length === 0) continue;
|
|
281
|
+
lines.push(
|
|
282
|
+
"",
|
|
283
|
+
`## ${KIND_SECTION_TITLES[kind]} (${names.length})`,
|
|
284
|
+
"",
|
|
285
|
+
sortStrings(names)
|
|
286
|
+
.map((symbolName) => `\`${symbolName}\``)
|
|
287
|
+
.join(", "),
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
lines.push("");
|
|
291
|
+
return lines.join("\n");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type { ApiReference };
|
|
296
|
+
|
|
297
|
+
export const loadApiReference = (options: ApiReferenceOptions): ApiReference => new ApiReference(options);
|
|
298
|
+
|
|
299
|
+
const classEntries = (namespace: GirNamespace): GiSymbolEntry[] => {
|
|
300
|
+
const entries: GiSymbolEntry[] = [];
|
|
301
|
+
for (const klass of [...namespace.classes, ...namespace.interfaces]) {
|
|
302
|
+
if (!klass.introspectable || klass.name.length === 0) continue;
|
|
303
|
+
const kind = klass.isInterface ? "interface" : "class";
|
|
304
|
+
entries.push({ kind, namespace, name: toPascalCase(klass.name), doc: klass.doc, klass });
|
|
305
|
+
}
|
|
306
|
+
return entries;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const recordEntries = (library: Library, namespace: GirNamespace): GiSymbolEntry[] => {
|
|
310
|
+
const entries: GiSymbolEntry[] = [];
|
|
311
|
+
for (const record of namespace.records) {
|
|
312
|
+
if (!record.introspectable || record.isVtable || record.name.length === 0) continue;
|
|
313
|
+
if (isClassStructRecord(library, namespace.name, record)) continue;
|
|
314
|
+
entries.push({ kind: "record", namespace, name: record.name, doc: record.doc, record });
|
|
315
|
+
}
|
|
316
|
+
return entries;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const valueEntries = (namespace: GirNamespace): GiSymbolEntry[] => [
|
|
320
|
+
...namespace.enums
|
|
321
|
+
.filter((enumeration) => enumeration.introspectable)
|
|
322
|
+
.map<GiSymbolEntry>((enumeration) => ({
|
|
323
|
+
kind: "enum",
|
|
324
|
+
namespace,
|
|
325
|
+
name: enumeration.name,
|
|
326
|
+
doc: enumeration.doc,
|
|
327
|
+
enumeration,
|
|
328
|
+
})),
|
|
329
|
+
...namespace.callbacks
|
|
330
|
+
.filter((callback) => callback.introspectable)
|
|
331
|
+
.map<GiSymbolEntry>((callback) => ({
|
|
332
|
+
kind: "callback",
|
|
333
|
+
namespace,
|
|
334
|
+
name: callback.name,
|
|
335
|
+
doc: callback.doc,
|
|
336
|
+
callback,
|
|
337
|
+
})),
|
|
338
|
+
...namespace.aliases.map<GiSymbolEntry>((alias) => ({
|
|
339
|
+
kind: "alias",
|
|
340
|
+
namespace,
|
|
341
|
+
name: alias.name,
|
|
342
|
+
doc: alias.doc,
|
|
343
|
+
alias,
|
|
344
|
+
})),
|
|
345
|
+
...namespace.constants.map<GiSymbolEntry>((constant) => ({
|
|
346
|
+
kind: "constant",
|
|
347
|
+
namespace,
|
|
348
|
+
name: constant.name,
|
|
349
|
+
doc: constant.doc,
|
|
350
|
+
constant,
|
|
351
|
+
})),
|
|
352
|
+
];
|
|
353
|
+
|
|
354
|
+
const searchScore = (entry: SymbolEntry, query: string): number => {
|
|
355
|
+
const name = entry.name.toLowerCase();
|
|
356
|
+
const qualified = `${entry.namespace.name.toLowerCase()}.${name}`;
|
|
357
|
+
if (name === query || qualified === query) return 3;
|
|
358
|
+
if (name.startsWith(query)) return 2;
|
|
359
|
+
if (name.includes(query) || qualified.includes(query)) return 1;
|
|
360
|
+
return 0;
|
|
361
|
+
};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import type { ContainerProp, ElementProp } from "@gtkx/config";
|
|
2
|
+
import { sortStringsBy, toCamelIdentifier, upperFirst } from "@gtkx/utils";
|
|
3
|
+
import { ancestorChain } from "../gir/ancestry.js";
|
|
4
|
+
import type { GirClass } from "../gir/class.js";
|
|
5
|
+
import type { Library } from "../gir/library.js";
|
|
6
|
+
import { type GirNamespace, namespaceDirectory } from "../gir/namespace.js";
|
|
7
|
+
import type { GirSignal } from "../gir/parameter.js";
|
|
8
|
+
import { type GirProperty, isConstructableProperty } from "../gir/property.js";
|
|
9
|
+
import { createElementPropTypegen, type ElementPropTypegen } from "../store/react/element-prop-types.js";
|
|
10
|
+
import { assembleElementProps } from "../store/react/element-props.js";
|
|
11
|
+
import { buildGirIndex, type GirIndex } from "../store/react/gir-index.js";
|
|
12
|
+
import {
|
|
13
|
+
type GlibNamedClass,
|
|
14
|
+
glibNameOf,
|
|
15
|
+
implementedInterfaces,
|
|
16
|
+
newlyImplementedInterfaces,
|
|
17
|
+
signalHandlerName,
|
|
18
|
+
} from "../store/react/intrinsic-elements.js";
|
|
19
|
+
import { isObjectProp } from "../store/react/props.js";
|
|
20
|
+
import {
|
|
21
|
+
classMethodEntries,
|
|
22
|
+
docMarkdown,
|
|
23
|
+
docsDefaultValue,
|
|
24
|
+
firstSentence,
|
|
25
|
+
joinSections,
|
|
26
|
+
metaBlock,
|
|
27
|
+
methodsSectionBlocks,
|
|
28
|
+
originSignatureBlocks,
|
|
29
|
+
renderDocsSignalSignature,
|
|
30
|
+
renderDocsType,
|
|
31
|
+
} from "./render.js";
|
|
32
|
+
|
|
33
|
+
export type ElementPageContext = {
|
|
34
|
+
library: Library;
|
|
35
|
+
girIndex: GirIndex;
|
|
36
|
+
typegen: ElementPropTypegen;
|
|
37
|
+
elementProps: Record<string, ElementProp[]>;
|
|
38
|
+
linkFor: (glibName: string) => string | undefined;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const createElementPageContext = (
|
|
42
|
+
library: Library,
|
|
43
|
+
elementProps: Record<string, ElementProp[]>,
|
|
44
|
+
linkFor: (glibName: string) => string | undefined,
|
|
45
|
+
): ElementPageContext => {
|
|
46
|
+
const girIndex = buildGirIndex(library);
|
|
47
|
+
const applied = assembleElementProps(girIndex, elementProps);
|
|
48
|
+
return {
|
|
49
|
+
library,
|
|
50
|
+
girIndex,
|
|
51
|
+
typegen: createElementPropTypegen(girIndex, applied),
|
|
52
|
+
elementProps: applied,
|
|
53
|
+
linkFor,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type MemberOwner = {
|
|
58
|
+
klass: GirClass;
|
|
59
|
+
namespace: GirNamespace;
|
|
60
|
+
origin: string | undefined;
|
|
61
|
+
glibName: string | undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type PropEntry = {
|
|
65
|
+
name: string;
|
|
66
|
+
meta: string;
|
|
67
|
+
doc: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const frontmatter = (entry: GlibNamedClass): string => {
|
|
71
|
+
const sentence = firstSentence(entry.klass.doc);
|
|
72
|
+
const description = sentence.length > 0 ? sentence : `API reference for the ${entry.glibName} element.`;
|
|
73
|
+
return `---\ndescription: ${JSON.stringify(description)}\n---`;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const importBlock = (entry: GlibNamedClass): string =>
|
|
77
|
+
`\`\`\`tsx\nimport { ${entry.glibName} } from "@gtkx/jsx/${namespaceDirectory(entry.namespace)}";\n\`\`\``;
|
|
78
|
+
|
|
79
|
+
const glibLabel = (context: ElementPageContext, glibName: string): string => {
|
|
80
|
+
const link = context.linkFor(glibName);
|
|
81
|
+
return link === undefined ? `\`${glibName}\`` : `[${glibName}](${link})`;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const hierarchySection = (entry: GlibNamedClass, context: ElementPageContext): string[] => {
|
|
85
|
+
const ancestors = [...ancestorChain(context.library, entry.klass, entry.namespace.name)].slice(1).reverse();
|
|
86
|
+
if (ancestors.length === 0) return [];
|
|
87
|
+
const parts = ancestors.map((ancestor) => {
|
|
88
|
+
const glib = glibNameOf(ancestor.klass);
|
|
89
|
+
return glib === undefined ? `\`${ancestor.namespaceName}.${ancestor.klass.name}\`` : glibLabel(context, glib);
|
|
90
|
+
});
|
|
91
|
+
parts.push(`**${entry.glibName}**`);
|
|
92
|
+
const lines = [`## Hierarchy`, parts.join(" → ")];
|
|
93
|
+
const interfaces = implementedInterfaces(entry.klass, entry.namespace, context.library)
|
|
94
|
+
.map((iface) => glibNameOf(iface.klass))
|
|
95
|
+
.filter((name): name is string => name !== undefined);
|
|
96
|
+
if (interfaces.length > 0) {
|
|
97
|
+
lines.push(`Implements ${interfaces.map((name) => `\`${name}\``).join(", ")}.`);
|
|
98
|
+
}
|
|
99
|
+
return lines;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const callName = (call: ContainerProp["append"]): string | undefined =>
|
|
103
|
+
call === undefined ? undefined : typeof call === "string" ? call : call.method;
|
|
104
|
+
|
|
105
|
+
const containerLine = (prop: ContainerProp, context: ElementPageContext): string => {
|
|
106
|
+
const child = glibLabel(context, prop.child);
|
|
107
|
+
const attach = callName(prop.append);
|
|
108
|
+
const detail: string[] = [];
|
|
109
|
+
if (attach !== undefined) detail.push(`attached with \`${attach}()\``);
|
|
110
|
+
if (prop.autowrap !== undefined) {
|
|
111
|
+
detail.push(`children are wrapped in a ${glibLabel(context, prop.autowrap)} before attaching`);
|
|
112
|
+
}
|
|
113
|
+
const suffix = detail.length > 0 ? ` (${detail.join("; ")})` : "";
|
|
114
|
+
if (prop.prop === "children") return `- \`children\` accepts ${child} elements${suffix}.`;
|
|
115
|
+
return `- \`${prop.prop}\` is a slot accepting ${child} elements${suffix}.`;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const childrenSection = (entry: GlibNamedClass, context: ElementPageContext): string[] => {
|
|
119
|
+
const lines: string[] = [];
|
|
120
|
+
const seen = new Set<string>();
|
|
121
|
+
for (const owner of memberOwners(entry, context)) {
|
|
122
|
+
if (owner.glibName === undefined) continue;
|
|
123
|
+
const overlays = context.elementProps[owner.glibName] ?? [];
|
|
124
|
+
const containers = overlays.filter(
|
|
125
|
+
(prop): prop is ContainerProp => prop.kind === "container" && !seen.has(prop.prop),
|
|
126
|
+
);
|
|
127
|
+
for (const prop of containers) lines.push(containerLine(prop, context));
|
|
128
|
+
for (const prop of containers) seen.add(prop.prop);
|
|
129
|
+
}
|
|
130
|
+
if (!seen.has("children") && context.typegen.acceptsChildren(entry.glibName)) {
|
|
131
|
+
lines.push("- `children` accepts child elements.");
|
|
132
|
+
}
|
|
133
|
+
if (lines.length === 0) return [];
|
|
134
|
+
return ["## Children", lines.join("\n")];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const memberOwners = (entry: GlibNamedClass, context: ElementPageContext): MemberOwner[] => [
|
|
138
|
+
{ klass: entry.klass, namespace: entry.namespace, origin: undefined, glibName: entry.glibName },
|
|
139
|
+
...newlyImplementedInterfaces(
|
|
140
|
+
entry.klass,
|
|
141
|
+
entry.namespace,
|
|
142
|
+
context.library,
|
|
143
|
+
(glibName) => glibName !== undefined && context.typegen.containerPropNamesFor(glibName).length > 0,
|
|
144
|
+
).map((iface) => {
|
|
145
|
+
const glibName = glibNameOf(iface.klass);
|
|
146
|
+
return { klass: iface.klass, namespace: iface.namespace, origin: glibName, glibName };
|
|
147
|
+
}),
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
const propertyEntry = (
|
|
151
|
+
context: ElementPageContext,
|
|
152
|
+
owner: MemberOwner,
|
|
153
|
+
property: GirProperty,
|
|
154
|
+
jsName: string,
|
|
155
|
+
): PropEntry => {
|
|
156
|
+
const object = isObjectProp(
|
|
157
|
+
{ library: context.library, klass: owner.klass, namespace: owner.namespace },
|
|
158
|
+
property,
|
|
159
|
+
jsName,
|
|
160
|
+
);
|
|
161
|
+
const baseType = renderDocsType(context.library, property.type, false);
|
|
162
|
+
const type = object ? `${baseType} | ReactElement` : baseType;
|
|
163
|
+
const meta: string[] = [`\`${type}\``];
|
|
164
|
+
if (property.defaultValue !== undefined) meta.push(`default \`${docsDefaultValue(property.defaultValue)}\``);
|
|
165
|
+
if (property.constructOnly) meta.push("construct-only");
|
|
166
|
+
if (!isConstructableProperty(property)) meta.push(`read-only, observe with \`onNotify${upperFirst(jsName)}\``);
|
|
167
|
+
if (owner.origin !== undefined) meta.push(`from \`${owner.origin}\``);
|
|
168
|
+
return { name: jsName, meta: meta.join(" · "), doc: docMarkdown(property.doc) };
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const overlayNote = (overlays: ElementProp[], name: string): string | undefined => {
|
|
172
|
+
for (const overlay of overlays) {
|
|
173
|
+
if (overlay.kind === "container" || overlay.prop !== name) continue;
|
|
174
|
+
if (overlay.kind === "value") return `Applied with \`${callName(overlay.call)}()\`.`;
|
|
175
|
+
if (overlay.kind === "list") {
|
|
176
|
+
const applied = (Array.isArray(overlay.add) ? overlay.add : [overlay.add])
|
|
177
|
+
.map((call) => `\`${callName(call)}()\``)
|
|
178
|
+
.join(", ");
|
|
179
|
+
return `Array prop; items are applied with ${applied}.`;
|
|
180
|
+
}
|
|
181
|
+
if (overlay.kind === "controlled-text") {
|
|
182
|
+
return "Controlled: the element is synced to the prop value whenever that value changes; text the user has typed is preserved rather than reverted on every render.";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const cleanOverlayType = (type: string): string => type.replace(/\s*\|\s*undefined$/, "").replaceAll("$.", ".");
|
|
189
|
+
|
|
190
|
+
const overlayEntries = (entry: GlibNamedClass, context: ElementPageContext, seen: Set<string>): PropEntry[] => {
|
|
191
|
+
const overlays = context.elementProps[entry.glibName] ?? [];
|
|
192
|
+
const entries: PropEntry[] = [];
|
|
193
|
+
const lines = context.typegen.classPropLines(entry.glibName, entry.klass, entry.namespace, new Map());
|
|
194
|
+
for (const line of lines) {
|
|
195
|
+
const match = line.match(/^([A-Za-z0-9_]+)\?: (.*);$/);
|
|
196
|
+
if (match === null) continue;
|
|
197
|
+
const [, name = "", rawType = ""] = match;
|
|
198
|
+
if (seen.has(name)) continue;
|
|
199
|
+
seen.add(name);
|
|
200
|
+
const note = overlayNote(overlays, name) ?? "Element prop managed by GTKX.";
|
|
201
|
+
entries.push({ name, meta: `\`${cleanOverlayType(rawType)}\``, doc: note });
|
|
202
|
+
}
|
|
203
|
+
return entries;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const withOverlayNote = (propEntry: PropEntry, note: string | undefined): PropEntry => {
|
|
207
|
+
if (note === undefined) return propEntry;
|
|
208
|
+
return { ...propEntry, doc: propEntry.doc.length > 0 ? `${note}\n\n${propEntry.doc}` : note };
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const propertyEntries = (entry: GlibNamedClass, context: ElementPageContext, seen: Set<string>): PropEntry[] => {
|
|
212
|
+
const owners = memberOwners(entry, context);
|
|
213
|
+
const overlays = owners.flatMap((owner) =>
|
|
214
|
+
owner.glibName === undefined ? [] : (context.elementProps[owner.glibName] ?? []),
|
|
215
|
+
);
|
|
216
|
+
const entries: PropEntry[] = [];
|
|
217
|
+
for (const owner of owners) {
|
|
218
|
+
for (const property of owner.klass.properties) {
|
|
219
|
+
if (!property.introspectable) continue;
|
|
220
|
+
const jsName = toCamelIdentifier(property.name);
|
|
221
|
+
if (seen.has(jsName)) continue;
|
|
222
|
+
seen.add(jsName);
|
|
223
|
+
const propEntry = propertyEntry(context, owner, property, jsName);
|
|
224
|
+
entries.push(withOverlayNote(propEntry, overlayNote(overlays, jsName)));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return entries;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const propsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {
|
|
231
|
+
const seen = new Set<string>();
|
|
232
|
+
const entries = [...propertyEntries(entry, context, seen), ...overlayEntries(entry, context, seen)];
|
|
233
|
+
const intro = [
|
|
234
|
+
`\`ref\` receives the \`${selfType}\` instance.`,
|
|
235
|
+
`Every mutable property also has an \`onNotify<Prop>\` handler prop called with the new value when the property changes.`,
|
|
236
|
+
`Props inherited from ancestor elements are documented on their own pages.`,
|
|
237
|
+
].join(" ");
|
|
238
|
+
if (entries.length === 0) return ["## Props", intro];
|
|
239
|
+
const sorted = sortStringsBy(entries, (item) => item.name);
|
|
240
|
+
return ["## Props", intro, ...sorted.map((item) => metaBlock(item.name, item.meta, item.doc))];
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
type SignalEntry = {
|
|
244
|
+
name: string;
|
|
245
|
+
signature: string;
|
|
246
|
+
doc: string;
|
|
247
|
+
origin: string | undefined;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const signalsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {
|
|
251
|
+
const seen = new Set<string>();
|
|
252
|
+
const entries: SignalEntry[] = [];
|
|
253
|
+
const acceptSignal = (signal: GirSignal, origin: string | undefined): void => {
|
|
254
|
+
const name = signalHandlerName(signal.name);
|
|
255
|
+
if (seen.has(name)) return;
|
|
256
|
+
seen.add(name);
|
|
257
|
+
entries.push({
|
|
258
|
+
name,
|
|
259
|
+
signature: renderDocsSignalSignature(context.library, signal, selfType),
|
|
260
|
+
doc: docMarkdown(signal.doc),
|
|
261
|
+
origin,
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
for (const owner of memberOwners(entry, context)) {
|
|
265
|
+
for (const signal of owner.klass.signals) acceptSignal(signal, owner.origin);
|
|
266
|
+
}
|
|
267
|
+
if (entries.length === 0) return [];
|
|
268
|
+
return ["## Signals", ...originSignatureBlocks(entries)];
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const methodsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {
|
|
272
|
+
const entries = classMethodEntries(context.library, entry.namespace, entry.klass);
|
|
273
|
+
const intro = `Methods are called on the \`${selfType}\` instance, obtained with the \`ref\` prop or imported from \`@gtkx/gi/${namespaceDirectory(entry.namespace)}\`. Methods inherited from ancestors are documented on their own pages.`;
|
|
274
|
+
return methodsSectionBlocks(entries, intro);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export const renderElementPage = (entry: GlibNamedClass, context: ElementPageContext): string => {
|
|
278
|
+
const selfType = `${entry.namespace.name}.${entry.klass.name}`;
|
|
279
|
+
return joinSections([
|
|
280
|
+
frontmatter(entry),
|
|
281
|
+
`# ${entry.glibName}`,
|
|
282
|
+
docMarkdown(entry.klass.doc),
|
|
283
|
+
importBlock(entry),
|
|
284
|
+
...hierarchySection(entry, context),
|
|
285
|
+
...childrenSection(entry, context),
|
|
286
|
+
...propsSection(entry, context, selfType),
|
|
287
|
+
...signalsSection(entry, context, selfType),
|
|
288
|
+
...methodsSection(entry, context, selfType),
|
|
289
|
+
]);
|
|
290
|
+
};
|