Cleanup npm link creation.

This commit is contained in:
John-David Dalton
2016-08-01 14:17:25 -07:00
parent fcaff8ff28
commit a4999575d0

View File

@@ -23,28 +23,40 @@ var config = {
}, },
'github': { 'github': {
'style': 'github', 'style': 'github',
'sublinks': [ 'sublinks': [npmLink('Ⓝ', 'See the npm package')]
'<% if (name == "templateSettings" || !/^(?:methods|properties|seq)$/i.test(category)) {' +
'print("[&#x24C3;](https://www.npmjs.com/package/lodash." + name.toLowerCase() + " \\"See the npm package\\")")' +
'} %>'
]
}, },
'site': { 'site': {
'entryLink': '<a href="${entryHref}" class="fa fa-link"></a>', 'entryLink': '<a href="${entryHref}" class="fa fa-link"></a>',
'sourceLink': '[source](${sourceHref})', 'sourceLink': '[source](${sourceHref})',
'tocHref': '', 'tocHref': '',
'tocLink': '', 'tocLink': '',
'sublinks': [ 'sublinks': [npmLink('npm package')]
'<% if (name == "templateSettings" || !/^(?:methods|properties|seq)$/i.test(category)) {' +
'print("[npm package](https://www.npmjs.com/package/lodash." + name.toLowerCase() + ")")' +
'} %>'
]
} }
}; };
/**
* Composes a npm link from `text` and optional `title`.
*
* @private
* @param {string} text The link text.
* @param {string} [title] The link title.
* @returns {string} Returns the composed npm link.
*/
function npmLink(text, title) {
return (
'<% if (name == "templateSettings" || !/^(?:methods|properties|seq)$/i.test(category)) {' +
'print(' +
'"[' + text + '](https://www.npmjs.com/package/lodash." + name.toLowerCase() + ' +
'"' + (title == null ? '' : ' \\"' + title + '\\"') + ')"' +
');' +
'} %>'
);
}
/** /**
* Post-process `markdown` to make adjustments. * Post-process `markdown` to make adjustments.
* *
* @private
* @param {string} markdown The markdown to process. * @param {string} markdown The markdown to process.
* @returns {string} Returns the processed markdown. * @returns {string} Returns the processed markdown.
*/ */
@@ -58,6 +70,7 @@ function postprocess(markdown) {
/** /**
* Creates the documentation markdown formatted for 'github' or 'site'. * Creates the documentation markdown formatted for 'github' or 'site'.
* *
* @private
* @param {string} type The format type. * @param {string} type The format type.
*/ */
function build(type) { function build(type) {