jsdoc3-parser is a utility designed to extract the Abstract Syntax Tree (AST) from JavaScript files by leveraging JSDoc's internal parser. It operates by invoking the JSDoc CLI with the `-X` option, which outputs the parsed documentation as JSON, and then processes this output. As of its last major release, version 3.0.0, published approximately three years ago, this package offered a workaround for the absence of a direct programmatic API for JSDoc's parser. However, the official JSDoc project now provides `@jsdoc/parse` which offers a direct, programmatic approach. Consequently, `jsdoc3-parser` has seen no recent updates and its core method of operation is now largely superseded, making its release cadence effectively ceased. Its key differentiator was its ability to provide JSDoc's parsed output programmatically at a time when no official library existed for this purpose.
npm install jsdoc3-parserVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to parse a JavaScript file containing JSDoc comments to retrieve its AST (doclets) using `jsdoc3-parser`. It writes a temporary file, parses it, and then logs parts of the resulting JSDoc AST.
Migrate to `@jsdoc/parse` for official and stable programmatic JSDoc parsing, or carefully pin JSDoc CLI version.
Ensure JSDoc is installed and globally accessible (e.g., `npm install -g jsdoc`) or configured in your environment's PATH.
Transition to using `@jsdoc/parse` for modern, stable, and direct programmatic JSDoc parsing. Consider alternatives like `jsdoc-parse` or `jsdoctypeparser` for specific AST needs.
For projects using modern JavaScript, consider `@jsdoc/parse` or other actively maintained AST parsers that are kept up-to-date with ECMAScript specifications.
Install JSDoc globally: `npm install -g jsdoc`, or ensure its executable path is correctly configured in your environment.
Ensure you are using CommonJS `const parser = require('jsdoc3-parser');` and calling `parser(filePath, callback)` as shown in the quickstart.Pin your JSDoc CLI version to the one compatible with `jsdoc3-parser` (likely an older JSDoc 3.x version from ~2023), or migrate to `@jsdoc/parse` for more robust parsing.