doctrine
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
esutils | 2.0.3 | 9.32 kB | BSD-2-Clause | prod |
Doctrine is a JSDoc parser utilized for analyzing JavaScript documentation comments. Unlike other parsers, Doctrine only needs the comment for examination and does not require the entire JavaScript file. By offering an effective way to parse JSDoc comments, Doctrine helps developers to understand and manage their JavaScript code documentation in a more efficient manner.
To use Doctrine, you first need to install it using npm with the following command:
$ npm install doctrine --save-dev
Doctrine can also be utilized in web browsers with the help of Browserify.
To use Doctrine in your JavaScript code, you need to require it:
var doctrine = require("doctrine");
The main method for Doctrine is parse()
, which accepts a JSDoc comment to parse and optional parameters for customization:
var ast = doctrine.parse(
[
"/**",
" * This function comment is parsed by doctrine",
" * @param {{ok:String}} userName",
"*/"
].join('\n'), { unwrap: true });
In this code, the 'unwrap' option is set to true
, which means that it will remove the leading /**
, any *
that begins a line, and the trailing */
from the source text.
The Doctrine documentation can be found within the Doctrine GitHub project, which provides a comprehensive understanding of the package. The page contains a host of information, including installation instructions, usage guidelines, and options for customizing the parser. Developers can also check out the demo page at http://eslint.org/doctrine/demo/ for more details. For any additional questions or support, you can join the Doctrine chatroom.