Skip to content

Commit

Permalink
fix(plugin): remove onHandleHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Apr 22, 2017
1 parent df924f6 commit 3a887e9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 28 deletions.
4 changes: 0 additions & 4 deletions src/ESDoc.js
Expand Up @@ -370,10 +370,6 @@ export default class ESDoc {
const _filePath = path.resolve(config.destination, filePath);
content = Plugin.onHandleContent(content, _filePath);

// todo: remove deprecated code
const ext = path.extname(filePath).toLowerCase();
if (ext === '.html') content = Plugin.onHandleHTML(content, _filePath);

console.log(`output: ${_filePath}`);
fs.outputFileSync(_filePath, content, option);
};
Expand Down
11 changes: 2 additions & 9 deletions src/Plugin/Plugin.js
Expand Up @@ -144,18 +144,11 @@ class Plugin {
}

/**
* handle HTML.
* @param {string} html - original HTML.
* handle content.
* @param {string} content - original content.
* @param {string} fileName - the fileName of the HTML file.
* @returns {string} handled HTML.
* @deprecated please use onHandleContent
*/
onHandleHTML(html, fileName) {
const ev = new PluginEvent({html, fileName});
this._execHandler('onHandleHTML', ev);
return ev.data.html;
}

onHandleContent(content, fileName) {
const ev = new PluginEvent({content, fileName});
this._execHandler('onHandleContent', ev);
Expand Down
8 changes: 0 additions & 8 deletions test/fixture/package/plugin/MyPlugin1.js
Expand Up @@ -47,14 +47,6 @@ exports.onHandleContent = function(ev) {
ev.data.content = ev.data.content.replace('MyPlugin1', 'MyPlugin1(modified)');
};

exports.onHandleHTML = function(ev) {
callInfo.handlerNames.onHandleHTML = ['MyPlugin1'];
ev.data.html = ev.data.html.replace(
'</head>',
`<meta name="x-from-plugin" content="fileName:${ev.data.fileName}" />\n</head>`
);
};

exports.onComplete = function(ev) {
callInfo.handlerNames.onComplete = ['MyPlugin1'];
};
4 changes: 0 additions & 4 deletions test/fixture/package/plugin/MyPlugin2.js
Expand Up @@ -32,10 +32,6 @@ exports.onHandleContent = function(ev) {
callInfo.handlerNames.onHandleContent.push('MyPlugin2');
};

exports.onHandleHTML = function(ev) {
callInfo.handlerNames.onHandleHTML.push('MyPlugin2');
};

exports.onComplete = function(ev) {
callInfo.handlerNames.onComplete.push('MyPlugin2');
};
3 changes: 0 additions & 3 deletions test/src/ConfigTest/PluginsTest.js
Expand Up @@ -21,7 +21,6 @@ describe('test config.plugins: [...]', ()=>{
assert(plugin.callInfo.handlerNames.onHandleTag);
assert(plugin.callInfo.handlerNames.onPublish);
assert(plugin.callInfo.handlerNames.onHandleContent);
assert(plugin.callInfo.handlerNames.onHandleHTML);
assert(plugin.callInfo.handlerNames.onComplete);
assert.deepEqual(plugin.callInfo.option, {foo: 1});
assert.equal(plugin.callInfo.usedParser, true);
Expand All @@ -33,7 +32,6 @@ describe('test config.plugins: [...]', ()=>{

const html = fs.readFileSync('./test/fixture/dest/esdoc-plugins/index.html');
assert(html.includes('content was made by MyPlugin1(modified).onPublish'));
assert(html.includes('x-from-plugin'));
});

/* eslint-disable global-require */
Expand All @@ -49,7 +47,6 @@ describe('test config.plugins: [...]', ()=>{
assert.deepEqual(plugin.callInfo.handlerNames.onHandleTag, ['MyPlugin1', 'MyPlugin2']);
assert.deepEqual(plugin.callInfo.handlerNames.onPublish, ['MyPlugin1', 'MyPlugin2']);
assert.deepEqual(plugin.callInfo.handlerNames.onHandleContent, ['MyPlugin1', 'MyPlugin2']);
assert.deepEqual(plugin.callInfo.handlerNames.onHandleHTML, ['MyPlugin1', 'MyPlugin2']);
assert.deepEqual(plugin.callInfo.handlerNames.onComplete, ['MyPlugin1', 'MyPlugin2']);
});
});

0 comments on commit 3a887e9

Please sign in to comment.