A library/tool for validating JavaScript code in Markdown documentation
doc-validator
A library/tool for validating JavaScript code in Markdown documentation
In development. JavaScript code in Markdown documentation can be parsed via the API or CLI, but there is no support for running code yet (see 1.0.0 milestone).
Install doc-validator
as a dependency. All commands take a Markdown source string and return an Array of any Errors reported. Errors are not thrown to make it easier to detect multiple errors from separate JavaScript code examples in the same file, so you will probably want to print or throw them.
Install doc-validator
globally for any project, or as a local development dependency for CI and test scripts. Use with a filename like doc-validator parse README.md
to parse existing Markdown files, or pass stdin with no path argument for advanced scripting.
parse
Parses JavaScript using Babel. Modern standardized syntax is supported, including ES modules (supported by Node).
const { parse } = require("doc-validator")
;(async () => {
await parse('```js\nconsole.log("Hello, world!")\n```')
})()
type
run
test