site/js/docurium.js in docurium-0.4.2 vs site/js/docurium.js in docurium-0.5.0
- old
+ new
@@ -15,10 +15,16 @@
var name = group[0]
var link = groupLink(name, version)
return {name: name, link: link, num: group[1].length}
})
+ // Callbacks
+ var callbacks = _.map(_.keys(data['callbacks']), function(name) {
+ var link = functionLink('callback', name, version)
+ return {name: name, link: link}
+ })
+
// Types
var getName = function(type) {
var name = type[0];
var link = typeLink(name, version);
return {link: link, name: name};
@@ -48,12 +54,12 @@
examples = _.map(data['examples'], function(file) {
return {name: file[0], path: file[1]}
})
}
- this.set('data', {funs: funs, enums: enums, structs: structs, opaques: opaques,
- files: files, examples: examples})
+ this.set('data', {funs: funs, callbacks: callbacks, enums: enums, structs: structs,
+ opaques: opaques, files: files, examples: examples})
},
})
var FileListView = Backbone.View.extend({
el: $('#files-list'),
@@ -76,16 +82,28 @@
},
render: function() {
var data = this.model.get('data')
- var enumList = this.typeTemplate({title: 'Enums', elements: data.enums})
- var structList = this.typeTemplate({title: 'Structs', elements: data.structs})
- var opaquesList = this.typeTemplate({title: 'Opaque Structs', elements: data.opaques})
var menu = $(this.template({funs: data.funs, files: data.files, examples: data.examples}))
- $('#types-list', menu).append(enumList, structList, opaquesList)
+ if (data.enums.length) {
+ var enumList = this.typeTemplate({title: 'Enums', elements: data.enums})
+ $('#types-list', menu).append(enumList)
+ }
+ if (data.structs.length) {
+ var structList = this.typeTemplate({title: 'Structs', elements: data.structs})
+ $('#types-list', menu).append(structList)
+ }
+ if (data.opaques.length) {
+ var opaquesList = this.typeTemplate({title: 'Opaque Structs', elements: data.opaques})
+ $('#types-list', menu).append(opaquesList)
+ }
+ if (data.callbacks.length) {
+ var callbacksList = this.typeTemplate({title: 'Callbacks', elements: data.callbacks})
+ $('#types-list', menu).append(callbacksList)
+ }
this.$el.html(menu)
return this
},
})
@@ -221,11 +239,11 @@
var ldata = fdata
if (isCallback) {
var cdata = docurium.get('data')['callbacks']
ldata = cdata
} else {
- var functions = group[1]
+ var functions = _.filter(group[1], function(f){ return f != fname})
}
// Function Arguments
var args = _.map(ldata[fname]['args'], function(arg) {
return {link: this.hotLink(arg.type), name: arg.name, comment: arg.comment}
@@ -389,10 +407,11 @@
var gname = group[0]
var fdata = o.functions
var cdata = o.callbacks
var version = o.version
+ this.gname = gname.charAt(0).toUpperCase() + gname.substring(1).toLowerCase()
this.functions = _.map(group[1], function(name) {
var url = '#' + functionLink(gname, name, version)
var d = fdata[name]
return {name: name, url: url, returns: d['return']['type'], argline: d['argline'],
description: d['description'], comments: d['comments'], args: d['args']}
@@ -579,11 +598,11 @@
return _.find(groups, function(g) {
return g[0] == gname
})
},
- // look for structs and link them
+ // look for structs and link them
hotLink: function(text) {
types = this.get('data')['types']
var version = this.get('version')
for(var i=0; i<types.length; i++) {
@@ -604,10 +623,13 @@
return text
},
groupOf: function (func) {
- return this.get('data')['functions'][func]['group']
+ if(func in this.get('data')['functions']) {
+ return this.get('data')['functions'][func]['group']
+ }
+ return 'callback'
},
github_file: function(file, line, lineto) {
var data = this.get('data')
url = ['https://github.com', docurium.get('github'),