Skip to content

Commit

Permalink
Merge pull request #20 from sanctuary-js/davidchambers/doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers authored Mar 9, 2019
2 parents 5a191c0 + 27b7f65 commit 08d0723
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,21 @@ For example:

Many variables have default values and are therefore optional.

| Variable name | Default value | Description |
| ----------------------------- | ------------- | ----------------------------------------------------------------------------- |
| `repo-owner` | | The name of the GitHub user or organization who owns the repository. |
| `repo-name` | | The name of the GitHub repository. |
| `default-branch` | `master` | The name of the repository's default branch. |
| `min-branch-coverage` | `100` | The minimum acceptable branch coverage (as a percentage). |
| `author-name` | `Sanctuary` | The name of the individual or group to whom copyright should be attributed. |
| `license-file` | `LICENSE` | The name of the licence file. |
| `source-files` | `index.js` | Space-separated list of filenames. Globbing is supported. |
| `heading-level` | `4` | The `<h[1-6]>` level of headings transcribed from `heading-prefix` comments. |
| `heading-prefix` | `#` | The character which follows `//` to signify a heading to transcribe. |
| `comment-prefix` | `.` | The character which follows `//` to signify documentation to transcribe. |
| `version-tag-prefix` | `v` | The prefix of annotated version tags (`version-tag-prefix =` for no prefix). |
| Variable name | Default value | Description |
| ----------------------------- | --------------------- | ----------------------------------------------------------------------------- |
| `repo-owner` | | The name of the GitHub user or organization who owns the repository. |
| `repo-name` | | The name of the GitHub repository. |
| `default-branch` | `master` | The name of the repository's default branch. |
| `min-branch-coverage` | `100` | The minimum acceptable branch coverage (as a percentage). |
| `author-name` | `Sanctuary` | The name of the individual or group to whom copyright should be attributed. |
| `license-file` | `LICENSE` | The name of the licence file. |
| `source-files` | `index.js` | Space-separated list of filenames. Globbing is supported. |
| `heading-level` | `4` | The `<h[1-6]>` level of headings transcribed from `heading-prefix` comments. |
| `heading-prefix` | `#` | The character which follows `//` to signify a heading to transcribe. |
| `comment-prefix` | `.` | The character which follows `//` to signify documentation to transcribe. |
| `opening-delimiter` | `` ```javascript `` | The opening delimiter of doctest blocks in the source files. |
| `closing-delimiter` | `` ``` `` | The closing delimiter of doctest blocks in the source files. |
| `version-tag-prefix` | `v` | The prefix of annotated version tags (`version-tag-prefix =` for no prefix). |

### Custom scripts

Expand All @@ -116,9 +118,11 @@ Configurable via [variables][] (`license-file`).

### `doctest`

Runs [`doctest`↗︎][] with suitable `--module` and `--prefix` values.
Runs [`doctest`↗︎][] with suitable `--module`, `--prefix`,
`--opening-delimiter`, and `--closing-delimiter` values.

Configurable via [variables][] (`source-files`, `comment-prefix`).
Configurable via [variables][] (`source-files`, `comment-prefix`,
`opening-delimiter`, `closing-delimiter`).

### `generate-readme`

Expand Down
9 changes: 8 additions & 1 deletion bin/doctest
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ files=($(get source-files))
set -f ; shopt -u nullglob

prefix="$(get comment-prefix)"
opening="$(get opening-delimiter)"
closing="$(get closing-delimiter)"

node_modules/.bin/doctest --module commonjs --prefix "$prefix" -- "${files[@]}"
node_modules/.bin/doctest \
--module commonjs \
--prefix "$prefix" \
--opening-delimiter "$opening" \
--closing-delimiter "$closing" \
-- "${files[@]}"
4 changes: 4 additions & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ get() {
heading-level) printf '4' ;;
heading-prefix) printf '#' ;;
comment-prefix) printf '.' ;;
opening-delimiter) # shellcheck disable=SC2016
printf '```javascript' ;;
closing-delimiter) # shellcheck disable=SC2016
printf '```' ;;
version-tag-prefix) printf 'v' ;;
*)
echo "'$1' not defined in $config" >&2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"npm": ">=3.0.0"
},
"dependencies": {
"doctest": "0.15.x",
"doctest": "0.16.x",
"eslint": "5.15.x",
"eslint-plugin-markdown": "1.0.0-beta.8",
"mocha": "5.x.x",
Expand Down

0 comments on commit 08d0723

Please sign in to comment.