I'm trying to build better node modules. Between writing the code, testing the library, and writing the documentation everything is a hassle to get even the smallest thing up.
I'm looking for a way to generate a testing file based on the @example's given within a jsdoc function declaration. This would means if you write a module, define it using jsdoc you get the markdown (using jsdoc2md) and the testing suite for free.
Thoughts? Does this exist?
Here's an example jsdoc function declaration, where all of the examples are copied and pasted from tests.
/**
* Standardize a function name.
* @module standard-fn-name
* @param {function} [fn] - The function you want to assign / get a name of.
* @param {string} [fnName] - The function name override.
* @param {object} [objFns] - The object that contains function property `fnName`.
* @example
* // returns ["ifHappy", [function]]
* var anon = {}
* anon.ifHappy = function(str){
* if(str == "happy") return true
* return false
* }
* standardFnName("ifHappy", anon)
* @example
* // throws Error
* var anon = {}
* anon.ifHappy = function(str){
* if(str == "happy") return true
* return false
* }
* standardFnName(anon.ifHappy)
* @example
* // returns ["ifHappy", [function]]
* var known = {}
* known.ifHappy = function ifHappy(str){
* if(str == "happy") return true
* return false
* }
* standardFnName(known.ifHappy)
* @example
* // returns ["ifHappy", [function]]
* function ifHappy(str){
* if(str == "happy") return true
* return false
* }
* standardFnName(ifHappy)
* @example
* // returns ["ifHappy", [function]]
* var ifHappyAnon = function(str){
* if(str == "happy") return true
* return false
* }
* standardFnName("ifHappy", ifHappyAnon)
*/
Aucun commentaire:
Enregistrer un commentaire