Skip to content

Commit bdd8492

Browse files
committed
Refactor to improve docs
1 parent a7bf98b commit bdd8492

File tree

2 files changed

+56
-89
lines changed

2 files changed

+56
-89
lines changed

lib/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
* @typedef {'html' | 'svg'} Space
4848
* Namespace.
4949
*
50+
* > 👉 **Note**: hast is not XML.
51+
* > It supports SVG as embedded in HTML.
52+
* > It does not support the features available in XML.
53+
* > Passing SVG might break but fragments of modern SVG should be fine.
54+
* > Use `xast` if you need to support SVG as XML.
55+
*
5056
* @typedef {'html' | 'react'} ElementAttributeNameCase
5157
* Casing to use for attribute names.
5258
*
@@ -121,9 +127,6 @@
121127
* Configuration.
122128
* @property {Partial<Components> | null | undefined} [components]
123129
* Components to use.
124-
*
125-
* Each key is the name of an HTML (or SVG) element to override.
126-
* The value is the component to render instead.
127130
* @property {string | null | undefined} [filePath]
128131
* File path to the original source file.
129132
*
@@ -146,12 +149,6 @@
146149
* automatically switches to and from the SVG space when entering and exiting
147150
* it.
148151
*
149-
* > 👉 **Note**: hast is not XML.
150-
* > It supports SVG as embedded in HTML.
151-
* > It does not support the features available in XML.
152-
* > Passing SVG might break but fragments of modern SVG should be fine.
153-
* > Use `xast` if you need to support SVG as XML.
154-
*
155152
* @typedef RuntimeUnknown
156153
* Runtime fields when development might be on or off.
157154
* @property {Fragment} Fragment

readme.md

Lines changed: 50 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ with an automatic JSX runtime.
2020
* [API](#api)
2121
* [`toJsxRuntime(tree, options)`](#tojsxruntimetree-options)
2222
* [`Options`](#options)
23-
* [`Components`](#components-1)
24-
* [`ElementAttributeNameCase`](#elementattributenamecase-1)
25-
* [`Fragment`](#fragment-1)
26-
* [`Jsx`](#jsx-1)
27-
* [`JsxDev`](#jsxdev-1)
23+
* [`Components`](#components)
24+
* [`ElementAttributeNameCase`](#elementattributenamecase)
25+
* [`Fragment`](#fragment)
26+
* [`Jsx`](#jsx)
27+
* [`JsxDev`](#jsxdev)
2828
* [`Props`](#props)
2929
* [`Source`](#source)
30-
* [`Space`](#space-1)
31-
* [`StylePropertyNameCase`](#stylepropertynamecase-1)
30+
* [`Space`](#space)
31+
* [`StylePropertyNameCase`](#stylepropertynamecase)
3232
* [Examples](#examples)
3333
* [Example: Preact](#example-preact)
3434
* [Example: Vue](#example-vue)
@@ -128,73 +128,37 @@ Result from your configured JSX runtime (`JSX.Element`).
128128

129129
Configuration (TypeScript type).
130130

131-
##### Fields
132-
133-
###### `Fragment`
134-
135-
Fragment ([`Fragment`][api-fragment], required).
136-
137-
###### `jsx`
138-
139-
Dynamic JSX ([`Jsx`][api-jsx], required in production).
140-
141-
###### `jsxs`
142-
143-
Static JSX ([`Jsx`][api-jsx], required in production).
144-
145-
###### `jsxDEV`
146-
147-
Development JSX ([`JsxDev`][api-jsx-dev], required in development).
148-
149-
###### `development`
150-
151-
Whether to use `jsxDEV` when on or `jsx` and `jsxs` when off (`boolean`,
152-
default: `false`).
153-
154-
###### `components`
155-
156-
Components to use ([`Partial<Components>`][api-components], optional).
157-
158-
Each key is the name of an HTML (or SVG) element to override.
159-
The value is the component to render instead.
160-
161-
###### `elementAttributeNameCase`
162-
163-
Specify casing to use for attribute names
164-
([`ElementAttributeNameCase`][api-element-attribute-name-case], default:
165-
`'react'`).
166-
167-
###### `filePath`
168-
169-
File path to the original source file (`string`, optional).
170-
171-
Passed in source info to `jsxDEV` when using the automatic runtime with
172-
`development: true`.
173-
174-
###### `passNode`
175-
176-
Pass the hast element node to components (`boolean`, default: `false`).
177-
178-
###### `space`
179-
180-
Whether `tree` is in the `'html'` or `'svg'` space ([`Space`][api-space],
181-
default: `'html'`).
182-
183-
When an `<svg>` element is found in the HTML space, this package already
184-
automatically switches to and from the SVG space when entering and exiting
185-
it.
186-
187-
> 👉 **Note**: hast is not XML.
188-
> It supports SVG as embedded in HTML.
189-
> It does not support the features available in XML.
190-
> Passing SVG might break but fragments of modern SVG should be fine.
191-
> Use `xast` if you need to support SVG as XML.
192-
193-
###### `stylePropertyNameCase`
131+
###### Fields
194132

195-
Specify casing to use for property names in `style` objects
196-
([`StylePropertyNameCase`][api-style-property-name-case], default:
197-
`'dom'`).
133+
* `Fragment` ([`Fragment`][api-fragment], required)
134+
— fragment
135+
* `jsx` ([`Jsx`][api-jsx], required in production)
136+
— dynamic JSX
137+
* `jsxs` ([`Jsx`][api-jsx], required in production)
138+
— static JSX
139+
* `jsxDEV` ([`JsxDev`][api-jsx-dev], required in development)
140+
— development JSX
141+
* `development` (`boolean`, default: `false`)
142+
— whether to use `jsxDEV` when on or `jsx` and `jsxs` when off
143+
* `components` ([`Partial<Components>`][api-components], optional)
144+
— components to use
145+
* `elementAttributeNameCase`
146+
([`ElementAttributeNameCase`][api-element-attribute-name-case],
147+
default: `'react'`)
148+
— specify casing to use for attribute names
149+
* `filePath` (`string`, optional)
150+
— file path to the original source file, passed in source info to `jsxDEV`
151+
when using the automatic runtime with `development: true`
152+
* `passNode` (`boolean`, default: `false`)
153+
— pass the hast element node to components
154+
* `space` ([`Space`][api-space], default: `'html'`)
155+
— whether `tree` is in the `'html'` or `'svg'` space, when an `<svg>`
156+
element is found in the HTML space, this package already automatically
157+
switches to and from the SVG space when entering and exiting it
158+
* `stylePropertyNameCase`
159+
([`StylePropertyNameCase`][api-style-property-name-case],
160+
default: `'dom'`)
161+
— specify casing to use for property names in `style` objects
198162

199163
### `Components`
200164

@@ -331,6 +295,12 @@ Info about source (TypeScript type).
331295
332296
Namespace (TypeScript type).
333297
298+
> 👉 **Note**: hast is not XML.
299+
> It supports SVG as embedded in HTML.
300+
> It does not support the features available in XML.
301+
> Passing SVG might break but fragments of modern SVG should be fine.
302+
> Use `xast` if you need to support SVG as XML.
303+
334304
###### Type
335305
336306
```ts
@@ -637,22 +607,22 @@ abide by its terms.
637607

638608
[api-to-jsx-runtime]: #tojsxruntimetree-options
639609

640-
[api-components]: #components-1
610+
[api-components]: #components
641611

642-
[api-element-attribute-name-case]: #elementattributenamecase-1
612+
[api-element-attribute-name-case]: #elementattributenamecase
643613

644-
[api-fragment]: #fragment-1
614+
[api-fragment]: #fragment
645615

646-
[api-jsx]: #jsx-1
616+
[api-jsx]: #jsx
647617

648-
[api-jsx-dev]: #jsxdev-1
618+
[api-jsx-dev]: #jsxdev
649619

650620
[api-options]: #options
651621

652622
[api-props]: #props
653623

654624
[api-source]: #source
655625

656-
[api-space]: #space-1
626+
[api-space]: #space
657627

658-
[api-style-property-name-case]: #stylepropertynamecase-1
628+
[api-style-property-name-case]: #stylepropertynamecase

0 commit comments

Comments
 (0)