1
0
Fork 0
forked from 0x2620/oxjs

add geo module documentation and tests

This commit is contained in:
rolux 2011-05-09 10:54:52 +02:00
commit 43fa75c8db
8 changed files with 203 additions and 98 deletions

View file

@ -2903,7 +2903,6 @@ Ox.doc = (function() {
}
function parseNode(node) {
var item = parseItem(node.line), subitem;
Ox.print(node, node.line, 'item', item);
node.nodes && node.nodes.forEach(function(node) {
var key, line = node.line, subitem;
if (!/^#/.test(node.line)) {
@ -2946,10 +2945,8 @@ Ox.doc = (function() {
}
function parseTest(str) {
var lines = decodeLinebreaks(str).split('\n');
Ox.print('$$$', str)
return {
statement: lines[0].substr(2),
// result: JSON.parse(lines[1].trim())
result: lines[1].trim()
};
}
@ -3144,7 +3141,6 @@ Ox.test = function(file, callback) {
var tests = [];
items.forEach(function(item) {
item.examples && item.examples.forEach(function(example) {
Ox.print(example)
var actual = eval(example.statement);
if (example.result) {
tests.push({
@ -3859,12 +3855,16 @@ Ox.endsWith = function(str, sub) {
return str.substr(str.length - sub.length) == sub;
};
Ox.highlight = function(txt, str) {
// fixme: move to ox.ui
return str ? txt.replace(
/*@
Ox.highlight <f> Highlight matches in a string
> Ox.highlight('foobar', 'foo', 'match')
'<span class="match">foo</span>bar'
@*/
Ox.highlight = function(txt, str, classname) {
return txt.replace(
new RegExp('(' + str + ')', 'ig'),
'<span class="OxHighlight">$1</span>'
) : txt;
'<span class="' + classname + '">$1</span>'
);
};
/*@
@ -4028,7 +4028,7 @@ Ox.toCamelCase <f> Takes a string with '-', '/' or '_', returns a camelCase stri
@*/
Ox.toCamelCase = function(str) {
return str.replace(/[\-_\/][a-z]/g, function(str) {
return str.replace(/[\-\/_][a-z]/g, function(str) {
return str[1].toUpperCase();
});
};