Add method contentLink as deprecated for plugin API

This commit is contained in:
Samy Pessé
2016-05-02 13:50:51 +02:00
parent 4c144b6ceb
commit b80dfd7b9a
2 changed files with 23 additions and 9 deletions
+20
View File
@@ -1,4 +1,5 @@
var is = require('is');
var objectPath = require('object-path');
var logged = {};
var disabled = {};
@@ -96,8 +97,27 @@ function disableDeprecation(key) {
disabled[key] = true;
}
/**
Deprecate a method in favor of another one
@param {Book} book
@param {String} key
@param {Object} instance
@param {String} oldName
@param {String} newName
*/
function deprecateRenamedMethod(book, key, instance, oldName, newName, msg) {
msg = msg || ('"' + oldName + '" is deprecated, use "' + newName + '()" instead');
var fn = objectPath.get(instance, newName);
instance[oldName] = deprecateMethod(book, key, function() {
return fn.apply(instance, arguments);
}. msg);
}
module.exports = {
method: deprecateMethod,
renamedMethod: deprecateRenamedMethod,
field: deprecateField,
enable: enableDeprecation,
disable: disableDeprecation
+3 -9
View File
@@ -47,15 +47,6 @@ function encodeGlobal(output) {
return book.isLanguageBook();
},
/**
Same as isLanguageBook
@deprecated
*/
isSubBook: deprecate.method(output, 'this.isSubBook', function() {
return book.isLanguageBook();
}, '"isSubBook" is deprecated, use "isLanguageBook()" instead'),
/**
Read a file from the book
@@ -141,6 +132,9 @@ function encodeGlobal(output) {
// Deprecated properties
deprecate.renamedMethod(output, 'this.isSubBook', result, 'isSubBook', 'isLanguageBook');
deprecate.renamedMethod(output, 'this.contentLink', result, 'contentLink', 'output.toURL');
deprecate.field(output, 'this.generator', result, 'generator',
output.getGenerator(), '"this.generator" property is deprecated, use "this.output.name" instead');