Skip to content

Commit d5396de

Browse files
committed
docs: api
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent c0f4022 commit d5396de

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

README.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,25 @@
1818
- [Install](#install)
1919
- [Use](#use)
2020
- [API](#api)
21+
- [`DECORATOR_REGEX`](#decorator-regex)
2122
- [Types](#types)
2223
- [Related](#related)
2324
- [Contribute](#contribute)
2425

2526
## What is this?
2627

27-
This package contains regular expressions for matching [decorators][1]. Decorators are functions called on classes,
28-
class elements, or other JavaScript and TypeScript syntax forms during definition.
28+
This package exports a regular expression for matching [decorators][1]. Decorators are functions called on classes,
29+
class accessors, class fields, class methods, and/or class method parameters.
2930

3031
## When should I use this?
3132

32-
Regex expressions exported from this package can be used to match decorators in JavaScript and TypeScript source code.
33+
The regular expression exported from this package can be used to match multi and single-line decorators in JavaScript
34+
and TypeScript source code.
3335

3436
Note:
3537

36-
- Statements in docblock (`/** */`), multiline (`/* */`), and single-line (`//`) comments are ignored
37-
- Expressions are ECMAScript-compatible. They have not been tested with other flavors (PCRE, PCRE2, etc)
38+
- Decorators in comments (`/** */`, `/* */`, `//`) are ignored
39+
- Regular expression is ECMAScript-compatible. It has **not** been tested with other flavors (PCRE, PCRE2, etc)
3840

3941
## Install
4042

@@ -63,23 +65,39 @@ yarn add @flex-development/decorator-regex@flex-development/decorator-regex
6365

6466
## API
6567

66-
**TODO**: api documentation.
68+
This package exports the identifier [`DECORATOR_REGEX`](#decorator-regex).
69+
70+
There is no default export.
71+
72+
### `DECORATOR_REGEX`
73+
74+
Regular expression matching multi and single-line decorators.
75+
76+
Ignores matches in comments.
77+
78+
Required [flags][3]:
79+
80+
- `s`: dot all
81+
- `u`: unicode
82+
83+
> **Source**: [`src/decorator-regex.ts`](src/decorator-regex.ts)
6784
6885
## Types
6986

70-
This package is fully typed with [TypeScript][3].
87+
This package is fully typed with [TypeScript][4].
7188

7289
## Related
7390

74-
- [`export-regex`][4] &mdash; `export` statement regex
75-
- [`import-regex`][5] &mdash; `import` statement regex
91+
- [`export-regex`][5] &mdash; `export` statement regex
92+
- [`import-regex`][6] &mdash; `import` statement regex
7693

7794
## Contribute
7895

7996
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
8097

8198
[1]: https://github.com/tc39/proposal-decorators
8299
[2]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
83-
[3]: https://www.typescriptlang.org
84-
[4]: https://github.com/flex-development/export-regex
85-
[5]: https://github.com/flex-development/import-regex
100+
[3]: https://codeguage.com/courses/regexp/flags
101+
[4]: https://www.typescriptlang.org
102+
[5]: https://github.com/flex-development/export-regex
103+
[6]: https://github.com/flex-development/import-regex

src/decorator-regex.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*
99
* Ignores matches in comments.
1010
*
11-
* Required flags:
11+
* Required [flags][1]:
1212
*
1313
* - `s`: dot all
1414
* - `u`: unicode
1515
*
16-
* @see https://codeguage.com/courses/regexp/flags
17-
* @see https://github.com/tc39/proposal-decorators
16+
* [1]: https://codeguage.com/courses/regexp/flags
17+
*
1818
* @see https://regex101.com/r/WPavSs
19+
* @see https://github.com/tc39/proposal-decorators
1920
*
2021
* @const {RegExp} DECORATOR_REGEX
2122
*/

0 commit comments

Comments
 (0)