Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Get started

Doc Detective is versatile, and you can deploy it in many ways to suit the requirements of your development environment. This guide covers the most common deployment methods: as a CLI tool.

You can run Doc Detective as a standalone CLI tool. When running as a CLI tool, you can specify default configuration options in config.json and override those defaults with command-line arguments. (For a list of arguments, complete the following steps and run npm run test -- -h.)

Install

  1. Install prerequisites:

  2. In a terminal, clone the repo and install dependencies:

    git clone https://github.com/doc-detective/doc-detective.git
    cd doc-detective
    npm install
    

Run tests

To run your tests, use the runTests command and specify your test file with the --input argument. For example, to run tests in a file named doc-content.md in the samples directory (like in this repo!), run the following command:

npm run runTests -- --input ./samples/doc-content.md

To customize your test, file type, and directory options, create a config.json file and reference it with the --config argument.

npm run runTests -- --config ./samples/config.json

You can override config.json options with command-line arguments. For example, to run tests in a file named tests.spec.json in the samples directory, run the following command:

npm run runTests -- --config ./samples/config.json --input ./samples/tests.spec.json

To see all available options, use the --help argument:

npm run runTests -- --help

Check your test coverage

You can check the test coverage of your documentation source files with the runCoverage command, specifying the source file or directory of source files with the --input argument. Doc Detective identifies potential areas of test coverage with file-format-specific regex, and supports CommonMark syntax natively. If you want to test coverage of a file with different syntax, update your the fileTypes object of your config.json file accordingly.

npm run runCoverage -- --config ./samples/config.json --input ./samples/doc-content.md

To see all available options, use the --help argument:

npm run runCoverage -- --help