Skip to content

Commit

Permalink
more docs tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Aug 11, 2024
1 parent 1186c82 commit acaea67
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/build-plugin-docs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ custom_edit_url: null
# Plugin API Reference
v8r plugins extend the [BasePlugin](#BasePlugin) class. Validating a file yields a [ValidationResult](#ValidationResult) object.
`;
tempFiles.forEach((file) => {
if (fs.existsSync(file.filename)) {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ v8r only searches for a config file in the current working directory.

Example yaml config file:

```yaml
```yaml title=".v8rrc.yml"
# - One or more filenames or glob patterns describing local file or files to validate
# - overridden by passing one or more positional arguments
patterns: ['*json']
Expand Down
10 changes: 9 additions & 1 deletion docs/docs/plugins/using-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ Plugins can be packages installed from a registry like [npm](https://www.npmjs.c

Plugins must be specified in a [config file](../configuration.md). They can't be loaded using command line arguments.

Plugins are run one at a time in the order they are specified in your config file.
```yaml title=".v8rrc.yml"
plugins:
# Plugins installed from NPM (or JSR) must be prefixed by "package:"
- "package:v8r-plugin-emoji-output"
# Local plugins must be prefixed by "local:"
- "local:./subdir/my-local-plugin.mjs"
```
Plugins are invoked one at a time in the order they are specified in your config file.
11 changes: 9 additions & 2 deletions docs/docs/plugins/writing-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ These hooks may optionally return or not return a value. Each plugin is run in s

## Worked Example

Lets build a simple example plugin. Our plugin is going to register an output format called "emoji". If the user passes `--format emoji` the plugin will output a 👍 when the file is valid and a 👎 when the file is invalid instead of the default text log message.
Lets build a simple example plugin. Our plugin is going to register an output format called "emoji". If the user passes `--format emoji` (or sets `format: emoji` in their config file) the plugin will output a 👍 when the file is valid and a 👎 when the file is invalid instead of the default text log message.

```js
```js title="./plugins/v8r-plugin-emoji-output.js"
// Our plugin extends the BasePlugin class
import { BasePlugin } from "v8r";

Expand Down Expand Up @@ -84,3 +84,10 @@ class EmojiOutput extends BasePlugin {
// and the plugin class must be the default export
export default EmojiOutput;
```

We can now register the plugin in our config file:

```yaml title=".v8rrc.yml"
plugins:
- "local:./plugins/v8r-plugin-emoji-output.js"
```

0 comments on commit acaea67

Please sign in to comment.