Skip to content

Commit

Permalink
Add improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 8, 2023
1 parent e5341dc commit d10a468
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 81 deletions.
13 changes: 7 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ type MaybeBuffer = any extends Buffer ? never : Buffer

/**
* Contents of the file.
* Can either be text, or a Buffer like structure.
* This does not directly use type `Buffer`, because it can also be used in a
* browser context.
* Instead this leverages `Uint8Array` which is the base type for `Buffer`,
* and a native JavaScript construct.
*
* Can either be text or a `Buffer` structure.
*/
// Note: this does not directly use type `Buffer`, because it can also be used
// in a browser context.
// Instead this leverages `Uint8Array` which is the base type for `Buffer`,
// and a native JavaScript construct.
export type Value = string | MaybeBuffer

/**
Expand All @@ -37,7 +38,7 @@ export type Value = string | MaybeBuffer
export interface DataMap {}

/**
* Place to store custom information.
* Custom information.
*
* Known attributes can be added to @see {@link DataMap}
*/
Expand Down
12 changes: 8 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* being needed.
* Copied from: <https://github.com/DefinitelyTyped/DefinitelyTyped/blob/90a4ec8/types/node/buffer.d.ts#L170>
*
* @typedef {Value | Options | VFile | URL} Compatible
* @typedef {Options | URL | Value | VFile} Compatible
* Things that can be passed to the constructor.
*
* @typedef VFileCoreOptions
Expand All @@ -42,7 +42,9 @@
* Set `data`.
*
* @typedef Map
* Raw source map, see:
* Raw source map.
*
* See:
* <https://github.com/mozilla/source-map/blob/58819f0/source-map.d.ts#L15-L23>.
* @property {number} version
* Which version of the source map spec this map is following.
Expand Down Expand Up @@ -72,7 +74,7 @@
* @template {ReporterSettings} Settings
* Options type.
* @callback Reporter
* Type for a report.
* Type for a reporter.
* @param {Array<VFile>} files
* Files to report.
* @param {Settings} options
Expand Down Expand Up @@ -403,7 +405,7 @@ export class VFile {
}

/**
* Create an informational message associated with the file.
* Create an info message associated with the file.
*
* Its `fatal` is set to `null` and `file` is set to the current file path.
* Its added to `file.messages`.
Expand Down Expand Up @@ -443,6 +445,8 @@ export class VFile {
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {never}
* Message.
* @throws {VFileMessage}
* Message.
*/
fail(reason, place, origin) {
const message = this.message(reason, place, origin)
Expand Down

0 comments on commit d10a468

Please sign in to comment.