bit-docs-generate-readme
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -13,3 +13,3 @@ var Q = require("q"); | ||
module.exports = function(docMapPromise, siteConfig){ | ||
siteConfig = _.cloneDeep(siteConfig); | ||
var apisPromise; | ||
@@ -34,5 +34,6 @@ if( Array.isArray(siteConfig.readme.apis) ) { | ||
var template = Handlebars.compile(result[1].toString()), | ||
docMap = _.cloneDeep( result[0] ), | ||
docMap = result[0], | ||
apis = result[4]; | ||
siteConfig.readme.apis = apis; | ||
@@ -42,3 +43,3 @@ Handlebars.registerPartial("signature.mustache", result[2].toString()); | ||
var helpers = makeHelpers(docMap); | ||
var helpers = makeHelpers(docMap, siteConfig); | ||
_.forEach(helpers, function(helper, helperName){ | ||
@@ -48,5 +49,7 @@ Handlebars.registerHelper(helperName, helper); | ||
var entities = makeDocEntities(apis,0,docMap); | ||
var outlineEntities = makeDocEntities(apis,0,docMap); | ||
var entities = makeDocEntities(apis,0,docMap, true); | ||
var out = template({ | ||
outlineEntities: outlineEntities, | ||
entities: entities | ||
@@ -79,3 +82,3 @@ }); | ||
function makeDocEntities(apis, depth, docMap) { | ||
function makeDocEntities(apis, depth, docMap, ignoreGroups) { | ||
var entities = []; | ||
@@ -86,7 +89,18 @@ | ||
_.forEach(name, function(apis, name){ | ||
entities.push.apply(entities, makeDocEntities([name],depth, docMap) ); | ||
entities.push.apply(entities, makeDocEntities(apis, depth+1, docMap) ); | ||
var isGroup = !docMap[name] || (docMap[name] && docMap[name].type === "group"); | ||
if(isGroup && ignoreGroups) { | ||
entities.push.apply(entities, makeDocEntities(apis, depth, docMap, ignoreGroups) ); | ||
} else { | ||
entities.push.apply(entities, makeDocEntities([name],depth, docMap, ignoreGroups) ); | ||
entities.push.apply(entities, makeDocEntities(apis, depth+1, docMap, ignoreGroups) ); | ||
} | ||
}); | ||
} else { | ||
var docObject = docMap[name]; | ||
if(!docObject) { | ||
docObject = {type: "group", name: name}; | ||
} else { | ||
docObject = _.cloneDeep(docObject); | ||
} | ||
@@ -107,2 +121,6 @@ docObject.depth = depth; | ||
} else if(docObject.type === "group") { | ||
if(!ignoreGroups) { | ||
entities.push(docObject); | ||
} | ||
} else { | ||
@@ -109,0 +127,0 @@ console.log("unable to process",docObject); |
@@ -1,2 +0,2 @@ | ||
module.exports = function(docMap){ | ||
module.exports = function(docMap, siteConfig){ | ||
@@ -24,3 +24,3 @@ function toHash(str) { | ||
}; | ||
var linksRegExp = /[\[](.*?)\]/g, | ||
@@ -58,7 +58,16 @@ linkRegExp = /^(\S+)\s*(.*)/, | ||
"linkToSignature":function(){ | ||
var moduleCode = ""; | ||
if(this.type === "module") { | ||
moduleCode = "__"+this.name+"__ "; | ||
} else if(this.docObject && this.docObject.type === "module") { | ||
moduleCode = "__"+this.docObject.name+"__ "; | ||
} | ||
if(this.code) { | ||
return "<code>["+this.code+"](#"+toHash(this.code)+")"+"</code>"; | ||
return "<code>["+moduleCode+this.code+"](#"+toHash(this.code)+")"+"</code>"; | ||
} else if(this.types) { | ||
var title = this.title+" "+helpers.makeTypes(this.types); | ||
return "<code>["+title+"](#"+toHash(title)+")"+"</code>"; | ||
return "<code>["+moduleCode+title+"](#"+toHash(title)+")"+"</code>"; | ||
} else if(this.type === "group") { | ||
return "_"+this.name+"_"; | ||
} | ||
@@ -65,0 +74,0 @@ |
{ | ||
"name": "bit-docs-generate-readme", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Generates a readme from other docs", | ||
@@ -5,0 +5,0 @@ "main": "bit-docs-generate-readme.js", |
Sorry, the diff of this file is not supported yet
12250
296