Skip to content

Commit

Permalink
Refactor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 24, 2017
1 parent 4ccb377 commit 6281a8d
Showing 1 changed file with 51 additions and 32 deletions.
83 changes: 51 additions & 32 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,46 +64,65 @@ search(tree, ['do blocklevel'], function (nodes) {

Search for patterns in an NLCST tree.

###### Parameters

* `node` ([`Node`][node]) — Tree to search in
* `patterns` (`Array.<string>` or `Object`)
— Patterns to search for. If an `Object`, uses its keys.
Each pattern is a space-delimited list of words, where each
word is [normalize][]d to remove casing, apostrophes, and dashes.
Spaces in a pattern mean zero or more white space nodes in
the tree
* `handler` ([`Function`][fn-handler])
— Handler invoked when a match is found
* `allowApostrophes` (`boolean`, default: `false`)
— Configuration for [**nlcst-normalize**][normalize])
* `options` (`Object`)
— Configuration:
* `allowApostrophes` (`boolean`, default: `false`)
— Configuration for [**nlcst-normalize**][normalize])
* `allowDashes` (`boolean`, default: `false`)
— Configuration for [**nlcst-normalize**][normalize])
* `allowLiterals` (`boolean`, default: `false`)
— Include [literal][] phrases

###### Throws
##### Throws

`Error` — When not given `node` or `patterns`.

##### Parameters

###### `node`

Tree to search in ([`Node`][node]).

###### `patterns`

Patterns to search for (`Array.<string>` or `Object`).
If an `Object`, uses its keys. Each pattern is a space-delimited list of
words, where each word is [normalize][]d to remove casing, apostrophes,
and dashes. Spaces in a pattern mean zero or more white space nodes in
the tree.

###### `handler`

Handler invoked when a match is found ([`Function`][fn-handler]).

###### `allowApostrophes`

Treated as `options.allowApostrophes`.

###### `options.allowApostrophes`

Passed to [`nlcst-normalize`][normalize] (`boolean`, default: `false`).

###### `options.allowDashes`

Passed to [`nlcst-normalize`][normalize] (`boolean`, default: `false`).

###### `options.allowLiterals`

Include [literal][] phrases (`boolean`, default: `false`).

## `function handler(nodes, index, parent, pattern)`

Handler invoked when a match is found.

###### Parameters
##### Parameters

###### `nodes`

List of siblings which match `pattern` ([`Array.<Node>`][node]).

###### `index`

Position at which the match starts in `parent` (`number`).

###### `parent`

Parent node of `nodes` ([`Node`][node]).

###### `pattern`

* `nodes` ([`Array.<Node>`][node])
— List of siblings which match `pattern`
* `index` (`number`)
— Position at which the match starts in `parent`
* `parent` ([`Node`][node])
— Parent node of `nodes`
* `pattern` (`string`)
— The matched pattern
The matched pattern (`string`).

## License

Expand Down

0 comments on commit 6281a8d

Please sign in to comment.