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

@es-joy/jsdoccomment

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@es-joy/jsdoccomment - npm Package Compare versions

Comparing version 0.37.1 to 0.38.0

src/parseInlineTags.js

4

CHANGES.md
# CHANGES for `@es-joy/jsdoccomment`
## 0.38.0
- feat: add parsing inline tags (#12); fixes #11
## 0.37.1

@@ -4,0 +8,0 @@

4

package.json
{
"name": "@es-joy/jsdoccomment",
"version": "0.37.1",
"version": "0.38.0",
"author": "Brett Zamir <brettz9@yahoo.com>",

@@ -41,3 +41,3 @@ "contributors": [],

"engines": {
"node": "^14 || ^16 || ^17 || ^18 || ^19 || ^20"
"node": ">=16"
},

@@ -44,0 +44,0 @@ "dependencies": {

@@ -56,13 +56,24 @@ import {parse as jsdocTypePrattParse} from 'jsdoc-type-pratt-parser';

* @typedef {{
* format: 'pipe' | 'plain' | 'prefix' | 'space',
* namepathOrURL: string,
* tag: string,
* text: string,
* type: "JsdocInlineTag"
* }} JsdocInlineTag
*/
/**
* @typedef {{
* delimiter: string,
* description: string,
* descriptionLines: JsdocDescriptionLine[],
* initial: string,
* inlineTags: JsdocInlineTag[]
* postDelimiter: string,
* initial: string,
* rawType: string,
* tag: string,
* terminal: string,
* type: "JsdocTag",
* type: string,
* descriptionLines: JsdocDescriptionLine[],
* rawType: string,
* type: "JsdocTag",
* typeLines: JsdocTypeLine[]
* typeLines: JsdocTypeLine[],
* }} JsdocTag

@@ -77,11 +88,20 @@ */

* initial: string,
* inlineTags: JsdocInlineTag[]
* lastDescriptionLine: Integer,
* lineEnd: string,
* postDelimiter: string,
* tags: JsdocTag[],
* terminal: string,
* postDelimiter: string,
* lineEnd: string,
* type: "JsdocBlock",
* lastDescriptionLine: Integer,
* tags: JsdocTag[]
* }} JsdocBlock
*/
const inlineTagToAST = ({text, tag, format, namepathOrURL}) => ({
text,
tag,
format,
namepathOrURL,
type: 'JsdocInlineTag'
});
/**

@@ -128,3 +148,3 @@ * Converts comment parser AST to ESTree format.

const {source} = jsdoc;
const {source, inlineTags: blockInlineTags} = jsdoc;

@@ -145,2 +165,3 @@ const {tokens: {

descriptionLines: [],
inlineTags: blockInlineTags.map((t) => inlineTagToAST(t)),

@@ -248,2 +269,11 @@ initial: startRoot,

let tagInlineTags = [];
if (tag) {
// Assuming the tags from `source` are in the same order as `jsdoc.tags`
// we can use the `tags` length as index into the parser result tags.
tagInlineTags = jsdoc.tags[tags.length].inlineTags.map(
(t) => inlineTagToAST(t)
);
}
const tagObj = {

@@ -255,2 +285,3 @@ ...tkns,

descriptionLines: [],
inlineTags: tagInlineTags,
rawType: '',

@@ -340,8 +371,9 @@ type: 'JsdocTag',

const jsdocVisitorKeys = {
JsdocBlock: ['descriptionLines', 'tags'],
JsdocBlock: ['descriptionLines', 'tags', 'inlineTags'],
JsdocDescriptionLine: [],
JsdocTypeLine: [],
JsdocTag: ['parsedType', 'typeLines', 'descriptionLines']
JsdocTag: ['parsedType', 'typeLines', 'descriptionLines', 'inlineTags'],
JsdocInlineTag: []
};
export {commentParserToESTree, jsdocVisitorKeys};

@@ -7,2 +7,4 @@ /* eslint-disable prefer-named-capture-group -- Temporary */

import parseInlineTags from './parseInlineTags.js';
const {

@@ -115,8 +117,9 @@ name: nameTokenizer,

// Preserve JSDoc block start/end indentation.
return commentParser(`${indent}/*${commentNode.value}*/`, {
const [block] = commentParser(`${indent}/*${commentNode.value}*/`, {
// @see https://github.com/yavorskiy/comment-parser/issues/21
tokenizers: getTokenizers()
})[0];
});
return parseInlineTags(block);
};
export {getTokenizers, parseComment};

Sorry, the diff of this file is not supported yet

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