swagger-jsdoc
Advanced tools
Comparing version 4.2.3 to 4.3.0
const fs = require('fs'); | ||
const path = require('path'); | ||
const parseApiFileContent = require('./parseApiFileContent'); | ||
/** | ||
@@ -5,0 +6,0 @@ * Parses the provided API file for JSDoc comments. |
@@ -15,14 +15,34 @@ const doctrine = require('doctrine'); | ||
const jsDocRegex = /\/\*\*([\s\S]*?)\*\//gm; | ||
const csDocRegex = /###([\s\S]*?)###/gm; | ||
const yaml = []; | ||
const jsDocComments = []; | ||
const jsdoc = []; | ||
let regexResults = null; | ||
if (ext === '.yaml' || ext === '.yml') { | ||
yaml.push(jsYaml.safeLoad(fileContent)); | ||
} else { | ||
const regexResults = fileContent.match(jsDocRegex); | ||
if (regexResults) { | ||
for (let i = 0; i < regexResults.length; i += 1) { | ||
const jsDocComment = doctrine.parse(regexResults[i], { unwrap: true }); | ||
jsDocComments.push(jsDocComment); | ||
switch (ext) { | ||
case '.yml': | ||
case '.yaml': | ||
yaml.push(jsYaml.safeLoad(fileContent)); | ||
break; | ||
case '.coffee': | ||
regexResults = fileContent.match(csDocRegex); | ||
if (regexResults) { | ||
for (let i = 0; i < regexResults.length; i += 1) { | ||
// Prepare input for doctrine | ||
let part = regexResults[i].split('###'); | ||
part[0] = `/**`; | ||
part[regexResults.length - 1] = '*/'; | ||
part = part.join(''); | ||
jsdoc.push(doctrine.parse(part, { unwrap: true })); | ||
} | ||
} | ||
break; | ||
default: { | ||
regexResults = fileContent.match(jsDocRegex); | ||
if (regexResults) { | ||
for (let i = 0; i < regexResults.length; i += 1) { | ||
jsdoc.push(doctrine.parse(regexResults[i], { unwrap: true })); | ||
} | ||
} | ||
} | ||
@@ -33,3 +53,3 @@ } | ||
yaml, | ||
jsdoc: jsDocComments, | ||
jsdoc, | ||
}; | ||
@@ -36,0 +56,0 @@ } |
{ | ||
"name": "swagger-jsdoc", | ||
"version": "4.2.3", | ||
"version": "4.3.0", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=10.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29477
595