8000 feat(docs): Add JSDocs to exported functions · fb55/css-what@6b60fa9 · GitHub
Skip to content

Commit 6b60fa9

Browse files
committed
feat(docs): Add JSDocs to exported functions
1 parent e4b589d commit 6b60fa9

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ CSSwhat.parse("foo[bar]:baz")
2525

2626
## API
2727

28-
**`CSSwhat.parse(str, options)` - Parses `str`, optionally with the passed `options`.**
28+
**`CSSwhat.parse(selector, options)` - Parses `selector`, optionally with the passed `options`.**
2929

3030
The function returns a two-dimensional array. The first array represents selectors separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:
3131

32-
| name | attributes | example | output |
32+
| name | properties | example | output |
3333
| ---------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- |
3434
| `tag` | `name` | `div` | `{ type: 'tag', name: 'div' }` |
3535
| `universal` | - | `*` | `{ type: 'universal' }` |

src/parse.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
"use strict";
2-
3-
export default parse;
4-
51
export interface Options {
2+
/**
3+
* When false, tag names will not be lowercased.
4+
* @default true
5+
*/
66
lowerCaseAttributeNames?: boolean;
7+
/**
8+
* When false, attribute names will not be lowercased.
9+
* @default true
10+
*/
711
lowerCaseTags?: boolean;
12+
/**
13+
* When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`.
14+
* @default false
15+
*/
816
xmlMode?: boolean;
917
}
1018

@@ -131,7 +139,19 @@ function isWhitespace(c: string) {
131139
return c === " " || c === "\n" || c === "\t" || c === "\f" || c === "\r";
132140
}
133141

134-
function parse(selector: string, options?: Options): Selector[][] {
142+
/**
143+
* Parses `selector`, optionally with the passed `options`.
144+
*
145+
* @param selector Selector to parse.
146+
* @param options Options for parsing.
147+
* @returns Returns a two-dimensional array.
EE79 148+
* The first dimension represents selectors separated by commas (eg. `sub1, sub2`),
149+
* the second contains the relevant tokens for that selector.
150+
*/
151+
export default function parse(
152+
selector: string,
153+
options?: Options
154+
): Selector[][] {
135155
const subselects: Selector[][] = [];
136156

137157
selector = parseSelector(subselects, `${selector}`, options);

src/stringify.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ const charsToEscape = new Set([
2121
"\\",
2222
]);
2323

24-
export default function stringify(token: Selector[][]): string {
25-
return token.map(stringifySubselector).join(", ");
24+
/**
25+
* Turns `selector` back into a string.
26+
*
27+
* @param selector Selector to stringify.
28+
*/
29+
export default function stringify(selector: Selector[][]): string {
30+
return selector.map(stringifySubselector).join(", ");
2631
}
2732

2833
function stringifySubselector(token: Selector[]): string {

0 commit comments

Comments
 (0)