update documentation example

This commit is contained in:
rolux 2012-05-30 19:23:47 +02:00
parent 3e6e938596
commit 874d316fb2

View file

@ -1,5 +1,24 @@
/*
An Ox.doc comment looks like this `//@ foo` or
```
/*@
foo
bar
baz
*\/
```
The syntax is simple: almost every line has the form `name <type> summary`. If
it doesn't, its meaning depends on its context.
*/
this.My = {}; this.My = {};
/*
If the first line of the comment doesn't match `name <type> summary`, it is a
section definition. Here, we mark a section named 'Primitives'.
*/
//@ Primitives
//@ My.REQUEST_TIMEOUT <number> Request timeout, in seconds //@ My.REQUEST_TIMEOUT <number> Request timeout, in seconds
My.REQUEST_TIMEOUT = 60; My.REQUEST_TIMEOUT = 60;
@ -9,6 +28,8 @@ My.MAGIC_CONSTANT <number> Magic constant needed for HTTP requests
*/ */
My.MAGIC_CONSTANT = navigator.userAgent.length % 2 == 0 ? 23 : 42; My.MAGIC_CONSTANT = navigator.userAgent.length % 2 == 0 ? 23 : 42;
//@ Objects
/*@ /*@
My.favorites <object> ... My.favorites <object> ...
array <a> My favorite array array <a> My favorite array
@ -23,7 +44,7 @@ My.favorites <object> ...
My.favorites = { My.favorites = {
array: [], array: [],
boolean: false, boolean: false,
date: new Date(0); date: new Date(0),
element: document.createElement('a'), element: document.createElement('a'),
number: 0, number: 0,
object: {}, object: {},
@ -31,6 +52,42 @@ My.favorites = {
string: '' string: ''
}; };
/*@
My.place <o> Default place object
name <o> Localized place names
short <o> Short place name
de <s> Short German name
en <s> Short English name
fr <s> Short French name
long <o> Long place name
de <s> Short German name
en <s> Short English name
fr <s> Short French name
points <[o]> Points of interest
lat <n> Latitude
lng <n> Longitude
@*/
My.place = {
name: {
short: {
de: 'Brüssel',
en: 'Brussels',
fr: 'Bruxelles'
},
long: {
de: 'Brüssel, Belgien',
en: 'Brussels, Belgium',
fr: 'Bruxelles, Belgique'
}
},
points: [
{lat: 0, lng: 0},
{lat: 45, lng: 90}
]
};
//@ Functions
/*@ /*@
(url[, method], callback) -> <u> undefined (url[, method], callback) -> <u> undefined
url <s> URL url <s> URL
@ -75,7 +132,7 @@ My.isOdd = function(number, callback) {
} else { } else {
return isOdd; return isOdd;
} }
} };
/* /*
Occasionally, you may write a function whose signature cannot be represented in Occasionally, you may write a function whose signature cannot be represented in
@ -87,7 +144,7 @@ be ambigious, since you cannot call it with `(stop, step)`.
My.range <f> Returns a python-style range My.range <f> Returns a python-style range
(b) -> <[n]> Integers from 0 (inclusive) to b (exclusive) (b) -> <[n]> Integers from 0 (inclusive) to b (exclusive)
(a, b) -> <[n]> Integers from a (inclusice) to b (exclusive) (a, b) -> <[n]> Integers from a (inclusice) to b (exclusive)
(a, b, x) -> <[n]> Numbers from a (inclusive) to b (exclusive), growing by x (a, b, c) -> <[n]> Numbers from a (inclusive) to b (exclusive), growing by c
*/ */
My.range = function() { My.range = function() {
var a = []; var a = [];
@ -126,7 +183,7 @@ My.localStorage = (function() {
ret[key.slice(ns.length + 1)] = JSON.parse(value); ret[key.slice(ns.length + 1)] = JSON.parse(value);
} }
}); });
} else if (arguments.length == 1 && typeof key == 'string') { } else if (arguments.length == 1 && !Ox.isObject(key)) {
value = localStorage[ns + '.' + key]; value = localStorage[ns + '.' + key];
ret = Ox.isUndefined(value) ? void 0 : JSON.parse(value); ret = Ox.isUndefined(value) ? void 0 : JSON.parse(value);
} else { } else {
@ -147,4 +204,14 @@ My.localStorage = (function() {
}; };
return storage; return storage;
}; };
}(); }());
//@
Ox.load('UI', function() {
var path = Ox.PATH + '../examples/documentation/js/';
Ox.print(path, '??')
Ox.DocPanel({
files: 'example.js',
path: path
}).appendTo(Ox.$body);
});