Skip to content

Commit d2bf5af

Browse files
committed
Add improved docs
1 parent 6311a35 commit d2bf5af

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Diff for: lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const search = /[#.]/g
1313
* @template {string} [DefaultTagName='div']
1414
* Type of default tag name.
1515
* @param {Selector | null | undefined} [selector]
16-
* A simple CSS selector.
16+
* Simple CSS selector.
1717
*
1818
* Can contain a tag-name (`foo`), classes (`.bar`), and an ID (`#baz`).
1919
* Multiple classes are allowed.

Diff for: readme.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`parseSelector([selector][, defaultTagName])`](#parseselectorselector-defaulttagname)
20+
* [`parseSelector(selector?[, defaultTagName])`](#parseselectorselector-defaulttagname)
2121
* [Types](#types)
2222
* [Compatibility](#compatibility)
2323
* [Security](#security)
@@ -38,7 +38,7 @@ You probably want the more powerful [`hastscript`][hastscript] or
3838
## Install
3939

4040
This package is [ESM only][esm].
41-
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
41+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
4242

4343
```sh
4444
npm install hast-util-parse-selector
@@ -77,37 +77,39 @@ Yields:
7777

7878
## API
7979

80-
This package exports the identifier `parseSelector`.
80+
This package exports the identifier [`parseSelector`][parseselector].
8181
There is no default export.
8282

83-
### `parseSelector([selector][, defaultTagName])`
83+
### `parseSelector(selector?[, defaultTagName])`
8484

85-
Create an [*element*][element] [*node*][node] from a simple CSS selector.
85+
Create a hast element from a simple CSS selector.
8686

8787
###### Parameters
8888

8989
* `selector` (`string`, optional)
90-
— can contain a tag name (`foo`), classes (`.bar`), and an ID (`#baz`),
91-
multiple classes are allowed, and uses the last ID if multiple IDs are found
90+
— simple CSS selector, can contain a tag name (`foo`), classes (`.bar`),
91+
and an ID (`#baz`), multiple classes are allowed, uses the last ID if
92+
multiple IDs are found
9293
* `defaultTagName` (`string`, default: `'div'`)
9394
— tag name to use if `selector` does not specify one
9495

9596
###### Returns
9697

97-
[`Element`][element].
98+
Built element ([`Element`][element]).
9899

99100
## Types
100101

101102
This package is fully typed with [TypeScript][].
102103
It exports no additional types.
104+
103105
In TypeScript 4.2+, the type system can infer the tag name of literal
104106
`selector`s and knows that the return element has that name.
105107

106108
## Compatibility
107109

108110
Projects maintained by the unified collective are compatible with all maintained
109111
versions of Node.js.
110-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
112+
As of now, that is Node.js 14.14+ and 16.0+.
111113
Our projects sometimes work with older versions, but this is not guaranteed.
112114

113115
## Security
@@ -194,8 +196,8 @@ abide by its terms.
194196

195197
[hast-util-from-selector]: https://github.com/syntax-tree/hast-util-from-selector
196198

197-
[node]: https://github.com/syntax-tree/hast#nodes
198-
199199
[element]: https://github.com/syntax-tree/hast#element
200200

201201
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
202+
203+
[parseselector]: #parseselectorselector-defaulttagname

0 commit comments

Comments
 (0)