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