mirror of
https://github.com/eclipse/upm.git
synced 2025-07-03 02:11:15 +03:00
yuidoc: updated generators and templates to fix IE sidebar issue
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
@ -58,6 +58,7 @@ function GENERATE_MODULE(module) {
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ '@instance\n'
|
||||
|
@ -28,44 +28,66 @@ var _ = require('lodash');
|
||||
|
||||
// generate json for ternjs input
|
||||
function generateDocs(specjs) {
|
||||
var docs = GENERATE_MODULE(specjs.MODULE);
|
||||
GENERATE_TYPE = (function(enums) {
|
||||
return function(type) {
|
||||
return (_.contains(enums, type) ? ('Enum ' + type) : type);
|
||||
}
|
||||
})(_.keys(specjs.ENUMS_BY_GROUP));
|
||||
var docs = { '!name': specjs.MODULE + 'library' };
|
||||
_.extend(docs, GENERATE_MODULE(specjs.MODULE));
|
||||
_.each(specjs.ENUMS, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
_.each(specjs.METHODS, function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(specjs.CLASSES, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
|
||||
if (_.isEmpty(specjs.CLASSGROUPS)) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(specjs.CLASSES));
|
||||
} else {
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped)));
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
_.extend(docs, GENERATE_MODULE(groupName));
|
||||
_.extend(docs[groupName], GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName));
|
||||
});
|
||||
docs[specjs.MODULE][parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
});
|
||||
}
|
||||
return JSON.stringify(docs, null, 2);
|
||||
}
|
||||
|
||||
|
||||
// generate module spec
|
||||
function GENERATE_MODULE(module) {
|
||||
var docs = { '!name': module + 'library' };
|
||||
var docs = {};
|
||||
docs[module] = {};
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate the spec for the given list of classes
|
||||
function GENERATE_CLASSES(classes) {
|
||||
var docs = {};
|
||||
_.each(classes, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
if (_.has(docs, parentClass)) {
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
docs[parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
}
|
||||
});
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate method spec
|
||||
function GENERATE_METHOD(name, spec) {
|
||||
var doc = {};
|
||||
|
14
doxy/node/generators/yuidoc/generator.js
vendored
14
doxy/node/generators/yuidoc/generator.js
vendored
@ -46,7 +46,7 @@ function generateDocs(specjs) {
|
||||
docs += GENERATE_MODULE('common', '');
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
|
||||
});
|
||||
@ -76,7 +76,7 @@ function GENERATE_MODULE(name, description) {
|
||||
function GENERATE_CLASSES(classes, parent) {
|
||||
return _.reduce(classes, function(memo, classSpec, className) {
|
||||
return memo
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent)
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent)
|
||||
+ _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec, className);
|
||||
}, '')
|
||||
@ -91,15 +91,21 @@ function GENERATE_CLASSES(classes, parent) {
|
||||
|
||||
|
||||
// generate class spec
|
||||
function GENERATE_CLASS(name, description, parent) {
|
||||
function GENERATE_CLASS(name, description, namespace, parent) {
|
||||
return GENERATE_DOC(description + '\n'
|
||||
+ '@class ' + name + '\n'
|
||||
+ (parent ? ('@module ' + parent + '\n') : ''));
|
||||
+ (namespace ? ('@module ' + namespace + '\n') : '')
|
||||
/*
|
||||
TODO: leave out until figure out what swig does with inheritance
|
||||
+ (parent ? ('@extends ' + parent + '\n') : '')
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ (parent ? ('@for ' + parent + '\n') : '@for common\n')
|
||||
|
10
doxy/node/generators/yuidoc/helper.js
vendored
10
doxy/node/generators/yuidoc/helper.js
vendored
@ -77,17 +77,15 @@ function listByGroup(modules, classes, field, projectRoot) {
|
||||
var groups = Object.keys(modulesByGroup).sort();
|
||||
var html = '';
|
||||
var pfx = projectRoot + 'modules/';
|
||||
var first = true;
|
||||
for (i = 0; i < groups.length; i++) {
|
||||
var group = groups[i];
|
||||
html += (first ? '' : '</span>');
|
||||
html += '<div class="upmGroup"><div class="right-arrow"></div>' + group + '</div><span class="upmModules" style="display:none">';
|
||||
var moduleNames = modulesByGroup[group];
|
||||
for (j = 0; j < moduleNames.length; j++) {
|
||||
var moduleName = moduleNames[j];
|
||||
html += '<a href="' + pfx + moduleName + '.html">' + moduleName + '</a>';
|
||||
}
|
||||
first = false;
|
||||
html += '</span>';
|
||||
}
|
||||
return html;
|
||||
}
|
||||
@ -117,7 +115,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
font-size: 0; \
|
||||
margin-right: 5px; \
|
||||
vertical-align: 5px; \
|
||||
display: inline; \
|
||||
float: left \
|
||||
} \
|
||||
div.down-arrow { \
|
||||
width: 0; \
|
||||
@ -127,7 +125,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
border-top: 5px solid #356de4; \
|
||||
font-size: 0; \
|
||||
margin-right: 5px; \
|
||||
display: inline; \
|
||||
float: left \
|
||||
} \
|
||||
div.upmGroup { \
|
||||
font-weight: bold; \
|
||||
@ -137,7 +135,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
|
||||
var scripts = "YUI().use('node', 'event', function (Y) {"
|
||||
+ onClickHandler
|
||||
+ insertStyles
|
||||
// + insertStyles
|
||||
+ "});";
|
||||
|
||||
|
||||
|
@ -787,3 +787,28 @@ kbd .cmd { font-family: Monaco, Helvetica; }
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.right-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-bottom: 5px solid transparent;
|
||||
border-top: 5px solid transparent;
|
||||
border-left: 5px solid #356de4;
|
||||
font-size: 0;
|
||||
margin-right: 5px;
|
||||
float: left
|
||||
}
|
||||
|
||||
div.down-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 5px solid #356de4;
|
||||
font-size: 0;
|
||||
margin-right: 5px;
|
||||
float: left
|
||||
}
|
||||
|
||||
div.upmGroup {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
Reference in New Issue
Block a user