Skip to content

Commit f65943a

Browse files
committed
Refactor docs
1 parent 1635e2f commit f65943a

File tree

115 files changed

+1089
-618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1089
-618
lines changed

packages/hast-util-from-string/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@
4646
*
4747
* Set the plain-text value of a node.
4848
*
49-
* * if `node` is a text node (has a `value` property; as in, `comment`,
50-
* `text`), set that to the given `value` or an empty string
51-
* * Otherwise, if `node` is a parent node (has `children`; as in, `element`,
52-
* `root`), replace them with a text node whose data is set to the given
53-
* `value`, or if `value` is not given, remove all its children
54-
*
5549
* ###### Parameters
5650
*
5751
* * `node` (`Node`) — node to change
@@ -60,6 +54,12 @@
6054
* ###### Returns
6155
*
6256
* Nothing (`undefined`).
57+
*
58+
* ###### Algorithm
59+
*
60+
* * if `node` is a `comment` or `text` node, sets its `value`
61+
* * if `node` is an `element` or `root`, replaces its children with a text
62+
* node for `value`
6363
*/
6464

6565
export {fromString} from './lib/index.js'

packages/hast-util-from-string/lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/**
66
* Set the plain-text value of a hast node.
7+
*
78
* This is like the DOMs `Node#textContent` setter.
89
* The given node is returned.
910
*

packages/hast-util-from-string/readme.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,14 @@ console.log(div)
9292

9393
## API
9494

95-
This package exports the following identifiers:
95+
This package exports the identifier
9696
`fromString`.
9797
There is no default export.
9898

9999
### `fromString(node[, value])`
100100

101101
Set the plain-text value of a node.
102102

103-
* if `node` is a text node (has a `value` property; as in, `comment`,
104-
`text`), set that to the given `value` or an empty string
105-
* Otherwise, if `node` is a parent node (has `children`; as in, `element`,
106-
`root`), replace them with a text node whose data is set to the given
107-
`value`, or if `value` is not given, remove all its children
108-
109103
###### Parameters
110104

111105
* `node` (`Node`) — node to change
@@ -115,25 +109,35 @@ Set the plain-text value of a node.
115109

116110
Nothing (`undefined`).
117111

112+
###### Algorithm
113+
114+
* if `node` is a `comment` or `text` node, sets its `value`
115+
* if `node` is an `element` or `root`, replaces its children with a text
116+
node for `value`
117+
118118
## Syntax
119119

120-
HTML is handled according to WHATWG HTML (the living standard), which is also
121-
followed by browsers such as Chrome and Firefox.
120+
HTML is parsed according to WHATWG HTML (the living standard), which is also
121+
followed by all browsers.
122122

123123
## Syntax tree
124124

125-
The syntax tree format used is [`hast`][hast].
125+
The syntax tree used is [hast][].
126126

127127
## Types
128128

129129
This package is fully typed with [TypeScript][].
130130

131131
## Compatibility
132132

133-
Projects maintained by the unified collective are compatible with all maintained
133+
Projects maintained by the unified collective are compatible with maintained
134134
versions of Node.js.
135-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
136-
Our projects sometimes work with older versions, but this is not guaranteed.
135+
136+
When we cut a new major release, we drop support for unmaintained versions of
137+
Node.
138+
This means we try to keep the current release line,
139+
`hast-util-from-string@^2`,
140+
compatible with Node.js 12.
137141

138142
## Security
139143

@@ -197,9 +201,9 @@ abide by its terms.
197201

198202
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
199203

200-
[size]: https://bundlephobia.com/result?p=hast-util-from-string
204+
[size]: https://bundlejs.com/?q=hast-util-from-string
201205

202-
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-from-string.svg
206+
[size-badge]: https://img.shields.io/bundlejs/size/hast-util-from-string
203207

204208
[support]: https://github.com/rehypejs/.github/blob/main/support.md
205209

packages/hast-util-is-body-ok-link/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
*
2929
* Check whether a node is a “body OK” link.
3030
*
31-
* * returns `true` for `link` elements with an `itemProp`
32-
* * returns `true` for `link` elements with a `rel` list where one or more
33-
* entries are `pingback`, `prefetch`, or `stylesheet`
31+
* The following nodes are “body OK” links:
32+
*
33+
* * `link` elements with an `itemProp`
34+
* * `link` elements with a `rel` list where one or more entries are
35+
* `pingback`, `prefetch`, or `stylesheet`
3436
*
3537
* ###### Parameters
3638
*
37-
* * `node` (`Node`) — hast node
39+
* * `node` (`Node`) — node to check.
3840
*
3941
* ###### Returns
4042
*

packages/hast-util-is-body-ok-link/readme.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,45 +74,51 @@ isBodyOkLink(h('link', {rel: ['author'], href: 'index.css'})) //=> false
7474

7575
## API
7676

77-
This package exports the following identifiers:
77+
This package exports the identifier
7878
`isBodyOkLink`.
7979
There is no default export.
8080

8181
### `isBodyOkLink(node)`
8282

8383
Check whether a node is a “body OK” link.
8484

85-
* returns `true` for `link` elements with an `itemProp`
86-
* returns `true` for `link` elements with a `rel` list where one or more
87-
entries are `pingback`, `prefetch`, or `stylesheet`
85+
The following nodes are “body OK” links:
86+
87+
* `link` elements with an `itemProp`
88+
* `link` elements with a `rel` list where one or more entries are
89+
`pingback`, `prefetch`, or `stylesheet`
8890

8991
###### Parameters
9092

91-
* `node` (`Node`) — hast node
93+
* `node` (`Node`) — node to check.
9294

9395
###### Returns
9496

9597
Whether a node is a “body OK” link (`boolean`).
9698

9799
## Syntax
98100

99-
HTML is handled according to WHATWG HTML (the living standard), which is also
100-
followed by browsers such as Chrome and Firefox.
101+
HTML is parsed according to WHATWG HTML (the living standard), which is also
102+
followed by all browsers.
101103

102104
## Syntax tree
103105

104-
The syntax tree format used is [`hast`][hast].
106+
The syntax tree used is [hast][].
105107

106108
## Types
107109

108110
This package is fully typed with [TypeScript][].
109111

110112
## Compatibility
111113

112-
Projects maintained by the unified collective are compatible with all maintained
114+
Projects maintained by the unified collective are compatible with maintained
113115
versions of Node.js.
114-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
115-
Our projects sometimes work with older versions, but this is not guaranteed.
116+
117+
When we cut a new major release, we drop support for unmaintained versions of
118+
Node.
119+
This means we try to keep the current release line,
120+
`hast-util-is-body-ok-link@^2`,
121+
compatible with Node.js 12.
116122

117123
## Security
118124

@@ -176,9 +182,9 @@ abide by its terms.
176182

177183
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
178184

179-
[size]: https://bundlephobia.com/result?p=hast-util-is-body-ok-link
185+
[size]: https://bundlejs.com/?q=hast-util-is-body-ok-link
180186

181-
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-is-body-ok-link.svg
187+
[size-badge]: https://img.shields.io/bundlejs/size/hast-util-is-body-ok-link
182188

183189
[support]: https://github.com/rehypejs/.github/blob/main/support.md
184190

packages/hast-util-is-conditional-comment/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* ###### Parameters
3535
*
36-
* * `node` (`Node`) — hast node
36+
* * `node` (`Node`) — node to check
3737
*
3838
* ###### Returns
3939
*

packages/hast-util-is-conditional-comment/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const re = /^\[if[ \t\f\n\r]+[^\]]+]|<!\[endif]$/
2-
31
/**
42
* @typedef {import('hast').Nodes} Nodes
53
*/
64

5+
const re = /^\[if[ \t\f\n\r]+[^\]]+]|<!\[endif]$/
6+
77
/**
88
* Check if a node is a conditional comment.
99
*

packages/hast-util-is-conditional-comment/readme.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ isConditionalComment(u({type: 'comment', value: 'foo'})) //=> false
7777

7878
## API
7979

80-
This package exports the following identifiers:
80+
This package exports the identifier
8181
`isConditionalComment`.
8282
There is no default export.
8383

@@ -87,31 +87,35 @@ Check if a node is a conditional comment.
8787

8888
###### Parameters
8989

90-
* `node` (`Node`) — hast node
90+
* `node` (`Node`) — node to check
9191

9292
###### Returns
9393

9494
Whether a node is a conditional comment (`boolean`).
9595

9696
## Syntax
9797

98-
HTML is handled according to WHATWG HTML (the living standard), which is also
99-
followed by browsers such as Chrome and Firefox.
98+
HTML is parsed according to WHATWG HTML (the living standard), which is also
99+
followed by all browsers.
100100

101101
## Syntax tree
102102

103-
The syntax tree format used is [`hast`][hast].
103+
The syntax tree used is [hast][].
104104

105105
## Types
106106

107107
This package is fully typed with [TypeScript][].
108108

109109
## Compatibility
110110

111-
Projects maintained by the unified collective are compatible with all maintained
111+
Projects maintained by the unified collective are compatible with maintained
112112
versions of Node.js.
113-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
114-
Our projects sometimes work with older versions, but this is not guaranteed.
113+
114+
When we cut a new major release, we drop support for unmaintained versions of
115+
Node.
116+
This means we try to keep the current release line,
117+
`hast-util-is-conditional-comment@^2`,
118+
compatible with Node.js 12.
115119

116120
## Security
117121

@@ -175,9 +179,9 @@ abide by its terms.
175179

176180
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
177181

178-
[size]: https://bundlephobia.com/result?p=hast-util-is-conditional-comment
182+
[size]: https://bundlejs.com/?q=hast-util-is-conditional-comment
179183

180-
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-is-conditional-comment.svg
184+
[size-badge]: https://img.shields.io/bundlejs/size/hast-util-is-conditional-comment
181185

182186
[support]: https://github.com/rehypejs/.github/blob/main/support.md
183187

packages/hast-util-is-css-link/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* ###### Parameters
3636
*
37-
* * `node` (`Node`) — hast node
37+
* * `node` (`Node`) — node to check
3838
*
3939
* ###### Returns
4040
*

packages/hast-util-is-css-link/lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import {collapseWhiteSpace} from 'collapse-white-space'
77
/**
88
* Check whether a hast node is a `<link>` that references CSS.
99
*
10+
* Returns `true` if `node` is a `<link>` element with a `rel` list that
11+
* contains `'stylesheet'` and has no `type`, an empty `type`, or `'text/css'`
12+
* as its `type`.
13+
*
1014
* @param {Nodes} node
1115
* Node to check.
1216
* @returns {boolean}

0 commit comments

Comments
 (0)