Skip to content

Commit

Permalink
Docs: add subtitles to api/registry.md
Browse files Browse the repository at this point in the history
add subtitles to Errors section, in order to improve readability.
  • Loading branch information
entrywayaudibly authored Oct 17, 2020
1 parent 422fa6d commit 27ab12d
Showing 1 changed file with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions docs/api/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,154 @@ When a constructor (instead of an instance) is passed as `registryInstance`, thr

> Custom registries must be instantiated, but it looks like you passed a constructor.
When a registry without a `get` method is passed as `registryInstance`, throws an error with the message:
<!-- front-matter
id: registry
title: registry()
hide_title: true
sidebar_label: registry()
-->

# registry()

Allows custom registries to be plugged into the task system, which can provide shared tasks or augmented functionality.

**Note:** Only tasks registered with `task()` will be provided to the custom registry. The task functions passed directly to `series()` or `parallel()` will not be provided - if you need to customize the registry behavior, compose tasks with string references.

When assigning a new registry, each task from the current registry will be transferred and the current registry will be replaced with the new one. This allows for adding multiple custom registries in sequential order.

See [Creating Custom Registries][creating-custom-registries] for details.

## Usage

```js
const { registry, task, series } = require('gulp');
const FwdRef = require('undertaker-forward-reference');

registry(FwdRef());

task('default', series('forward-ref'));

task('forward-ref', function(cb) {
// body omitted
cb();
});
```

## Signature

<!-- front-matter
id: registry
title: registry()
hide_title: true
sidebar_label: registry()
-->

# registry()

Allows custom registries to be plugged into the task system, which can provide shared tasks or augmented functionality.

**Note:** Only tasks registered with `task()` will be provided to the custom registry. The task functions passed directly to `series()` or `parallel()` will not be provided - if you need to customize the registry behavior, compose tasks with string references.

When assigning a new registry, each task from the current registry will be transferred and the current registry will be replaced with the new one. This allows for adding multiple custom registries in sequential order.

See [Creating Custom Registries][creating-custom-registries] for details.

## Usage

```js
const { registry, task, series } = require('gulp');
const FwdRef = require('undertaker-forward-reference');

registry(FwdRef());

task('default', series('forward-ref'));

task('forward-ref', function(cb) {
// body omitted
cb();
});
```

## Signature

<!-- front-matter
id: registry
title: registry()
hide_title: true
sidebar_label: registry()
-->

# registry()

Allows custom registries to be plugged into the task system, which can provide shared tasks or augmented functionality.

**Note:** Only tasks registered with `task()` will be provided to the custom registry. The task functions passed directly to `series()` or `parallel()` will not be provided - if you need to customize the registry behavior, compose tasks with string references.

When assigning a new registry, each task from the current registry will be transferred and the current registry will be replaced with the new one. This allows for adding multiple custom registries in sequential order.

See [Creating Custom Registries][creating-custom-registries] for details.

## Usage

```js
const { registry, task, series } = require('gulp');
const FwdRef = require('undertaker-forward-reference');

registry(FwdRef());

task('default', series('forward-ref'));

task('forward-ref', function(cb) {
// body omitted
cb();
});
```

## Signature

```js
registry([registryInstance])
```

### Parameters

| parameter | type | note |
|:--------------:|:-----:|--------|
| registryInstance | object | An instance - not the class - of a custom registry. |

### Returns

If a `registryInstance` is passed, nothing will be returned. If no arguments are passed, returns the current registry instance.

### Errors

#### Incorrect Parameter

When a constructor (instead of an instance) is passed as `registryInstance`, throws an error with the message:

> Custom registries must be instantiated, but it looks like you passed a constructor.
#### Missing get Method

When a registry without a `get` method is passed as `registryInstance`, throws an error with the message:

> Custom registry must have `get` function.
#### Missing set Method

When a registry without a `set` method is passed as `registryInstance`, throws an error with the message:

> Custom registry must have `set` function.
#### Missing init Method

When a registry without an `init` method is passed as `registryInstance`, throws an error with the message:

> Custom registry must have `init` function"
#### Missing tasks Method

When a registry without a `tasks` method is passed as `registryInstance`, throws an error with the message:

> Custom registry must have `tasks` function.
Expand Down

0 comments on commit 27ab12d

Please sign in to comment.