Skip to content

Commit

Permalink
docs: replace sed with nodejs-based md patch
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Apr 22, 2024
1 parent 484d2c6 commit dd50a2a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ install:
script:
# verify readme has been generated
- npm run readme
# show diff for debugging
- git diff
- test -z "$(git diff)"

# run tests with coverage
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"posttest": "npm run lint -s",
"lint": "eslint . --cache",
"cover": "nyc npm test -s",
"readme": "jsdoc2md --template readme.hbs index.js | sed 's/[[:space:]]+$//g;s/**\\(Returns\\|Throws\\|Params\\|Properties\\)/<br>**\\1/g' > readme.md"
"readme": "jsdoc2md --template readme.hbs index.js | node patch-md.js > readme.md"
},
"devDependencies": {
"ava": "^4.2.0",
Expand Down
24 changes: 24 additions & 0 deletions patch-md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
'use strict';

let buff = '';
process.stdin

Check warning on line 5 in patch-md.js

View check run for this annotation

Codecov / codecov/patch

patch-md.js#L4-L5

Added lines #L4 - L5 were not covered by tests
.on('data', (data) => {
buff += data;

Check warning on line 7 in patch-md.js

View check run for this annotation

Codecov / codecov/patch

patch-md.js#L7

Added line #L7 was not covered by tests
})
.on('end', () => {
if (buff.length > 0) {
buff.trim().split(/\r\n|\n/).forEach(processLine);

Check warning on line 11 in patch-md.js

View check run for this annotation

Codecov / codecov/patch

patch-md.js#L10-L11

Added lines #L10 - L11 were not covered by tests
}
});

function processLine(line) {
process.stdout.write(patchLine(line) + '\n');

Check warning on line 16 in patch-md.js

View check run for this annotation

Codecov / codecov/patch

patch-md.js#L16

Added line #L16 was not covered by tests
}

function patchLine(line) {
if (line.startsWith('**')) {
return line.replace(/\s+$/, '<br/>');

Check warning on line 21 in patch-md.js

View check run for this annotation

Codecov / codecov/patch

patch-md.js#L20-L21

Added lines #L20 - L21 were not covered by tests
}
return line;

Check warning on line 23 in patch-md.js

View check run for this annotation

Codecov / codecov/patch

patch-md.js#L23

Added line #L23 was not covered by tests
}
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ get('http://google.com')
Retry module setup function. Takes an options object that configures the
default retry options.

**Kind**: global function
**Kind**: global function<br/>
**Returns**: <code>function</code> - [retryWrapper](retryWrapper) A decorator function that wraps a
a function to turn it into a retry-enabled function.
**Throws**:
Expand All @@ -71,8 +71,8 @@ to retry.
retryify function decorator. Allows configuration on a function by function
basis.

**Kind**: inner method of [<code>retryify</code>](#retryify)
**Returns**: <code>function</code> - The wrapped function.
**Kind**: inner method of [<code>retryify</code>](#retryify)<br/>
**Returns**: <code>function</code> - The wrapped function.<br/>

| Param | Type | Description |
| --- | --- | --- |
Expand All @@ -82,7 +82,7 @@ basis.
<a name="Options"></a>

## Options : <code>Object</code>
**Kind**: global typedef
**Kind**: global typedef<br/>
**Properties**

| Name | Type | Default | Description |
Expand Down

0 comments on commit dd50a2a

Please sign in to comment.