Skip to content

Commit

Permalink
feat(cli): fixes v0.4 and normalize newlines'
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
  • Loading branch information
Charlike Mike Reagent committed Nov 1, 2018
1 parent 271fdc1 commit 5c9b2b7
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 5 deletions.
188 changes: 188 additions & 0 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,194 @@ $ yarn add {%= name %}
## API

<!-- docks-start -->
_Generated using [docks](http://npm.im/docks)._

### [src/index.js](/src/index.js)

#### [docks](/src/index.js#L47)
Constructor that gives you methods.

**Returns**
- `Object` instance of `Docks`

#### [.use](/src/index.js#L79)
A plugin is a function that may extend the core functionality,
or if it returns another function it is called for each block comment.

Look at [src/plugins/](/src/plugins) folder to see the built-in ones.

**Params**
- `plugin` **{Function}** with signature like `(docks) => (comment) => {}`

**Returns**
- `Object` instance of `Docks`

**Examples**
```javascript
import docks from 'docks';

const app = docks();

// extending the core
app.use((self) => {
self.foobar = 123
});

console.log(app.foobar); // => 123

// Or plugin that will be called on each block comment
app.use(() => (comment) => {
comment.hoho = 'okey'
});
```

#### [.parse](/src/index.js#L112)
Parses given `input` using `@babel/parser` and passes
all block comments to `doctrine` which is JSDoc parser.
It also applies all the "Smart Plugins". Smart plugin is the function
that is returned from each function passed to the `app.use` method.

**Params**
- `input` **{string}** file content which contains document block comments

**Returns**
- `Array<Comment>` an array with `Comment` objects.

**Examples**
```javascript
const app = docks();

const smartPlugin = (comment) => {
// do some stuff witht he Comment object.
};

app.use((self) => smartPlugin);

const cmts = app.parse('some cool stuff with block comments');
console.log(cmts);
```

### [src/plugins/render.js](/src/plugins/render.js)

#### [.renderFileSync](/src/plugins/render.js#L25)
Render single `fp` file to a documentation string.

**Params**
- `fp` **{string}** absolute filepath to file to look for doc comments.

**Returns**
- `string`

**Examples**
```javascript
const app = docks();
const output = app.renderFileSync('path/to/source/file/with/comments');
console.log(output);
```

#### [.renderFile](/src/plugins/render.js#L45)
Render single `fp` file to a documentation string, asynchronously.

**Params**
- `fp` **{string}** absolute file path to look for doc comments.

**Returns**
- `Promise<string>`

**Examples**
```javascript
const app = docks();
app.renderFile('path/to/source/file/with/comments').then((output) => {
console.log(output);
});
```

#### [.renderTextSync](/src/plugins/render.js#L70)
Create a documentation output string from given comments.
Use `app.parse` method to generate such list of `Comment` objects.

**Params**
- `comments` **{Array&lt;Comment&gt;}**

**Returns**
- `string`

**Examples**
```javascript
const app = docks();

const comments = app.parse('some string with block comments');
const output = app.renderTextSync(comments);
console.log(output);
```

#### [.renderText](/src/plugins/render.js#L91)
Create a documentation output string from given comments, asynchronously.
Use `app.parse` method to generate such list of `Comment` objects.

**Params**
- `comments` **{Array&lt;Comment&gt;}**

**Returns**
- `Promise<string>`

**Examples**
```javascript
const app = docks();

const comments = app.parse('some string with block comments');
app.renderText(comments).then((output) => {
console.log(output);
});
```

#### [.renderSync](/src/plugins/render.js#L115)
Render a list of filepaths to a documentation string.

**Params**
- `files` **{Array&lt;string&gt;}** list of absolute file paths to look for doc comments.

**Returns**
- `string`

**Examples**
```javascript
const proc = require('process');
const path = require('path');
const app = docks();

const files = ['src/index.js', 'src/bar.js'].map((fp) => {
return path.join(proc.cwd(), fp);
})

const output = app.renderSync(files);
console.log(output);
```

#### [.render](/src/plugins/render.js#L145)
Render a list of filepaths to a documentation, asynchronously.

**Params**
- `files` **{Array&lt;string&gt;}** list of absolute file paths to look for doc comments.

**Returns**
- `Promise<string>`

**Examples**
```javascript
const proc = require('process');
const path = require('path');
const app = docks();

const files = ['src/index.js', 'src/bar.js'].map((fp) => {
return path.join(proc.cwd(), fp);
})

app.render(files).then((output) => {
console.log(output);
});
```

<!-- docks-end -->

**[back to top](#thetop)**
Expand Down
Loading

0 comments on commit 5c9b2b7

Please sign in to comment.