Skip to content

Commit

Permalink
docs(parsers): improve the parser examples
Browse files Browse the repository at this point in the history
  • Loading branch information
reconbot committed Feb 28, 2018
1 parent e8b73c2 commit 41f1d2d
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 99 deletions.
2 changes: 1 addition & 1 deletion docs/BaseBinding.html
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
10 changes: 4 additions & 6 deletions docs/ByteLengthParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h4 class="name" id="ByteLengthParser"><span class="type-signature"></span>new B

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parsers_byte-length.js.html">parsers/byte-length.js</a>, <a href="parsers_byte-length.js.html#line20">line 20</a>
<a href="parsers_byte-length.js.html">parsers/byte-length.js</a>, <a href="parsers_byte-length.js.html#line18">line 18</a>
</li></ul></dd>


Expand Down Expand Up @@ -118,14 +118,12 @@ <h4 class="name" id="ByteLengthParser"><span class="type-signature"></span>new B

<h5>Example</h5>

<pre class="prettyprint"><code>To use the `ByteLength` parser:
```js
<pre class="prettyprint"><code>// To use the `ByteLength` parser:
const SerialPort = require('serialport');
const ByteLength = SerialPort.parsers.ByteLength
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new ByteLength({length: 8}));
parser.on('data', console.log); // will have 8 bytes per data event
```</code></pre>
parser.on('data', console.log); // will have 8 bytes per data event</code></pre>



Expand Down Expand Up @@ -285,7 +283,7 @@ <h3 class="subsection-title">Extends</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
10 changes: 4 additions & 6 deletions docs/CCTalkParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h4 class="name" id="CCTalkParser"><span class="type-signature"></span>new CCTal

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parsers_cctalk.js.html">parsers/cctalk.js</a>, <a href="parsers_cctalk.js.html#line17">line 17</a>
<a href="parsers_cctalk.js.html">parsers/cctalk.js</a>, <a href="parsers_cctalk.js.html#line15">line 15</a>
</li></ul></dd>


Expand Down Expand Up @@ -118,14 +118,12 @@ <h4 class="name" id="CCTalkParser"><span class="type-signature"></span>new CCTal

<h5>Example</h5>

<pre class="prettyprint"><code>CCTalk Messages are emitted as buffers.
```js
<pre class="prettyprint"><code>// CCTalk Messages are emitted as buffers.
const SerialPort = require('serialport');
const CCTalk = SerialPort.parsers.CCTalk;
const port = new SerialPort('/dev/ttyUSB0');
const parser = port.pipe(new CCtalk());
parser.on('data', console.log);
```</code></pre>
parser.on('data', console.log);</code></pre>



Expand Down Expand Up @@ -187,7 +185,7 @@ <h3 class="subsection-title">Extends</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
12 changes: 5 additions & 7 deletions docs/DelimiterParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h4 class="name" id="DelimiterParser"><span class="type-signature"></span>new De

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parsers_delimiter.js.html">parsers/delimiter.js</a>, <a href="parsers_delimiter.js.html#line17">line 17</a>
<a href="parsers_delimiter.js.html">parsers/delimiter.js</a>, <a href="parsers_delimiter.js.html#line15">line 15</a>
</li></ul></dd>


Expand Down Expand Up @@ -118,14 +118,12 @@ <h4 class="name" id="DelimiterParser"><span class="type-signature"></span>new De

<h5>Example</h5>

<pre class="prettyprint"><code>To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
```js
<pre class="prettyprint"><code>// To use the `Delimiter` parser, provide a delimiter as a string, buffer, or array of bytes:
const SerialPort = require('serialport');
const Delimiter = SerialPort.parsers.Delimiter;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Delimiter({ delimiter: Buffer.from('EOL') }));
parser.on('data', console.log);
```</code></pre>
const parser = port.pipe(new Delimiter({ delimiter: '\n' }));
parser.on('data', console.log);</code></pre>



Expand Down Expand Up @@ -187,7 +185,7 @@ <h3 class="subsection-title">Extends</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Poller.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
14 changes: 6 additions & 8 deletions docs/ReadLineParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ <h2>
ReadLineParser
</h2>

<div class="class-description"><p>A transform stream that emits data after a newline delimiter is received.</p></div>
<div class="class-description"><p>A transform stream that emits data after a newline delimiter is received.</p>
<p> To use the <code>Readline</code> parser, provide a delimiter (defaults to <code>\n</code>). Data is emitted as string controllable by the <code>encoding</code> option (defaults to <code>utf8</code>).</p></div>


</header>
Expand All @@ -69,7 +70,7 @@ <h4 class="name" id="ReadLineParser"><span class="type-signature"></span>new Rea

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parsers_readline.js.html">parsers/readline.js</a>, <a href="parsers_readline.js.html#line17">line 17</a>
<a href="parsers_readline.js.html">parsers/readline.js</a>, <a href="parsers_readline.js.html#line16">line 16</a>
</li></ul></dd>


Expand Down Expand Up @@ -118,14 +119,11 @@ <h4 class="name" id="ReadLineParser"><span class="type-signature"></span>new Rea

<h5>Example</h5>

<pre class="prettyprint"><code>To use the `Readline` parser, provide a delimiter (defaults to '\n'). Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
```js
const SerialPort = require('serialport');
<pre class="prettyprint"><code>const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Readline({ delimiter: '\r\n' }));
parser.on('data', console.log);
```</code></pre>
parser.on('data', console.log);</code></pre>



Expand Down Expand Up @@ -187,7 +185,7 @@ <h3 class="subsection-title">Extends</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
14 changes: 6 additions & 8 deletions docs/ReadyParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ <h2>
ReadyParser
</h2>

<div class="class-description"><p>A transform stream that waits for a sequence of &quot;ready&quot; bytes before emitting a ready event and emitting data events</p></div>
<div class="class-description"><p>A transform stream that waits for a sequence of &quot;ready&quot; bytes before emitting a ready event and emitting data events</p>
<p>To use the <code>Ready</code> parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.</p></div>


</header>
Expand All @@ -69,7 +70,7 @@ <h4 class="name" id="ReadyParser"><span class="type-signature"></span>new ReadyP

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parsers_ready.js.html">parsers/ready.js</a>, <a href="parsers_ready.js.html#line18">line 18</a>
<a href="parsers_ready.js.html">parsers/ready.js</a>, <a href="parsers_ready.js.html#line17">line 17</a>
</li></ul></dd>


Expand Down Expand Up @@ -118,15 +119,12 @@ <h4 class="name" id="ReadyParser"><span class="type-signature"></span>new ReadyP

<h5>Example</h5>

<pre class="prettyprint"><code>To use the `Ready` parser provide a byte start sequence. After the bytes have been received a ready event is fired and data events are passed through.
```js
const SerialPort = require('serialport');
<pre class="prettyprint"><code>const SerialPort = require('serialport');
const Ready = SerialPort.parsers.Ready;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Ready({ delimiter: 'READY' }));
parser.on('ready', () => console.log('the ready byte sequence has been received'))
parser.on('data', console.log); // all data after READY is received
```</code></pre>
parser.on('data', console.log); // all data after READY is received</code></pre>



Expand Down Expand Up @@ -292,7 +290,7 @@ <h3 class="subsection-title">Extends</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
14 changes: 6 additions & 8 deletions docs/RegexParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ <h2>
RegexParser
</h2>

<div class="class-description"><p>A transform stream that uses a regular expression to split the incoming text upon.</p></div>
<div class="class-description"><p>A transform stream that uses a regular expression to split the incoming text upon.</p>
<p>To use the <code>Regex</code> parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the <code>encoding</code> option (defaults to <code>utf8</code>).</p></div>


</header>
Expand All @@ -69,7 +70,7 @@ <h4 class="name" id="RegexParser"><span class="type-signature"></span>new RegexP

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parsers_regex.js.html">parsers/regex.js</a>, <a href="parsers_regex.js.html#line17">line 17</a>
<a href="parsers_regex.js.html">parsers/regex.js</a>, <a href="parsers_regex.js.html#line15">line 15</a>
</li></ul></dd>


Expand Down Expand Up @@ -118,14 +119,11 @@ <h4 class="name" id="RegexParser"><span class="type-signature"></span>new RegexP

<h5>Example</h5>

<pre class="prettyprint"><code>To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
```js
const SerialPort = require('serialport');
<pre class="prettyprint"><code>const SerialPort = require('serialport');
const Regex = SerialPort.parsers.Regex;
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Regex({ regex: /[\r\n]+/ }));
parser.on('data', console.log);
```</code></pre>
parser.on('data', console.log);</code></pre>



Expand Down Expand Up @@ -187,7 +185,7 @@ <h3 class="subsection-title">Extends</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/SerialPort.html
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/bindings_base.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ <h1 class="page-title">bindings/base.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/bindings_poller.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h1 class="page-title">bindings/poller.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ <h4 class="name" id="event:open">open</h4>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ <h3>Serial Port List</h3><p><code>serialport-list</code> will list all available
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h1 class="page-title">index.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
6 changes: 2 additions & 4 deletions docs/parsers_byte-length.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ <h1 class="page-title">parsers/byte-length.js</h1>
* @param {Object} options parser options object
* @param {Number} options.length the number of bytes on each data event
* @example
To use the `ByteLength` parser:
```js
// To use the `ByteLength` parser:
const SerialPort = require('serialport');
const ByteLength = SerialPort.parsers.ByteLength
const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new ByteLength({length: 8}));
parser.on('data', console.log); // will have 8 bytes per data event
```
*/
class ByteLengthParser extends Transform {
constructor(options) {
Expand Down Expand Up @@ -109,7 +107,7 @@ <h1 class="page-title">parsers/byte-length.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
6 changes: 2 additions & 4 deletions docs/parsers_cctalk.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ <h1 class="page-title">parsers/cctalk.js</h1>
* Parses the CCTalk protocol
* @extends Transform
* @example
CCTalk Messages are emitted as buffers.
```js
// CCTalk Messages are emitted as buffers.
const SerialPort = require('serialport');
const CCTalk = SerialPort.parsers.CCTalk;
const port = new SerialPort('/dev/ttyUSB0');
const parser = port.pipe(new CCtalk());
parser.on('data', console.log);
```
*/
class CCTalkParser extends Transform {
constructor() {
Expand Down Expand Up @@ -94,7 +92,7 @@ <h1 class="page-title">parsers/cctalk.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 27 2018 23:06:42 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
Loading

0 comments on commit 41f1d2d

Please sign in to comment.