{"library":"markdown-doctest","title":"Markdown Doctest","description":"markdown-doctest is a command-line utility designed to automatically test code examples embedded within Markdown documentation files. Its primary purpose is to prevent out-of-date or broken code snippets from appearing in project READMEs and other documentation, thereby improving the user experience and reducing embarrassing issues for open-source maintainers. The current stable version is 1.1.0. The project has seen releases relatively consistently in its past, indicating an active maintenance phase, though a specific release cadence is not strictly defined. It differentiates itself by focusing specifically on validating documentation code for executability rather than correctness (unless assertions are explicitly added), integrating seamlessly into CI/CD pipelines, and offering flexible configuration for requiring modules, defining globals, and ignoring specific examples or file patterns. It's not a replacement for a comprehensive test suite but rather a complementary tool for documentation integrity.","language":"javascript","status":"active","last_verified":"Thu Apr 23","install":{"commands":["npm install markdown-doctest"],"cli":{"name":"markdown-doctest","version":null}},"imports":["npx markdown-doctest [glob]","module.exports = { /* config object */ };","<!-- skip-example -->\n```js\n// code to skip\n```"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"mkdir doctest-example\ncd doctest-example\nnpm init -y\nnpm install markdown-doctest\n\ncat > README.md <<EOF\n# My Awesome Project\n\nThis is a great project!\n\n## Example Usage\n\n```js\nconst greeting = \"Hello\";\nconst name = \"World\";\nconsole.log(greeting + \", \" + name + \"!\");\n```\n\n## Broken Example\n\n```js\n// This will fail\nconst x = 10;\nconsole.log(x + y);\n```\nEOF\n\n# Run the doctests\nnpx markdown-doctest\n\n# Expected Output (truncated, showing failure)\n# x. \n# \n# Failed - README.md:16:17\n# evalmachine.<anonymous>:7\n# console.log(x + y);\n#                 ^\n# \n# ReferenceError: y is not defined","lang":"bash","description":"Demonstrates installing markdown-doctest, creating a markdown file with both a working and a broken code example, and then running the doctests to show how errors are reported.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}