Skip to content

Commit f095a15

Browse files
committed
build(deps): add @flex-development/vfile-location
- https://github.com/flex-development/vfile-location Signed-off-by: Lexus Drumgold <[email protected]>
1 parent b2264f1 commit f095a15

17 files changed

+83
-324
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"@flex-development/docast": "1.0.0-alpha.17",
8484
"@flex-development/tutils": "6.0.0-alpha.25",
8585
"@flex-development/unist-util-visit": "1.1.0",
86+
"@flex-development/vfile-location": "1.0.0",
8687
"@types/mdast": "4.0.3",
8788
"debug": "4.3.4",
8889
"devlop": "1.1.0",
@@ -105,7 +106,7 @@
105106
"@flex-development/mkbuild": "1.0.0-alpha.23",
106107
"@flex-development/mlly": "1.0.0-alpha.18",
107108
"@flex-development/pathe": "2.0.0",
108-
"@flex-development/unist-util-types": "1.3.1",
109+
"@flex-development/unist-util-types": "1.4.0",
109110
"@html-eslint/eslint-plugin": "0.24.0",
110111
"@html-eslint/parser": "0.24.0",
111112
"@types/chai": "4.3.14",
@@ -169,7 +170,7 @@
169170
"yaml-eslint-parser": "1.2.2"
170171
},
171172
"resolutions": {
172-
"@flex-development/unist-util-types": "1.3.1",
173+
"@flex-development/unist-util-types": "1.4.0",
173174
"@types/mdast": "4.0.3",
174175
"@types/unist": "3.0.2",
175176
"chai": "5.1.0",

src/__tests__/location.spec.ts

Lines changed: 0 additions & 94 deletions
This file was deleted.

src/__tests__/reader.spec-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @module docast-util-from-docs/tests/unit-d/Reader
44
*/
55

6-
import type Location from '#src/location'
6+
import type { Location } from '@flex-development/vfile-location'
77
import type TestSubject from '../reader'
88

99
describe('unit-d:Reader', () => {

src/interfaces/__tests__/options-lexer.spec-d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
* @module docast-util-from-docs/interfaces/tests/unit-d/LexerOptions
44
*/
55

6-
import type { Point } from '@flex-development/docast'
76
import type { Nilable } from '@flex-development/tutils'
7+
import type { Point } from '@flex-development/vfile-location'
88
import type TestSubject from '../options-lexer'
99

1010
describe('unit-d:interfaces/LexerOptions', () => {
11-
it('should match [from?: Nilable<Point>]', () => {
11+
it('should match [from?: Point | null | undefined]', () => {
1212
expectTypeOf<TestSubject>()
1313
.toHaveProperty('from')
1414
.toEqualTypeOf<Nilable<Point>>()
1515
})
1616

17-
it('should match [multiline?: Nilable<boolean>]', () => {
17+
it('should match [multiline?: boolean | null | undefined]', () => {
1818
expectTypeOf<TestSubject>()
1919
.toHaveProperty('multiline')
2020
.toEqualTypeOf<Nilable<boolean>>()

src/interfaces/options-lexer.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@
33
* @module docast-util-from-docs/interfaces/LexerOptions
44
*/
55

6-
import type { Point } from '@flex-development/docast'
7-
import type { Nilable } from '@flex-development/tutils'
6+
import type { Point } from '@flex-development/vfile-location'
87

98
/**
109
* Lexer configuration options.
1110
*/
1211
interface LexerOptions {
1312
/**
14-
* Start point.
13+
* Point before first character in source file.
1514
*
1615
* Node positions will be relative to this point.
1716
*
1817
* @see {@linkcode Point}
1918
*/
20-
from?: Nilable<Point>
19+
from?: Point | null | undefined
2120

2221
/**
2322
* Allow multiline comments.
2423
*/
25-
multiline?: Nilable<boolean>
24+
multiline?: boolean | null | undefined
2625
}
2726

2827
export type { LexerOptions as default }

src/lexer.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
* @module docast-util-from-docs/lexer
44
*/
55

6-
import type { Point } from '@flex-development/docast'
7-
import type { Nilable, Optional } from '@flex-development/tutils'
6+
import type { Optional } from '@flex-development/tutils'
7+
import type { Point } from '@flex-development/vfile-location'
88
import debug from 'debug'
99
import { ok } from 'devlop'
10-
import type { VFile } from 'vfile'
10+
import type { VFile, Value } from 'vfile'
1111
import { TokenKind as kinds } from './enums'
1212
import type { LexerOptions } from './interfaces'
1313
import Reader from './reader'
1414
import Token from './token'
1515
import type { Character, CharacterMatch } from './types'
1616

1717
/**
18-
* Source document tokenizer.
18+
* Docblock tokenizer.
1919
*
2020
* @class
2121
*/
@@ -66,7 +66,7 @@ class Lexer {
6666
protected readonly options: Readonly<LexerOptions>
6767

6868
/**
69-
* Source document reader.
69+
* Character reader.
7070
*
7171
* @see {@linkcode Reader}
7272
*
@@ -102,19 +102,20 @@ class Lexer {
102102
protected readonly tokens: Token[]
103103

104104
/**
105-
* Create a new document tokenizer.
105+
* Create a new docblock tokenizer.
106106
*
107107
* @see {@linkcode LexerOptions}
108108
* @see {@linkcode VFile}
109+
* @see {@linkcode Value}
109110
*
110-
* @param {VFile | string} source - Source document or file
111-
* @param {Nilable<LexerOptions>?} [options] - Lexer options
111+
* @param {Value | VFile} value - Source document or file
112+
* @param {(LexerOptions | null)?} [options] - Lexer options
112113
*/
113-
constructor(source: VFile | string, options?: Nilable<LexerOptions>) {
114+
constructor(value: Value | VFile, options?: LexerOptions | null) {
114115
this.comment = false
115116
this.debug = debug('docast-util-from-docs:lexer')
116117
this.options = Object.freeze(options ??= {})
117-
this.reader = new Reader(source, this.options.from)
118+
this.reader = new Reader(value, this.options.from)
118119
this.tokens = []
119120

120121
this.head = this.tokenize()
@@ -321,7 +322,7 @@ class Lexer {
321322
* @return {Point} Current point in document
322323
*/
323324
protected now(): Point {
324-
return this.reader.point(this.reader.from.offset + this.reader.index)
325+
return this.reader.point(this.reader.start.offset + this.reader.index)
325326
}
326327

327328
/**

src/location.ts

Lines changed: 0 additions & 148 deletions
This file was deleted.

0 commit comments

Comments
 (0)