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

dmd

Package Overview
Dependencies
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dmd - npm Package Compare versions

Comparing version 6.2.3 to 6.3.0-1

partials/partial-cache.js

79

helpers/ddata.js

@@ -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) {

@@ -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": [

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