doc(showdown.js): add source documentation for showdown's api

This commit is contained in:
Estevão Soares dos Santos 2015-01-19 16:28:14 +00:00
parent c528f4a427
commit 8ee87ead9f

View File

@ -7,7 +7,7 @@ var showdown = {},
parsers = {}, parsers = {},
globalOptions = { globalOptions = {
omitExtraWLInCodeBlocks: false, omitExtraWLInCodeBlocks: false,
prefixHeaderId: false prefixHeaderId: false
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -27,24 +27,42 @@ showdown.helper = {};
showdown.extensions = {}; showdown.extensions = {};
//Public methods //Public methods
/**
* Set a global option
*
* @param {string} key
* @param {string} value
* @returns {showdown}
*/
showdown.setOption = function (key, value) { showdown.setOption = function (key, value) {
'use strict'; 'use strict';
globalOptions[key] = value; globalOptions[key] = value;
return this; return this;
}; };
/**
* Get a global option
*
* @param {string} key
* @returns {*}
*/
showdown.getOption = function (key) { showdown.getOption = function (key) {
'use strict'; 'use strict';
return globalOptions[key]; return globalOptions[key];
}; };
/**
* Get the global options
* @returns {{omitExtraWLInCodeBlocks: boolean, prefixHeaderId: boolean}}
*/
showdown.getOptions = function () { showdown.getOptions = function () {
'use strict'; 'use strict';
return globalOptions; return globalOptions;
}; };
/** /**
* Static Method * Get or set a subParser
* *
* subParser(name) - Get a registered subParser * subParser(name) - Get a registered subParser
* subParser(name, func) - Register a subParser * subParser(name, func) - Register a subParser
@ -68,6 +86,7 @@ showdown.subParser = function (name, func) {
}; };
/** /**
* Showdown Converter class
* *
* @param {object} [converterOptions] * @param {object} [converterOptions]
* @returns {{makeHtml: Function}} * @returns {{makeHtml: Function}}
@ -98,7 +117,12 @@ showdown.Converter = function (converterOptions) {
} }
} }
var makeHtml = function (text) { /**
* Converts a markdown string into HTML
* @param {string} text
* @returns {*}
*/
function makeHtml(text) {
//check if text is not falsy //check if text is not falsy
if (!text) { if (!text) {
@ -149,7 +173,7 @@ showdown.Converter = function (converterOptions) {
//}); //});
return text; return text;
}; }
return { return {
makeHtml: makeHtml makeHtml: makeHtml