Skip to content

Commit

Permalink
create "common" section in API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Oct 8, 2015
1 parent 122acba commit 337d270
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 127 deletions.
72 changes: 72 additions & 0 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,68 @@ var app = templates();
```

## API
### Common
This section describes API features that are shared by all Templates classes.

#### .option

Set or get an option value.

**Params**

* `key` **{String|Object}**: Pass a key-value pair or an object to set.
* `val` **{any}**: Any value when a key-value pair is passed. This can also be options if a glob pattern is passed as the first value.
* `returns` **{Object}**: Returns the instance for chaining.

**Example**

```js
app.option('a', 'b');
app.option({c: 'd'});
console.log(app.options);
//=> {a: 'b', c: 'd'}
```

#### .use

Run a plugin on the given instance. Plugins are invoked immediately upon instantiating in the order in which they were defined.

**Example**

The simplest plugin looks something like the following:

```js
app.use(function(inst) {
// do something to `inst`
});
```

Note that `inst` is the instance of the class you're instantiating. So if you create an instance of `Collection`, inst is the collection instance.


**Params**

* `fn` **{Function}**: Plugin function. If the plugin returns a function it will be passed to the `use` method of each item created on the instance.
* `returns` **{Object}**: Returns the instance for chaining.

**Usage**

```js
collection.use(function(items) {
// `items` is the instance, as is `this`

// optionally return a function to be passed to
// the `.use` method of each item created on the
// instance
return function(item) {
// do stuff to each `item`
};
});
```

### Application
This section describes the methods and features available on the main `Templates` class.

{%= apidocs("index.js", {type: 'app', ctor: 'templates'}) %}


Expand All @@ -67,6 +129,8 @@ var app = templates();
***

### View
API for the `View` class.

{%= apidocs("lib/view.js") %}

#### Settings
Expand All @@ -78,6 +142,8 @@ var app = templates();
***

### Item
API for the `Item` class.

{%= apidocs("lib/item.js") %}

#### Settings
Expand All @@ -89,6 +155,8 @@ var app = templates();
***

### Collections
API for the `Collections` class.

{%= apidocs("lib/collection.js") %}

#### Settings
Expand All @@ -100,6 +168,8 @@ var app = templates();
***

### List
API for the `List` class.

{%= apidocs("lib/list.js") %}

#### Settings
Expand All @@ -108,6 +178,8 @@ var app = templates();
***

### Group
API for the `Group` class.

{%= apidocs("lib/group.js") %}


Expand Down
Loading

0 comments on commit 337d270

Please sign in to comment.