Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

doctrine

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doctrine

JSDoc parser

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
72M
decreased by-4.6%
Maintainers
4
Weekly downloads
 
Created

What is doctrine?

The doctrine npm package is a JSDoc type expression parser written in JavaScript. It allows developers to parse JSDoc comments and extract useful information and metadata about the code, which can be used for documentation generation, type checking, and other analysis purposes.

What are doctrine's main functionalities?

Parsing JSDoc comments

This feature allows you to parse JSDoc comments to extract information such as descriptions, parameters, and return types. The 'unwrap' option tells doctrine to strip the leading /**, trailing */, and any * that begins a line from the source text.

{"var doctrine = require('doctrine');\nvar ast = doctrine.parse('/**\n * This function adds two numbers together.\n * @param {number} a The first number.\n * @param {number} b The second number.\n * @return {number} The sum of the two numbers.\n */', { unwrap: true });\nconsole.log(ast);"}

Extracting type information

With this feature, you can extract type information from JSDoc comments. It parses the type expression and provides an abstract syntax tree (AST) representing the type information.

{"var doctrine = require('doctrine');\nvar ast = doctrine.parse('/** @type {Array.<string>} */', { unwrap: true });\nconsole.log(ast);"}

Parsing with recoverable errors

This feature allows parsing with recoverable errors, meaning that it will try to parse as much as possible without throwing an error immediately. This is useful for handling incomplete or incorrect JSDoc comments.

{"var doctrine = require('doctrine');\ntry {\n  var ast = doctrine.parse('/** @param {string} name */', { recoverable: true });\n  console.log(ast);\n} catch (error) {\n  console.error('Failed to parse:', error);\n}"}

Other packages similar to doctrine

FAQs

Package last updated on 10 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc