Functionality required for SVG Integration table generation.
--- a/publish/config.js Sun Apr 07 16:03:59 2013 +1000
+++ b/publish/config.js Tue Apr 09 09:36:03 2013 +1000
@@ -273,6 +273,48 @@
return this.pages[page].sectionHierarchy;
},
+
+ lookupElementBySpec: function(specid, elementName) {
+ var element = this.definitionsBySpec[specid].elements[elementName];
+ if (!element) {
+ for (var id in this.definitionMainSpecs) {
+ if (this.definitionMainSpecs[id] == specid) {
+ element = this.definitionsBySpec[id].elements[elementName];
+ if (element) {
+ break;
+ }
+ }
+ }
+ }
+ return element;
+ },
+
+ lookupElementAttributeBySpec: function(specid, elementName, attributeName) {
+ var element = this.definitionsBySpec[specid].elements[elementName];
+ if (!element || !element.attributes[attributeName]) {
+ for (var id in this.definitionMainSpecs) {
+ if (this.definitionMainSpecs[id] == specid) {
+ element = this.definitionsBySpec[id].elements[elementName];
+ if (element && element.attributes[attributeName]) {
+ break;
+ }
+ }
+ }
+ }
+ return element && element.attributes[attributeName];
+ },
+
+ lookupElementAttributeCategoryBySpec: function(specid, elementName, attributeCategoryName) {
+ var element = this.definitionsBySpec[specid].elements[elementName];
+ if (element) {
+ for (var i = 0; i < element.attributeCategories.length; i++) {
+ var catName = element.attributeCategories[i];
+ if (catName == attributeCategoryName) {
+ return this.definitionsBySpec[specid].attributeCategories[catName];
+ }
+ }
+ }
+ },
};
exports.load = function(filename) {
--- a/publish/definitions.js Sun Apr 07 16:03:59 2013 +1000
+++ b/publish/definitions.js Tue Apr 09 09:36:03 2013 +1000
@@ -324,6 +324,7 @@
name: c.getAttribute('name'),
href: utils.resolveURL(base, c.getAttribute('href')),
animatable: c.getAttribute('animatable') == 'yes',
+ specific: true,
specid: specid
}));
});
@@ -351,6 +352,7 @@
name: a.getAttribute('name'),
href: utils.resolveURL(base, a.getAttribute('href')),
animatable: a.getAttribute('animatable') == 'yes',
+ common: true,
specid: specid
});
if (a.hasAttribute('elements')) {
@@ -376,6 +378,7 @@
name: a.getAttribute('name'),
href: utils.resolveURL(base, a.getAttribute('href')),
animatable: a.getAttribute('animatable') == 'yes',
+ category: category,
specid: specid
}));
});
--- a/publish/processing.js Sun Apr 07 16:03:59 2013 +1000
+++ b/publish/processing.js Tue Apr 09 09:36:03 2013 +1000
@@ -805,7 +805,7 @@
return n.getAttribute("class") == 'proptable';
}
- utils.forEachNode(doc, function(n) {
+ utils.forEachNode(doc, function(n, speclinks) {
if (n.nodeType != n.ELEMENT_NODE ||
n.localName != 'a' ||
n.hasAttribute('href') ||
@@ -815,22 +815,24 @@
var text = n.textContent;
+ var definitions = speclinks ? conf.definitionsBySpec[speclinks] : conf.definitions;
+
if (/^'(\S+)\s+element'$/.test(text)) {
- utils.replace(n, conf.definitions.formatElementLink(RegExp.$1, n));
+ utils.replace(n, definitions.formatElementLink(RegExp.$1, n));
} else if (/^'(\S+)\s+attribute'$/.test(text)) {
- utils.replace(n, conf.definitions.formatAttributeLink(RegExp.$1, n));
+ utils.replace(n, definitions.formatAttributeLink(RegExp.$1, n));
} else if (/^'(\S+)\s+property'$/.test(text)) {
- utils.replace(n, conf.definitions.formatPropertyLink(RegExp.$1, n, shouldOmitQuotes(n)));
+ utils.replace(n, definitions.formatPropertyLink(RegExp.$1, n, shouldOmitQuotes(n)));
} else if (/^'(\S+)\s+presentationattribute'$/.test(text)) {
- utils.replace(n, conf.definitions.formatPresentationAttributeLink(RegExp.$1, n));
+ utils.replace(n, definitions.formatPresentationAttributeLink(RegExp.$1, n));
} else if (/^'([^\/]+)\/([^\/]+)'$/.test(text)) {
- utils.replace(n, conf.definitions.formatElementAttributeLink(RegExp.$1, RegExp.$2, n));
+ utils.replace(n, definitions.formatElementAttributeLink(RegExp.$1, RegExp.$2, n));
} else if (/^'(\S+)'$/.test(text)) {
- utils.replace(n, conf.definitions.formatNameLink(RegExp.$1, n, shouldOmitQuotes(n)));
+ utils.replace(n, definitions.formatNameLink(RegExp.$1, n, shouldOmitQuotes(n)));
} else if (/^([^:]+)::([^:]+)$/.test(text)) {
var interfaceName = RegExp.$1;
var memberName = RegExp.$2;
- if (/^(.*)#/.test(conf.definitions.interfaces[interfaceName].href)) {
+ if (/^(.*)#/.test(definitions.interfaces[interfaceName].href)) {
var beforeHash = RegExp.$1;
utils.replace(n, utils.parse('<a href="{{base}}#__svg__{{interface}}__{{member}}">{{prefix}}{{member}}</a>',
{ base: beforeHash,
@@ -841,10 +843,12 @@
utils.warn('unknown interface name "' + interfaceName + '"', n);
}
} else if (/^<(.*)>$/.test(text)) {
- utils.replace(n, conf.definitions.formatSymbolLink(RegExp.$1, n));
+ utils.replace(n, definitions.formatSymbolLink(RegExp.$1, n));
} else {
- utils.replace(n, conf.definitions.formatTermLink(text, n));
+ utils.replace(n, definitions.formatTermLink(text, n));
}
+ }, function(n) {
+ return n.nodeType == 1 && n.getAttributeNS(namespaces.edit, 'speclinks');
});
};
--- a/publish/utils.js Sun Apr 07 16:03:59 2013 +1000
+++ b/publish/utils.js Tue Apr 09 09:36:03 2013 +1000
@@ -260,15 +260,16 @@
return s1 < s2 ? -1 : 1;
};
-exports.forEachNode = function(n, fn) {
- var a = fn(n);
+exports.forEachNode = function(n, fn, stackfn, stackval) {
+ stackval = stackfn && stackfn(n) || stackval;
+ var a = fn(n, stackval);
if (Array.isArray(a)) {
- a.forEach(function(n) { exports.forEachNode(n, fn) });
+ a.forEach(function(n) { exports.forEachNode(n, fn, stackfn, stackval) });
} else {
n = n.firstChild;
while (n) {
var next = n.nextSibling;
- exports.forEachNode(n, fn);
+ exports.forEachNode(n, fn, stackfn, stackval);
n = next;
}
}
@@ -281,3 +282,16 @@
console.warn('warning: ' + message);
}
};
+
+exports.allEqual = function(a) {
+ if (a.length == 0) {
+ return true;
+ }
+ var x = a[0];
+ for (var i = 1; i < a.length; i++) {
+ if (a[i] != x) {
+ return false;
+ }
+ }
+ return true;
+};