Skip to content

Commit 503acc3

Browse files
committed
no more errors on missing name, but a nice warning
1 parent 9b6456d commit 503acc3

6 files changed

+18
-12
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ lib/configured/test/tmp/
1515
lib/configured/test/api/
1616
lib/configured/test/docs/
1717
lib/generators/html/test/tmp/
18+
.DS_Store
19+
.DS_Store?

documentjs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"docs": {
44
"glob": {
55
"pattern": "{docs,tags,lib}/**/*.{js,md}",
6-
"ignore": "lib/{configured,generate,find}/test/**/*"
6+
"ignore": "lib/{configured,generate,find,generators/html}/test/**/*"
77
}
88
},
99
"examples/multi": {

lib/configured/generate_project.js

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ function document(project, parent, options ){
7373
module.exports = document;
7474

7575
/**
76+
* @function documentjs.configured.generateProject generateProject
77+
* @hide
7678
*
7779
* @param {Object} docConfig A docConfig loaded from `{project.path}/documentjs.json`.
7880
*

lib/process/add_doc_object_to_doc_map.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var _ = require("lodash");
2+
13
module.exports = function(docObject, docMap, filename, line){
24
if (docObject.name) {
35

@@ -21,14 +23,8 @@ module.exports = function(docObject, docMap, filename, line){
2123
if (line) {
2224
docObject.line = line;
2325
}
24-
} else {
25-
throw new Error({
26-
message: "Created a docObject without a name. "+(filename || "" + (line ? ":"+line : "")),
27-
docObject: docObject,
28-
toString: function(){
29-
return this.message;
30-
}
31-
});
26+
} else if(!_.isEmpty( _.omit(docObject,['body','description']) ) && docObject.type !== "hide"){
27+
console.log("WARNING!!\nNo name for:\n",docObject);
3228
}
3329
};
3430

lib/process/clean_doc_map.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module.exports = function(docMap, options){
66

77
if(!options.parent) {
88
var info = docMapInfo(docMap);
9-
109
if(_.size(info.nameHeightMap) === 1) {
1110
// everything is under one object, so use that
1211
options.parent = info.maxName;
@@ -19,6 +18,9 @@ module.exports = function(docMap, options){
1918
type: "page"
2019
};
2120
options.parent = info.maxParent;
21+
} else if(info.sortedNames.length > 1 && info.sortedNames[0].childCount > info.sortedNames[1].childCount * 5) {
22+
options.parent = info.maxName;
23+
console.log("Parent-less comments: "+_.map(info.sortedNames.slice(1),"name")+".");
2224
} else {
2325
// we need to balance an empty project, which should probably have everything
2426
// just added to it
@@ -35,7 +37,7 @@ module.exports = function(docMap, options){
3537
});
3638

3739
options.parent = maxParent;
38-
40+
console.log("Parent-less comments:"+_.keys(info.nameHeightMap).join(", ")+".");
3941
}
4042

4143
console.warn("Guessed parent '"+options.parent+"'. Set parent in your siteConfig.");

lib/process/doc_map_info.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Goes through the graph and figures out the highest parent
2-
2+
var _ = require("lodash");
33

44
var getTop = function(docMap, child){
55
var parent;
@@ -53,9 +53,13 @@ module.exports = function(docMap){
5353
}
5454

5555
}
56+
var sortedNameHeightMap= _.sortBy(_.map(nameHeightMap, function(val, name){
57+
return {name: name, childCount: val};
58+
}), "childCount").reverse();
5659
return {
5760
maxName: maxName,
5861
nameHeightMap: nameHeightMap,
62+
sortedNames: sortedNameHeightMap,
5963
maxParent: maxParent,
6064
parentHeightMap: parentHeightMap
6165
};

0 commit comments

Comments
 (0)