Comparing version 6.2.3 to 6.3.0-1
@@ -7,5 +7,19 @@ const arrayify = require('array-back') | ||
const where = require('test-value').where | ||
const flatten = require('reduce-flatten') | ||
const state = require('../lib/state') | ||
let malformedDataWarningIssued = false | ||
function isValidURL (url) { | ||
try { | ||
new URL(url) | ||
return true | ||
} catch (err) { | ||
if (err.code === 'ERR_INVALID_URL') { | ||
return false | ||
} else { | ||
throw err | ||
} | ||
} | ||
} | ||
/** | ||
@@ -269,3 +283,3 @@ * ddata is a collection of handlebars helpers for working with the documentation data output by [jsdoc-parse](https://github.com/75lb/jsdoc-parse). | ||
symbol: '⇒', | ||
types: typeNames.reduce(flatten, []) | ||
types: typeNames.flat() | ||
}) | ||
@@ -340,3 +354,3 @@ } else { | ||
if (typeNames.length) { | ||
data.returnTypes = typeNames.reduce(flatten, []) | ||
data.returnTypes = typeNames.flat() | ||
} | ||
@@ -453,3 +467,2 @@ } else if ((this.type || this.kind === 'namespace') && this.kind !== 'event') { | ||
const query = {} | ||
for (const prop in options.hash) { | ||
@@ -479,2 +492,11 @@ if (/^-/.test(prop)) { | ||
if (!this.id) return [] | ||
if (this.id === this.memberof) { | ||
if (!malformedDataWarningIssued) { | ||
console.warn('Jsdoc data looks malformed. Typically, this can be fixed by ensuring the sourcecode file has a `@module tag`. ') | ||
console.warn('Please see the "Document an ES2015 module" section in the wiki') | ||
console.warn('https://github.com/jsdoc2md/jsdoc-to-markdown/wiki') | ||
malformedDataWarningIssued = true | ||
} | ||
return [] | ||
} | ||
const min = options.hash.min | ||
@@ -509,6 +531,6 @@ delete options.hash.min | ||
if (childrenList.length) { | ||
childrenList.forEach(function (child) { | ||
for (const child of childrenList) { | ||
output.push(child) | ||
iterate(_children.call(child, options)) | ||
}) | ||
} | ||
} | ||
@@ -619,13 +641,14 @@ } | ||
* @param {string} - a string containing one or more {@link} tags | ||
* @returns {Array.<{original: string, caption: string, url: string}>} | ||
* @param {object} - `dmdOptions`; link formatting is influenced by the `clever-links` and `monospace-links` values | ||
* @returns {Array.<{original: string, caption: string, url: string, format: 'code'|'plain'}>} | ||
* @static | ||
*/ | ||
function parseLink (text) { | ||
function parseLink (text, dmdOptions = {}) { | ||
if (!text) return '' | ||
const results = [] | ||
let matches = null | ||
const link1 = /{@link\s+([^\s}|]+?)\s*}/g // {@link someSymbol} | ||
const link2 = /\[([^\]]+?)\]{@link\s+([^\s}|]+?)\s*}/g // [caption here]{@link someSymbol} | ||
const link3 = /{@link\s+([^\s}|]+?)\s*\|([^}]+?)}/g // {@link someSymbol|caption here} | ||
const link4 = /{@link\s+([^\s}|]+?)\s+([^}|]+?)}/g // {@link someSymbol Caption Here} | ||
const link1 = /{@link(code|plain)?\s+([^\s}|]+?)\s*}/g // {@link someSymbol} | ||
const link2 = /\[([^\]]+?)\]{@link(code|plain)?\s+([^\s}|]+?)\s*}/g // [caption here]{@link someSymbol} | ||
const link3 = /{@link(code|plain)?\s+([^\s}|]+?)\s*\|([^}]+?)}/g // {@link someSymbol|caption here} | ||
const link4 = /{@link(code|plain)?\s+([^\s}|]+?)\s+([^}|]+?)}/g // {@link someSymbol Caption Here} | ||
@@ -635,4 +658,5 @@ while ((matches = link4.exec(text)) !== null) { | ||
original: matches[0], | ||
caption: matches[2], | ||
url: matches[1] | ||
caption: matches[3], | ||
url: matches[2], | ||
format: matches[1] | ||
}) | ||
@@ -645,4 +669,5 @@ text = text.replace(matches[0], ' '.repeat(matches[0].length)) | ||
original: matches[0], | ||
caption: matches[2], | ||
url: matches[1] | ||
caption: matches[3], | ||
url: matches[2], | ||
format: matches[1] | ||
}) | ||
@@ -656,3 +681,4 @@ text = text.replace(matches[0], ' '.repeat(matches[0].length)) | ||
caption: matches[1], | ||
url: matches[2] | ||
url: matches[3], | ||
format: matches[2] | ||
}) | ||
@@ -665,7 +691,22 @@ text = text.replace(matches[0], ' '.repeat(matches[0].length)) | ||
original: matches[0], | ||
caption: matches[1], | ||
url: matches[1] | ||
caption: matches[2], | ||
url: matches[2], | ||
format: matches[1] | ||
}) | ||
text = text.replace(matches[0], ' '.repeat(matches[0].length)) | ||
} | ||
results.forEach((result) => { | ||
const format = result.format | ||
if (format === undefined) { | ||
result.format = format || // if tag is @linkplain or @linkcode, then that determines the format | ||
// else, if 'clever-links' is true, then if the link is a URL, it's plain, otherwise code format | ||
(dmdOptions['clever-links'] && (isValidURL(result.url) ? 'plain' : 'code')) || | ||
// else, if 'monospace-links' is true, then all links are code format | ||
(dmdOptions['monospace-links'] && 'code') || | ||
// else, it's a plain | ||
'plain' | ||
} | ||
}) | ||
return results | ||
@@ -672,0 +713,0 @@ } |
@@ -7,3 +7,2 @@ const ddata = require('./ddata') | ||
const unique = require('reduce-unique') | ||
const without = require('reduce-without') | ||
@@ -44,12 +43,14 @@ /** | ||
/** | ||
replaces {@link} tags with markdown links in the suppied input text | ||
replaces {@link}, {@linkplain}, and {@linkcode} tags with markdown links in the supplied input text | ||
*/ | ||
function inlineLinks (text, options) { | ||
if (text) { | ||
const links = ddata.parseLink(text) | ||
const dmdOptions = options.data.root.options | ||
const links = ddata.parseLink(text, dmdOptions) | ||
links.forEach(function (link) { | ||
const captionFmt = link.format === 'code' ? '`' : '' | ||
const linked = ddata._link(link.url, options) | ||
if (link.caption === link.url) link.caption = linked.name | ||
if (linked.url) link.url = linked.url | ||
text = text.replace(link.original, '[' + link.caption + '](' + link.url + ')') | ||
text = text.replace(link.original, '[' + captionFmt + link.caption + captionFmt + '](' + link.url + ')') | ||
}) | ||
@@ -109,5 +110,6 @@ } | ||
let output = '' | ||
let data | ||
if (options.data) { | ||
var data = handlebars.createFrame(options.data) | ||
data = handlebars.createFrame(options.data) | ||
cols.forEach(function (col, index) { | ||
@@ -205,3 +207,3 @@ const colNumber = index + 1 | ||
.reduce(unique, []) | ||
if (groupValues.length <= 1) groupByFields = groupByFields.reduce(without(group), []) | ||
if (groupValues.length <= 1) groupByFields = groupByFields.filter(g => g !== group) | ||
}) | ||
@@ -312,2 +314,3 @@ identifiers = _addGroup(identifiers, groupByFields) | ||
const lines = example.split(/\r\n|\r|\n/) | ||
let exampleLangSubtag | ||
@@ -318,3 +321,3 @@ /* Process @lang */ | ||
if (matches) { | ||
var exampleLangSubtag = matches[1] | ||
exampleLangSubtag = matches[1] | ||
lines[0] = lines[0].replace(matches[0], '') | ||
@@ -321,0 +324,0 @@ if (lines[0].length === 0) { |
60
index.js
@@ -1,11 +0,12 @@ | ||
/** | ||
* @module dmd | ||
*/ | ||
const path = require('path') | ||
const Cache = require('cache-point') | ||
const DmdOptions = require('./lib/dmd-options') | ||
const dmdVersion = require('./package').version | ||
const FileSet = require('file-set') | ||
const os = require('os') | ||
const fs = require('fs') | ||
const partialCache = require('./partials/partial-cache.js') | ||
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, './package.json'), 'utf8')) | ||
const dmdVersion = pkg.version | ||
/** | ||
@@ -15,6 +16,6 @@ * Transforms doclet data into markdown documentation. | ||
* @param [options] {module:dmd-options} - The render options | ||
* @return {string} | ||
* @return {Promise<string>} | ||
* @alias module:dmd | ||
*/ | ||
function dmd (templateData, options) { | ||
async function dmd (templateData, options) { | ||
options = new DmdOptions(options) | ||
@@ -24,6 +25,7 @@ if (skipCache(options)) { | ||
} else { | ||
const cached = dmd.cache.readSync([templateData, options, dmdVersion]) | ||
if (cached) { | ||
return cached | ||
} else { | ||
try { | ||
const result = await dmd.cache.read([templateData, options, dmdVersion]) | ||
return result | ||
} catch (err) { | ||
/* cache miss */ | ||
return generate(templateData, options) | ||
@@ -34,17 +36,5 @@ } | ||
dmd.async = function (templateData, options) { | ||
options = new DmdOptions(options) | ||
if (skipCache(options)) { | ||
return Promise.resolve(generate(templateData, options)) | ||
} else { | ||
return dmd.cache.read([templateData, options, dmdVersion]) | ||
.catch(function () { | ||
return generate(templateData, options) | ||
}) | ||
} | ||
} | ||
dmd.cache = new Cache({ dir: path.join(os.tmpdir(), 'dmd') }) | ||
dmd.cache = new Cache({ dir: path.join(require('os').tmpdir(), 'dmd') }) | ||
function generate (templateData, options) { | ||
async function generate (templateData, options) { | ||
const fs = require('fs') | ||
@@ -57,4 +47,5 @@ const path = require('path') | ||
function registerPartials (paths) { | ||
const fileSet = new FileSet(paths) | ||
async function registerPartials (paths) { | ||
const fileSet = new FileSet() | ||
await fileSet.add(paths) | ||
for (const file of fileSet.files) { | ||
@@ -68,4 +59,5 @@ handlebars.registerPartial( | ||
function registerHelpers (helpers) { | ||
const fileSet = new FileSet(helpers) | ||
async function registerHelpers (helpers) { | ||
const fileSet = new FileSet() | ||
await fileSet.add(helpers) | ||
for (const file of fileSet.files) { | ||
@@ -97,4 +89,6 @@ handlebars.registerHelper(require(path.resolve(process.cwd(), file))) | ||
/* register all dmd partials. */ | ||
registerPartials(path.resolve(__dirname, './partials/**/*.hbs')) | ||
/* register all internal dmd partials. */ | ||
for (const [name, content] of partialCache) { | ||
handlebars.registerPartial(name, content) | ||
} | ||
@@ -127,4 +121,4 @@ /* if plugins were specified, register the helpers/partials from them too */ | ||
/* if additional partials/helpers paths were specified, register them too */ | ||
if (options.partial.length) registerPartials(options.partial) | ||
if (options.helper.length) registerHelpers(options.helper) | ||
if (options.partial.length) await registerPartials(options.partial) | ||
if (options.helper.length) await registerHelpers(options.helper) | ||
@@ -131,0 +125,0 @@ const compiled = handlebars.compile(options.template, { |
@@ -84,2 +84,16 @@ /** | ||
/** | ||
* If true, \{@link XXX} tags are rendered in normal text if XXX is a URL and monospace (code) format otherwise. | ||
* @type {boolean} | ||
* @dafult | ||
*/ | ||
this['clever-links'] = false | ||
/** | ||
* If true, all \{@link} tags are rendered in monospace (code) format. This setting is ignored in `clever-links` is true. | ||
* @type {boolean} | ||
* @default | ||
*/ | ||
this['monospace-links'] = false | ||
/** | ||
* Show identifiers marked `@private` in the output. | ||
@@ -86,0 +100,0 @@ * @type {boolean} |
{ | ||
"name": "dmd", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "6.2.3", | ||
"version": "6.3.0-1", | ||
"description": "The default output template for jsdoc-to-markdown", | ||
@@ -11,2 +11,3 @@ "license": "MIT", | ||
}, | ||
"exports": "./index.js", | ||
"keywords": [ | ||
@@ -17,3 +18,3 @@ "documentation", | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=12.17" | ||
}, | ||
@@ -27,22 +28,28 @@ "files": [ | ||
"scripts": { | ||
"test": "test-runner test/*.js test/ddata/*.js" | ||
"test": "75lb-nature test-runner test/api.js test/grouping.js test/parseType.js test/plugin.js test/ddata/children.js test/ddata/globals.js test/ddata/linkTo.js test/ddata/list.js test/ddata/orphans.js test/ddata/parseLink.js test/ddata/return-sig.js test/ddata/type-link.js", | ||
"partials": "node bin/generate-partial-cache.js > partials/partial-cache.js" | ||
}, | ||
"dependencies": { | ||
"array-back": "^6.2.2", | ||
"cache-point": "^2.0.0", | ||
"cache-point": "^3.0.0", | ||
"common-sequence": "^2.0.2", | ||
"file-set": "^4.0.2", | ||
"file-set": "^5.2.0", | ||
"handlebars": "^4.7.8", | ||
"marked": "^4.3.0", | ||
"marked": "^14.1.0", | ||
"object-get": "^2.1.1", | ||
"reduce-flatten": "^3.0.1", | ||
"reduce-unique": "^2.0.1", | ||
"reduce-without": "^1.0.1", | ||
"test-value": "^3.0.0", | ||
"walk-back": "^5.1.0" | ||
"walk-back": "^5.1.1" | ||
}, | ||
"devDependencies": { | ||
"dmd-plugin-example": "^0.1.0", | ||
"test-runner": "^0.10.1" | ||
"dmd-plugin-example": "^0.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@75lb/nature": "latest" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@75lb/nature": { | ||
"optional": true | ||
} | ||
}, | ||
"standard": { | ||
@@ -49,0 +56,0 @@ "ignore": [ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
82002
11
1
75
2085
2
5
+ Added@75lb/nature@0.1.9(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Added@isaacs/cliui@8.0.2(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jsdoc/salty@0.2.8(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@pkgjs/parseargs@0.11.0(transitive)
+ Added@rollup/plugin-commonjs@26.0.3(transitive)
+ Added@rollup/plugin-node-resolve@15.3.0(transitive)
+ Added@rollup/pluginutils@5.1.3(transitive)
+ Added@rollup/rollup-android-arm-eabi@4.27.3(transitive)
+ Added@rollup/rollup-android-arm64@4.27.3(transitive)
+ Added@rollup/rollup-darwin-arm64@4.27.3(transitive)
+ Added@rollup/rollup-darwin-x64@4.27.3(transitive)
+ Added@rollup/rollup-freebsd-arm64@4.27.3(transitive)
+ Added@rollup/rollup-freebsd-x64@4.27.3(transitive)
+ Added@rollup/rollup-linux-arm-gnueabihf@4.27.3(transitive)
+ Added@rollup/rollup-linux-arm-musleabihf@4.27.3(transitive)
+ Added@rollup/rollup-linux-arm64-gnu@4.27.3(transitive)
+ Added@rollup/rollup-linux-arm64-musl@4.27.3(transitive)
+ Added@rollup/rollup-linux-powerpc64le-gnu@4.27.3(transitive)
+ Added@rollup/rollup-linux-riscv64-gnu@4.27.3(transitive)
+ Added@rollup/rollup-linux-s390x-gnu@4.27.3(transitive)
+ Added@rollup/rollup-linux-x64-gnu@4.27.3(transitive)
+ Added@rollup/rollup-linux-x64-musl@4.27.3(transitive)
+ Added@rollup/rollup-win32-arm64-msvc@4.27.3(transitive)
+ Added@rollup/rollup-win32-ia32-msvc@4.27.3(transitive)
+ Added@rollup/rollup-win32-x64-msvc@4.27.3(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/linkify-it@5.0.0(transitive)
+ Added@types/markdown-it@14.1.2(transitive)
+ Added@types/mdurl@2.0.0(transitive)
+ Added@types/resolve@1.20.2(transitive)
+ Addedansi-escape-sequences@6.2.3(transitive)
+ Addedansi-regex@5.0.16.1.0(transitive)
+ Addedansi-styles@4.3.06.2.1(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedcache-point@3.0.0(transitive)
+ Addedcatharsis@0.9.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchalk-template@0.4.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommand-line-args@6.0.1(transitive)
+ Addedcommand-line-usage@7.0.3(transitive)
+ Addedcommondir@1.0.1(transitive)
+ Addedconfig-master@3.1.0(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addedcurrent-module-paths@1.1.2(transitive)
+ Addeddeepmerge@4.3.1(transitive)
+ Addeddmd@7.0.7(transitive)
+ Addedeastasianwidth@0.2.0(transitive)
+ Addedemoji-regex@8.0.09.2.2(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedescape-string-regexp@2.0.0(transitive)
+ Addedestree-walker@2.0.2(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfile-set@5.2.2(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-replace@5.0.2(transitive)
+ Addedforeground-child@3.3.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedglob@10.4.5(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-module@1.0.0(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-reference@1.2.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjackspeak@3.4.3(transitive)
+ Addedjs2xmlparser@4.0.2(transitive)
+ Addedjsdoc@4.0.4(transitive)
+ Addedjsdoc-api@9.3.4(transitive)
+ Addedjsdoc-parse@6.2.4(transitive)
+ Addedjsdoc-to-markdown@9.0.5(transitive)
+ Addedklaw@3.0.0(transitive)
+ Addedlinkify-it@5.0.0(transitive)
+ Addedload-module@5.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlodash.camelcase@4.3.0(transitive)
+ Addedlodash.omit@4.5.0(transitive)
+ Addedlru-cache@10.4.3(transitive)
+ Addedmagic-string@0.30.13(transitive)
+ Addedmarkdown-it@14.1.0(transitive)
+ Addedmarkdown-it-anchor@8.6.7(transitive)
+ Addedmarked@14.1.4(transitive)
+ Addedmdurl@2.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedminimatch@9.0.5(transitive)
+ Addedminipass@7.1.2(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addednature@0.7.0(transitive)
+ Addedobject-to-spawn-args@2.0.1(transitive)
+ Addedpackage-json-from-dist@1.0.1(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpath-scurry@1.11.1(transitive)
+ Addedpicomatch@2.3.14.0.2(transitive)
+ Addedpunycode.js@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedrequizzle@0.2.4(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrollup@4.27.3(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedsort-array@5.0.0(transitive)
+ Addedstring-width@4.2.35.1.2(transitive)
+ Addedstrip-ansi@6.0.17.1.0(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtable-layout@4.1.1(transitive)
+ Addedtest-runner@0.12.0-8(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtypical@7.3.0(transitive)
+ Addeduc.micro@2.1.0(transitive)
+ Addedunderscore@1.13.7(transitive)
+ Addedwalk-back@2.0.1(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedwordwrapjs@5.1.0(transitive)
+ Addedwrap-ansi@7.0.08.1.0(transitive)
+ Addedxmlcreate@2.0.4(transitive)
- Removedreduce-flatten@^3.0.1
- Removedreduce-without@^1.0.1
- Removedarray-back@1.0.44.0.25.0.0(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcache-point@2.0.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedfile-set@4.0.2(transitive)
- Removedfs-then-native@2.0.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedmkdirp2@1.0.5(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedreduce-flatten@3.0.1(transitive)
- Removedreduce-without@1.0.1(transitive)
- Removedtest-value@2.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedcache-point@^3.0.0
Updatedfile-set@^5.2.0
Updatedmarked@^14.1.0
Updatedwalk-back@^5.1.1