Skip to content

Commit

Permalink
Add missing inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Mar 1, 2024
1 parent fde3379 commit c4ed721
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,37 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {import('./lib/index.js').CreateEvaluater<JsxFunction>} CreateEvaluater
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {import('./lib/index.js').EvaluateExpression<JsxFunction>} EvaluateExpression
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {import('./lib/index.js').Evaluater<JsxFunction>} Evaluater
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {import('./lib/index.js').JsxDev<JsxFunction>} JsxDev
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {import('./lib/index.js').Options<JsxFunction>} Options
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {import('./lib/index.js').Props<JsxFunction>} Props
*/

Expand Down
47 changes: 47 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {ReturnType<JsxFunction> | string | null | undefined} Child
* Child.
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @callback Create
* Create something in development or production.
* @param {Nodes} node
Expand All @@ -53,6 +55,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @callback CreateEvaluater
* Create an evaluator that turns ESTree ASTs from embedded MDX into values.
* @returns {Evaluater<JsxFunction>}
Expand All @@ -69,6 +72,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @callback EvaluateExpression
* Turn an MDX expression into a value.
* @param {Expression} expression
Expand All @@ -90,6 +94,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef Evaluater
* Evaluator that turns ESTree ASTs from embedded MDX into values.
* @property {EvaluateExpression<JsxFunction>} evaluateExpression
Expand All @@ -105,33 +110,46 @@

/**
* @template [JsxElementType=any]
* Element type: `Fragment` symbol, tag name (`string`), component.
* @template [JsxProps=any]
* Element props, `children`, and maybe `node`.
* @template [JsxKey=any]
* Dynamicly generated key to use.
* @template [JsxElement=any]
* Analogous to `JSX.Element`.
* @callback Jsx
* Create a production element.
* @param {JsxElementType} type
* Element type: `Fragment` symbol, tag name (`string`), component.
* @param {JsxProps} props
* Element props, `children`, and maybe `node`.
* @param {JsxKey} [key]
* Dynamicly generated key to use.
* @returns {JsxElement}
* Element from your framework.
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {Parameters<JsxFunction>[0]} GetType
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {Parameters<JsxFunction>[1]} GetProps
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {Parameters<JsxFunction>[2]} GetKey
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @callback JsxDev
* Create a development element.
* @param {GetType<JsxFunction>} type
Expand All @@ -153,6 +171,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {{
* children?: Array<Child<JsxFunction>> | Child<JsxFunction>, node?: Element | MdxJsxFlowElement | MdxJsxTextElement | undefined,
* [prop: string]: Array<Child<JsxFunction>> | Child<JsxFunction> | Element | MdxJsxFlowElement | MdxJsxTextElement | Value | undefined
Expand All @@ -162,6 +181,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef RegularFields
* Configuration.
* @property {Record<string, GetType<JsxFunction>>} [components]
Expand Down Expand Up @@ -200,6 +220,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef RuntimeDevelopment
* Runtime fields when development is on.
* @property {GetType<JsxFunction>} Fragment
Expand All @@ -216,6 +237,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef RuntimeProduction
* Runtime fields when development is off.
* @property {GetType<JsxFunction>} Fragment
Expand All @@ -231,6 +253,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef RuntimeUnknown
* Runtime fields when development might be on or off.
* @property {GetType<JsxFunction>} Fragment
Expand Down Expand Up @@ -269,6 +292,7 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef State
* Info passed around.
* @property {GetType<JsxFunction>} Fragment
Expand Down Expand Up @@ -319,24 +343,28 @@

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {RuntimeDevelopment<JsxFunction> & RegularFields<JsxFunction>} Development
* Configuration (development).
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {Development<JsxFunction> | Production<JsxFunction>} Options
* Configuration.
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {RegularFields<JsxFunction> & RuntimeProduction<JsxFunction>} Production
* Configuration (production).
*/

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @typedef {RegularFields<JsxFunction> & RuntimeUnknown<JsxFunction>} Unknown
* Configuration (production or development).
*/
Expand Down Expand Up @@ -381,6 +409,7 @@ const docs = 'https://github.com/syntax-tree/hast-util-to-jsx-runtime'
* with an automatic JSX runtime.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {Nodes} tree
* Tree to transform.
* @param {Options<JsxFunction>} options
Expand Down Expand Up @@ -455,6 +484,7 @@ export function toJsxRuntime(tree, options) {
* Transform a node.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {Nodes} node
Expand Down Expand Up @@ -494,6 +524,7 @@ function one(state, node, key) {
* Handle element.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {Element} node
Expand Down Expand Up @@ -538,6 +569,7 @@ function element(state, node, key) {
* Handle MDX expression.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {MdxFlowExpression | MdxTextExpression} node
Expand All @@ -564,6 +596,7 @@ function mdxExpression(state, node) {
* Handle MDX ESM.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {MdxjsEsm} node
Expand All @@ -587,6 +620,7 @@ function mdxEsm(state, node) {
*
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {MdxJsxFlowElement | MdxJsxTextElement} node
Expand Down Expand Up @@ -628,6 +662,7 @@ function mdxJsxElement(state, node, key) {
* Handle root.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {Root} node
Expand All @@ -650,6 +685,7 @@ function root(state, node, key) {
* Handle text.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} _
* Info passed around.
* @param {Text} node
Expand All @@ -665,6 +701,7 @@ function text(_, node) {
* Add `node` to props.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {Props<JsxFunction>} props
Expand All @@ -687,6 +724,7 @@ function addNode(state, props, type, node) {
* Add children to props.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {Props<JsxFunction>} props
* Props.
* @param {Array<Child<JsxFunction>>} children
Expand All @@ -706,6 +744,7 @@ function addChildren(props, children) {

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {string | undefined} _
* Path to file.
* @param {JsxFunction} jsx
Expand All @@ -728,6 +767,7 @@ function productionCreate(_, jsx, jsxs) {

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {string | undefined} filePath
* Path to file.
* @param {JsxDev<JsxFunction>} jsxDEV
Expand Down Expand Up @@ -761,6 +801,7 @@ function developmentCreate(filePath, jsxDEV) {
* Create props from an element.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {Element} node
Expand Down Expand Up @@ -811,6 +852,7 @@ function createElementProps(state, node) {
* Create props from a JSX element.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {MdxJsxFlowElement | MdxJsxTextElement} node
Expand Down Expand Up @@ -876,6 +918,7 @@ function createJsxElementProps(state, node) {
* Create children.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {Parents} node
Expand Down Expand Up @@ -924,6 +967,7 @@ function createChildren(state, node) {
* Handle a property.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {string} prop
Expand Down Expand Up @@ -975,6 +1019,7 @@ function createProperty(state, prop, value) {
* Parse a CSS declaration to an object.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* Info passed around.
* @param {string} value
Expand Down Expand Up @@ -1035,6 +1080,7 @@ function parseStyle(state, value) {
* Create a JSX name from a string.
*
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* To do.
* @param {string} name
Expand Down Expand Up @@ -1101,6 +1147,7 @@ function findComponentFromName(state, name, allowExpression) {

/**
* @template {Jsx} [JsxFunction=Jsx]
* The type of the `jsx` function impoted from `${jsxImportSource}/jsx-runtime`.
* @param {State<JsxFunction>} state
* @param {Position | undefined} [place]
* @returns {never}
Expand Down

0 comments on commit c4ed721

Please sign in to comment.