# doxie.filter

> A plugin for doxie. Filter comments through a custom function.

Latest version **0.4.1** (published 2015-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install doxie.filter
pnpm add doxie.filter
yarn add doxie.filter
bun add doxie.filter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2015-06-23 |
| First published | 2015-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | tomekwi |
| Keywords | doxie-plugin |

## Links

- npm: https://www.npmjs.com/package/doxie.filter
- Repository: https://github.com/studio-b12/doxie.filter
- Homepage: https://github.com/studio-b12/doxie.filter#readme
- Issues: https://github.com/studio-b12/doxie.filter/issues
- npm.io page: https://npm.io/package/doxie.filter

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^1.0.0
- [1-liners](https://npm.io/package/1-liners.md) ^0.3.0
- [tiny-error](https://npm.io/package/tiny-error.md) ^0.2.1

## Recent versions

- 0.4.1 (latest) — 2015-06-23
- 0.4.0 — 2015-06-22
- 0.3.2 — 2015-06-16
- 0.3.1 — 2015-06-09
- 0.3.0 — 2015-06-09
- 0.2.1 — 2015-06-09
- 0.2.0 — 2015-06-09
- 0.1.1 — 2015-06-08
- 0.1.0 — 2015-06-08

## README

[![Coveralls – test coverage
](https://img.shields.io/coveralls/studio-b12/doxie.filter.svg?style=flat-square)
](https://coveralls.io/r/studio-b12/doxie.filter)
 [![Travis – build status
](https://img.shields.io/travis/studio-b12/doxie.filter/master.svg?style=flat-square)
](https://travis-ci.org/studio-b12/doxie.filter)
 [![David – status of dependencies
](https://img.shields.io/david/studio-b12/doxie.filter.svg?style=flat-square)
](https://david-dm.org/studio-b12/doxie.filter)
 [![Stability: unstable
](https://img.shields.io/badge/stability-unstable-yellowgreen.svg?style=flat-square)
](https://nodejs.org/api/documentation.html#documentation_stability_index)
 [![Code style: airbnb
](https://img.shields.io/badge/code%20style-airbnb-blue.svg?style=flat-square)
](https://github.com/airbnb/javascript)




<h1                                                                 id="/"><pre>
doxie --filter
</pre></h1>


A plugin for *[doxie][]*.  
**Filter comments through a custom function.**


[doxie]:  http://npm.im/doxie



<p><a
  title="Graphic by the great Justin Mezzell"
  href="http://justinmezzell.tumblr.com/post/57086283476"
  >
  <br/>
  <br/>
  <br/>
  <br/>
  <img
    alt="lightweight"
    src="Readme/Filter.gif"
    width="400"
    height="300"
  />
  <br/>
  <br/>
  <br/>
  <br/>
</a></p>




**Note:** Don’t panic. `doxie --filter` is a flexible, low-level plugin. We’re working on higher-level plugins which you can drop into your project without fiddling with configuration.




CLI Usage
---------
`doxie --filter` is a plugin for the command-line tool *[doxie][]*. Most plugins are designed for *[dox][]* data. Install all three if you haven’t already:

```sh
$ npm install --global dox doxie doxie.filter
```


Pass the option `--filter` to *doxie* to put the plugin in your pipeline. By default it will import the [filter function][] from `<pwd>/.doxie.filter.js` and pipe your docs through it:

```sh
$ dox | doxie --filter
```


You can also specify a custom file to import the [filter function][] from:

```sh
$ dox | doxie --filter ./build/my-custom-filter.js
```


[dox]:              http://npm.im/dox
[filter function]:  #/filter-function




Programmatic usage
------------------

`doxie.filter` can be used directly with *[doxie-core][]* – the backend of *[doxie][]*. Install both if you haven’t already:

```sh
$ npm install doxie-core doxie.filter
```


Pass the [filter function][] directly as a parameter:

```js
const doxie = require('doxie-core');
const filter = require('doxie.filter');
const myDoxData = {/* … */};

doxie([
  filter(({data}) => (!data || !data.isPrivate)),
])(myDoxData);
```


[doxie-core]:  http://npm.im/doxie-core




<a                                                    id="/filter-function"></a>
The filter function
-------------------

Put the file `.doxie.filter.js` in the root directory of your project and export a single function from it. Every doc will be piped through your filter function. If it returns a truthy value, the doc will be kept. Otherwise it won’t be passed down the plugin pipeline.

Here’s a drop-in example written in ES5:

```js
// `/.doxie.filter.js`

module.exports = function(doc) {return (
  // Keep the doc if it has no associated data (comes from a plugin, not from
  // a comment)
  !doc.data ||

  // Or if *dox* hasn’t marked it as private.
  !doc.data.isPrivate
);};
```



<h5                                             id="/filter-function/signature">
Signature:
</h5>

<pre>
filterFunction({[data], [output]})
  → keep?
</pre>


<h5                                                 id="/filter-function/input">
Input properties:
</h5>

* **`[data]`**
  <sup>{&ast;}</sup>  
  The data associated with a doc. If the doc corresponds comes from a *[dox][]* comment, this will be the output from *[dox][]*.

* **`[output]`**
  <sup>{String}</sup>  
  The rendered text output for a doc.


<h5                                          id="/filter-function/return-value">
Return value:
</h5>

* **`keep?`**
  <sup>{Boolean}</sup>  
  If falsy, the doc won’t be passed down the plugin pipeline.




License
-------

[MIT][] © [Studio B12 GmbH][]

[MIT]: ./License.md
[Studio B12 GmbH]: http://studio-b12.de

---
_Source: https://npm.io/package/doxie.filter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
