-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(renderers): use a templating system with EJS (#106)
Use http://ejs.co.
- Loading branch information
Showing
24 changed files
with
453 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable no-console */ | ||
|
||
const getTemplatePath = require('../../lib/core/getTemplatePath'); | ||
|
||
describe('guessTemplatePath', () => { | ||
test('guess default', () => { | ||
expect(getTemplatePath().endsWith('lib/templates/default.ejs')).toBeTruthy(); | ||
expect(getTemplatePath('default').endsWith('lib/templates/default.ejs')).toBeTruthy(); | ||
}); | ||
|
||
test('guess docstrap', () => { | ||
const templatePath = getTemplatePath('./node_modules/ink-docstrap/template'); | ||
|
||
expect(templatePath.endsWith('lib/templates/docstrap.ejs')).toBeTruthy(); | ||
}); | ||
|
||
test('guess minami', () => { | ||
const templatePath = getTemplatePath('node_modules/minami'); | ||
|
||
expect(templatePath.endsWith('lib/templates/minami.ejs')).toBeTruthy(); | ||
}); | ||
|
||
test('guess tui', () => { | ||
const templatePath = getTemplatePath('node_modules/tui-jsdoc-template'); | ||
|
||
expect(templatePath.endsWith('lib/templates/tui.ejs')).toBeTruthy(); | ||
}); | ||
|
||
test('guess unsupported', () => { | ||
console.warn = jest.fn(); | ||
|
||
expect(getTemplatePath('foo-bar').endsWith('lib/templates/default.ejs')).toBeTruthy(); | ||
expect(console.warn).toHaveBeenCalledWith('The template "foo-bar" is not recognized by jsdoc-vuejs. Using default template as fallback.'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
const config = require('jsdoc/env'); | ||
const guessRenderer = require('./lib/core/guessRenderer'); | ||
const getTemplatePath = require('./lib/core/getTemplatePath'); | ||
|
||
config['jsdoc-vuejs'] = config['jsdoc-vuejs'] || {}; | ||
|
||
// Detect JSDoc template if not specified | ||
if (!Object.prototype.hasOwnProperty.call(config['jsdoc-vuejs'], 'renderer')) { | ||
config['jsdoc-vuejs'].renderer = guessRenderer(config.opts.template || 'default'); | ||
if (!Object.prototype.hasOwnProperty.call(config['jsdoc-vuejs'], 'template')) { | ||
config['jsdoc-vuejs'].template = getTemplatePath(config.opts.template || 'default'); | ||
} | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { resolve } = require('path'); | ||
|
||
module.exports = function getTemplatePath(template) { | ||
// eslint-disable-next-line no-param-reassign | ||
template = template || 'default'; | ||
|
||
const path = (() => { | ||
switch (true) { | ||
case template === 'default': | ||
return `${__dirname}/../templates/default.ejs`; | ||
case /ink-docstrap\/template/.test(template): | ||
return `${__dirname}/../templates/docstrap.ejs`; | ||
case /minami/.test(template): | ||
return `${__dirname}/../templates/minami.ejs`; | ||
case /tui-jsdoc-template/.test(template): | ||
return `${__dirname}/../templates/tui.ejs`; | ||
default: | ||
// eslint-disable-next-line no-console | ||
console.warn(`The template "${template}" is not recognized by jsdoc-vuejs. Using default template as fallback.`); | ||
return `${__dirname}/../templates/default.ejs`; | ||
} | ||
})(); | ||
|
||
return resolve(path); | ||
}; |
Oops, something went wrong.