docurium 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/docurium.gemspec +1 -2
- data/lib/docurium/version.rb +1 -1
- data/site/css/style.css +5 -0
- data/site/index.html +252 -5
- data/site/js/docurium.js +554 -561
- data/site/shared/css/documentation.css +0 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ff36a5dfaa610fcbfda3a707dfb7c6e94cc6730
|
4
|
+
data.tar.gz: 9cea6cf8f7717f47466332302614fb4c16d399d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e168acd3e40157a48634b4482b4675cf91b7e88e51776b9d10801086be68fb2287cfa9ee10cf805fcdb6143fc112ac413599f66e18986f6ff6e6064e0043c199
|
7
|
+
data.tar.gz: 0c979249a408c30c10f11bf78f6a18bedbc02ee5d3164ea9aec056f576faf6d37eddfde9e16c82c6e93adf9a9f81cd19eab4c386f09d4485f5c208cfee7895b2
|
data/README.md
CHANGED
@@ -29,7 +29,10 @@ Run the `cm` binary and pass it your Docurium config file.
|
|
29
29
|
git_index_get
|
30
30
|
git_repository_path
|
31
31
|
git_tree_entry_byindex
|
32
|
-
*
|
32
|
+
* writing to branch gh-pages
|
33
|
+
wrote tree 87f0f3cb1622b9dc3d6d5d39106e863608b3b504
|
34
|
+
wrote commit 5cee46f4d491e9611abab218604db893b70202f3
|
35
|
+
updated gh-pages
|
33
36
|
|
34
37
|
Docurium will tell you if you have unmatched @params entries in header docs and if you've changed signatures in functions in HEAD, just to help you know what's happening and if you've written your docs properly.
|
35
38
|
|
@@ -48,7 +51,7 @@ The Docurium config file looks like this:
|
|
48
51
|
}
|
49
52
|
}
|
50
53
|
|
51
|
-
|
54
|
+
Docurium will write your docs directly into the specified Git branch.
|
52
55
|
|
53
56
|
# Installing
|
54
57
|
|
data/docurium.gemspec
CHANGED
@@ -11,8 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "https://github.com/libgit2/docurium"
|
12
12
|
s.summary = "A simpler, prettier Doxygen replacement."
|
13
13
|
s.description = s.summary
|
14
|
-
|
15
|
-
s.rubyforge_project = 'docurium'
|
14
|
+
s.license = 'MIT'
|
16
15
|
|
17
16
|
s.add_dependency "version_sorter", "~>1.1.0"
|
18
17
|
s.add_dependency "mustache", ">= 0.99.4"
|
data/lib/docurium/version.rb
CHANGED
data/site/css/style.css
CHANGED
data/site/index.html
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
<html
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
5
5
|
<title>API Documentation</title>
|
@@ -12,9 +12,256 @@
|
|
12
12
|
<script src="js/underscore.js" type="text/javascript"></script>
|
13
13
|
<script src="js/backbone.js" type="text/javascript"></script>
|
14
14
|
<script src="js/docurium.js" type="text/javascript"></script>
|
15
|
+
|
16
|
+
<!-- Changelog -->
|
17
|
+
<script type="text/template" id="changelog-item-template">
|
18
|
+
<p>
|
19
|
+
<ul>
|
20
|
+
<% _.each(dels, function(elem) { %>
|
21
|
+
<li class="deletes"><%= elem %></li>
|
22
|
+
<% }) %>
|
23
|
+
</ul>
|
24
|
+
</p>
|
25
|
+
<p>
|
26
|
+
<ul>
|
27
|
+
<% _.each(adds, function(elem) { %>
|
28
|
+
<li class="adds"><a href="#<%= elem.link %>"><%= elem.text %></a></li>
|
29
|
+
<% }) %>
|
30
|
+
</ul>
|
31
|
+
</p>
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<script type="text/template" id="changelog-template">
|
35
|
+
<h1>Function Changelog</h1>
|
36
|
+
<% _.each(versions, function(version) { %>
|
37
|
+
<h3><%= version.title %></h3>
|
38
|
+
<div class="changelog">
|
39
|
+
<%= version.listing %>
|
40
|
+
</div>
|
41
|
+
<% }) %>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
<!-- Version picker -->
|
45
|
+
<script type="text/template" id="version-picker-template">
|
46
|
+
<% _.each(versions, function(version) { %>
|
47
|
+
<li><a href="#<%= version %>"><%= version %></a></li>
|
48
|
+
<% }) %>
|
49
|
+
<li><a href="#p/changelog">Changelog</a></li>
|
50
|
+
</script>
|
51
|
+
|
15
52
|
</head>
|
16
53
|
|
17
54
|
<body class="documentation">
|
55
|
+
|
56
|
+
<!-- Sidebar where the groups and types appear -->
|
57
|
+
<script type="text/template" id="type-list-template">
|
58
|
+
<li>
|
59
|
+
<li><span class="divide"><%= title %></span></li>
|
60
|
+
<% _.each(elements, function(e) { %>
|
61
|
+
<li>
|
62
|
+
<a href="#<%= e.link %>" ref="<%= e.ref %>" class="type", id="typeItem<%= e.name %>">
|
63
|
+
<%= e.name %>
|
64
|
+
</a>
|
65
|
+
</li>
|
66
|
+
<% }) %>
|
67
|
+
</li>
|
68
|
+
</script>
|
69
|
+
<script type="text/template" id="file-list-template">
|
70
|
+
<li>
|
71
|
+
<h3><a href="#">Functions</a></h3>
|
72
|
+
<ul>
|
73
|
+
<% _.each(funs, function(fun, i) { %>
|
74
|
+
<li>
|
75
|
+
<a href="#<%= fun.link %>" ref="<%= i %>" class="group" id="groupItem<%= fun.name %>">
|
76
|
+
<%= fun.name %> <small>(<%= fun.num %>)</small>
|
77
|
+
</a>
|
78
|
+
</li>
|
79
|
+
<% }) %>
|
80
|
+
</ul>
|
81
|
+
</li>
|
82
|
+
<li>
|
83
|
+
<h3><a href="#">Types</a></h3>
|
84
|
+
<ul class="hidden" id="types-list" />
|
85
|
+
</li>
|
86
|
+
<li>
|
87
|
+
<h3><a href="#">Files</a></h3>
|
88
|
+
<ul class="hidden">
|
89
|
+
<% _.each(files, function(file) { %>
|
90
|
+
<li>
|
91
|
+
<a target="github" href="<%= file.url %>"><%= file.name %></a>
|
92
|
+
</li>
|
93
|
+
<% }) %>
|
94
|
+
</ul>
|
95
|
+
</li>
|
96
|
+
<li>
|
97
|
+
<h3><a href="#">Examples</a></h3>
|
98
|
+
<ul>
|
99
|
+
<% _.each(examples, function(example) { %>
|
100
|
+
<li>
|
101
|
+
<a href="<%= example.path %>"><%= example.name %></a>
|
102
|
+
</li>
|
103
|
+
<% }) %>
|
104
|
+
</ul>
|
105
|
+
</li>
|
106
|
+
</script>
|
107
|
+
|
108
|
+
<!-- Listing of the details of a single function -->
|
109
|
+
<script type="text/template" id="function-args-template">
|
110
|
+
<table class="funcTable">
|
111
|
+
<% _.each(args, function(arg) { %>
|
112
|
+
<tr>
|
113
|
+
<td valign="top" nowrap="true"><%= arg.link %></td>
|
114
|
+
<td valign="top" class="var"><%= arg.name %></td>
|
115
|
+
<td class="comment"><%= arg.comment %></td>
|
116
|
+
</tr>
|
117
|
+
<% }) %>
|
118
|
+
</table>
|
119
|
+
</script>
|
120
|
+
<script type="text/template" id="function-template">
|
121
|
+
<h1 class="funcTitle"><%= name %></h1>
|
122
|
+
<h3 class="funcDesc"><%= data.description %></h3>
|
123
|
+
<!-- The args table -->
|
124
|
+
<%= argsTemplate({args: args}) %>
|
125
|
+
<div class="returns">
|
126
|
+
<h3>returns</h3>
|
127
|
+
<table class="funcTable">
|
128
|
+
<tr>
|
129
|
+
<td valign="top"><%= returns.link %></td>
|
130
|
+
<td class="comment"><%= returns.comment %></td>
|
131
|
+
</tr>
|
132
|
+
</table>
|
133
|
+
</div>
|
134
|
+
<div><%= data.comments %></div>
|
135
|
+
<!-- function signature -->
|
136
|
+
<div class="example">
|
137
|
+
<h3>signature</h3>
|
138
|
+
<code class="params"><%= sig %></code>
|
139
|
+
</div>
|
140
|
+
<!-- function history -->
|
141
|
+
<div class="signatures">
|
142
|
+
<h3>versions</h3>
|
143
|
+
<ul>
|
144
|
+
<% _.each(sigs, function(sig) { %>
|
145
|
+
<li><a href="<%= sig.url %>" class="<%= sig.klass %>"><%= sig.name %></a></li>
|
146
|
+
<% }) %>
|
147
|
+
</ul>
|
148
|
+
</div>
|
149
|
+
<div class="fileLink">Defined in: <a href="<%= fileLink %>"> <%= data.file %></a></div>
|
150
|
+
<% if (data.examples) { %>
|
151
|
+
<div class="funcEx">Used in examples:
|
152
|
+
<ul>
|
153
|
+
<% _.each(data.examples, function(uses, filename) { %>
|
154
|
+
<li>
|
155
|
+
<strong><%= filename %></strong>
|
156
|
+
<% _.each(uses, function(use, i) { %>
|
157
|
+
<a href="<%= use %>">[<%= i + 1 %>]</a>
|
158
|
+
<% }) %> <!-- loop over the uses -->
|
159
|
+
</li>
|
160
|
+
<% }) %> <!-- loop over the files -->
|
161
|
+
</ul>
|
162
|
+
</div>
|
163
|
+
<% } %> <!-- if we have examples -->
|
164
|
+
<div class="also">
|
165
|
+
Also in <a href="<%= alsoGroup %>"><%= groupName %></a> group: <br/>
|
166
|
+
<% _.each(_.initial(alsoLinks), function(link) { %>
|
167
|
+
<a href="<%= link.url %>"><%= link.name %></a>,
|
168
|
+
<% }) %>
|
169
|
+
<% var link = _.last(alsoLinks) %>
|
170
|
+
<a href="<%= link.url %>"><%= link.name %></a>
|
171
|
+
</div>
|
172
|
+
</script>
|
173
|
+
|
174
|
+
<!-- main page, list of groups and their functions -->
|
175
|
+
<script type="text/template" id="index-template">
|
176
|
+
<h1>Public API Functions</h1>
|
177
|
+
<% _.each(groups, function(group) { %>
|
178
|
+
<h2 class="funcGroup"><%= group.name %></h2>
|
179
|
+
<p class="functionList">
|
180
|
+
<% _.each(_.initial(group.funs), function(fun) { %>
|
181
|
+
<a href="<%= fun.url %>" class="<%= fun.klass %>"><%= fun.name %></a>
|
182
|
+
<% }) %> <!-- loop through all but the last function -->
|
183
|
+
<% var fun = _.last(group.funs) %>
|
184
|
+
<a href="<%= fun.url %>" class="<%= fun.klass %>"><%= fun.name %></a>
|
185
|
+
</p>
|
186
|
+
<% }) %> <!-- loop through the groups -->
|
187
|
+
</script>
|
188
|
+
|
189
|
+
<!-- listing for a particular type -->
|
190
|
+
<script type="text/template" id="type-template">
|
191
|
+
<h1 class="funcTitle"><%= tname %><small><%= data.type %></small></h1>
|
192
|
+
<p><%= data.value %></p>
|
193
|
+
<% if (data.comments) { %>
|
194
|
+
<div><%= data.comments %></div>
|
195
|
+
<% } %>
|
196
|
+
<% if (data.block) { %>
|
197
|
+
<pre><%= data.block %></pre>
|
198
|
+
<% } %>
|
199
|
+
<% if (returns.length > 0) { %>
|
200
|
+
<h3>Returns</h3>
|
201
|
+
<% _.each(_.initial(returns), function(fun) { %>
|
202
|
+
<a href="<%= fun.url %>"><%= fun.name %></a>
|
203
|
+
<% }) %> <!-- loop over each 'return' -->
|
204
|
+
<% var fun = _.last(returns) %>
|
205
|
+
<a href="<%= fun.url %>"><%= fun.name %></a>
|
206
|
+
<% } %> <!-- if we have 'returns' -->
|
207
|
+
|
208
|
+
<% if (needs.length > 0) { %>
|
209
|
+
<h3>Argument In</h3>
|
210
|
+
<% _.each(_.initial(needs), function(fun) { %>
|
211
|
+
<a href="<%= fun.url %>"><%= fun.name %></a>
|
212
|
+
<% }) %> <!-- loop over each 'need' -->
|
213
|
+
<% var fun = _.last(needs) %>
|
214
|
+
<a href="<%= fun.url %>"><%= fun.name %></a>
|
215
|
+
<% } %> <!-- if we have 'needs' -->
|
216
|
+
|
217
|
+
<div class="fileLink">
|
218
|
+
Defined in:
|
219
|
+
<a href="<%= fileLink.url %>"><%= fileLink.name %></a>
|
220
|
+
</div>
|
221
|
+
</script>
|
222
|
+
|
223
|
+
<script type="text/template" id="group-template">
|
224
|
+
<h1><%= gname %> functions</h1>
|
225
|
+
<!-- table with all the functions -->
|
226
|
+
<table class="methods">
|
227
|
+
<% _.each(functions, function(fun) { %>
|
228
|
+
<tr>
|
229
|
+
<td valign="top" nowrap="true">
|
230
|
+
<%= fun.returns %>
|
231
|
+
</td>
|
232
|
+
<td valign="top" class="methodName">
|
233
|
+
<a href="<%= fun.url %>"><%= fun.name %></a>
|
234
|
+
</td>
|
235
|
+
<td>
|
236
|
+
<% _.each(fun.args, function(arg) { %>
|
237
|
+
<%= arg.type %> <%= arg.name %><br/>
|
238
|
+
<% }) %> <!-- loop over the args of a function -->
|
239
|
+
</td>
|
240
|
+
</tr>
|
241
|
+
<% }) %> <!-- loop over the functions -->
|
242
|
+
</table>
|
243
|
+
<!-- list of the functions with the descriptions -->
|
244
|
+
<% _.each(functions, function(fun) { %>
|
245
|
+
<h2><a href="<%= fun.url %>"><%= fun.name %></a><small>(<%= fun.argline %>)</small></h2>
|
246
|
+
<div class="description">
|
247
|
+
<%= fun.description %>
|
248
|
+
<%= fun.comments %>
|
249
|
+
</div>
|
250
|
+
<% }) %> <!-- loop over the functions -->
|
251
|
+
</script>
|
252
|
+
|
253
|
+
<script type="text/template" id="search-template">
|
254
|
+
<h1>Search Results</h1>
|
255
|
+
<table>
|
256
|
+
<% _.each(results, function(result) { %>
|
257
|
+
<tr>
|
258
|
+
<td><a href="<%= result.url %>"><%= result.name %></a></td>
|
259
|
+
<td><%= result.match %></td>
|
260
|
+
</tr>
|
261
|
+
<% }) %>
|
262
|
+
</table>
|
263
|
+
</script>
|
264
|
+
|
18
265
|
<div id="not-footer">
|
19
266
|
<div id="header-wrapper">
|
20
267
|
<div id="header">
|
@@ -29,14 +276,14 @@
|
|
29
276
|
|
30
277
|
<div id="wrapper">
|
31
278
|
|
32
|
-
<div class="content"></div>
|
279
|
+
<div id="content" class="content"></div>
|
33
280
|
|
34
281
|
<div id="js-help-sidebar" class="sidebar-shell">
|
35
282
|
<div class="sidebar-module">
|
36
283
|
<ul class="subgroup" id="versions">
|
37
284
|
<li>
|
38
285
|
<h3 id="version-picker">Version: <span id="version"></span></h3>
|
39
|
-
<ul id="version-list"></ul>
|
286
|
+
<ul id="version-list" class="hidden"></ul>
|
40
287
|
</li>
|
41
288
|
</ul>
|
42
289
|
</div> <!-- /sidebar-module -->
|
@@ -53,7 +300,7 @@
|
|
53
300
|
<div id="footer-wrapper">
|
54
301
|
<div id="footer">
|
55
302
|
<div class="left-col">
|
56
|
-
Powered by <a href="https://github.com/
|
303
|
+
Powered by <a href="https://github.com/libgit2/docurium">Docurium</a><br/>
|
57
304
|
Sponsored by GitHub<br/>
|
58
305
|
<br/>
|
59
306
|
</div>
|
data/site/js/docurium.js
CHANGED
@@ -1,618 +1,574 @@
|
|
1
1
|
$(function() {
|
2
|
-
|
3
|
-
var Docurium = Backbone.Model.extend({
|
4
|
-
|
5
|
-
defaults: {'version': 'unknown'},
|
6
|
-
|
2
|
+
var FileListModel = Backbone.Model.extend({
|
7
3
|
initialize: function() {
|
8
|
-
this.
|
4
|
+
var docurium = this.get('docurium')
|
5
|
+
this.listenTo(docurium, 'change:data', this.extract)
|
9
6
|
},
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
$('#site-title').text(data.name + ' API')
|
16
|
-
document.title = data.name + ' API'
|
17
|
-
}
|
18
|
-
docurium.setVersionPicker()
|
19
|
-
docurium.setVersion()
|
20
|
-
})
|
21
|
-
},
|
8
|
+
extract: function() {
|
9
|
+
var docurium = this.get('docurium')
|
10
|
+
var data = docurium.get('data')
|
11
|
+
var version = docurium.get('version')
|
22
12
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
vlink = $('<a>').attr('href', '#' + version).append(version).click( function() {
|
29
|
-
$('#version-list').hide(100)
|
30
|
-
})
|
31
|
-
$('#version-list').append($('<li>').append(vlink))
|
32
|
-
}
|
33
|
-
vlink = $('<a>').attr('href', '#' + 'p/changelog').append("Changelog").click ( function () {
|
34
|
-
$('#version-list').hide(100)
|
13
|
+
// Function groups
|
14
|
+
var funs = _.map(data['groups'], function(group, i) {
|
15
|
+
var name = group[0]
|
16
|
+
var link = groupLink(name, version)
|
17
|
+
return {name: name, link: link, num: group[1].length}
|
35
18
|
})
|
36
|
-
$('#version-list').append($('<li>').append(vlink))
|
37
|
-
},
|
38
19
|
|
39
|
-
|
40
|
-
|
41
|
-
|
20
|
+
// Types
|
21
|
+
var getName = function(type) {
|
22
|
+
var name = type[0];
|
23
|
+
var link = typeLink(name, version);
|
24
|
+
return {link: link, name: name};
|
42
25
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
|
27
|
+
var enums = _.filter(data['types'], function(type) {
|
28
|
+
return type[1]['block'] && type[1]['type'] == 'enum';
|
29
|
+
}).map(getName)
|
30
|
+
|
31
|
+
var structs = _.filter(data['types'], function(type) {
|
32
|
+
return type[1]['block'] && type[1]['type'] != 'enum'
|
33
|
+
}).map(getName)
|
34
|
+
|
35
|
+
var opaques = _.filter(data['types'], function(type) {
|
36
|
+
return !type[1]['block']
|
37
|
+
}).map(getName)
|
38
|
+
|
39
|
+
// File Listing
|
40
|
+
var files = _.map(data['files'], function(file) {
|
41
|
+
var url = this.github_file(file['file'])
|
42
|
+
return {url: url, name: file['file']}
|
43
|
+
}, docurium)
|
44
|
+
|
45
|
+
// Examples List
|
46
|
+
var examples = []
|
47
|
+
if(data['examples'] && (data['examples'].length > 0)) {
|
48
|
+
examples = _.map(data['examples'], function(file) {
|
49
|
+
return {name: file[0], path: file[1]}
|
50
|
+
})
|
47
51
|
}
|
52
|
+
|
53
|
+
this.set('data', {funs: funs, enums: enums, structs: structs, opaques: opaques,
|
54
|
+
files: files, examples: examples})
|
48
55
|
},
|
56
|
+
})
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}
|
60
|
-
})
|
58
|
+
var FileListView = Backbone.View.extend({
|
59
|
+
el: $('#files-list'),
|
60
|
+
|
61
|
+
template: _.template($('#file-list-template').html()),
|
62
|
+
|
63
|
+
typeTemplate: _.template($('#type-list-template').html()),
|
64
|
+
|
65
|
+
events: {
|
66
|
+
'click h3': 'toggleList',
|
61
67
|
},
|
62
68
|
|
63
|
-
|
64
|
-
$(
|
69
|
+
toggleList: function(e) {
|
70
|
+
$(e.currentTarget).next().toggle(100)
|
65
71
|
return false
|
66
72
|
},
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
ws.navigate(version, {replace: replace})
|
71
|
-
|
72
|
-
data = docurium.get('data')
|
73
|
-
content = $('.content')
|
74
|
-
content.empty()
|
75
|
-
|
76
|
-
content.append($('<h1>').append("Public API Functions"))
|
77
|
-
|
78
|
-
sigHist = docurium.get('signatures')
|
79
|
-
|
80
|
-
// Function Groups
|
81
|
-
for (var i in data['groups']) {
|
82
|
-
group = data['groups'][i]
|
83
|
-
content.append($('<h2>').addClass('funcGroup').append(group[0]))
|
84
|
-
list = $('<p>').addClass('functionList')
|
85
|
-
for(var j in group[1]) {
|
86
|
-
fun = group[1][j]
|
87
|
-
link = $('<a>').attr('href', '#' + groupLink(group[0], fun)).append(fun)
|
88
|
-
if(sigHist[fun].changes[version]) {
|
89
|
-
link.addClass('changed')
|
90
|
-
}
|
91
|
-
if(version == _.first(sigHist[fun].exists)) {
|
92
|
-
link.addClass('introd')
|
93
|
-
}
|
94
|
-
list.append(link)
|
95
|
-
if(j < group[1].length - 1) {
|
96
|
-
list.append(', ')
|
97
|
-
}
|
98
|
-
}
|
99
|
-
content.append(list)
|
100
|
-
}
|
74
|
+
initialize: function() {
|
75
|
+
this.listenTo(this.model, 'change:data', this.render)
|
101
76
|
},
|
102
77
|
|
103
|
-
|
104
|
-
var
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}
|
78
|
+
render: function() {
|
79
|
+
var data = this.model.get('data')
|
80
|
+
|
81
|
+
var enumList = this.typeTemplate({title: 'Enums', elements: data.enums})
|
82
|
+
var structList = this.typeTemplate({title: 'Structs', elements: data.structs})
|
83
|
+
var opaquesList = this.typeTemplate({title: 'Opaque Structs', elements: data.opaques})
|
84
|
+
var menu = $(this.template({funs: data.funs, files: data.files, examples: data.examples}))
|
85
|
+
|
86
|
+
$('#types-list', menu).append(enumList, structList, opaquesList)
|
87
|
+
|
88
|
+
this.$el.html(menu)
|
89
|
+
return this
|
110
90
|
},
|
91
|
+
})
|
111
92
|
|
112
|
-
|
113
|
-
|
93
|
+
var VersionView = Backbone.View.extend({
|
94
|
+
el: $('#version'),
|
114
95
|
|
115
|
-
|
116
|
-
|
117
|
-
|
96
|
+
initialize: function() {
|
97
|
+
this.listenTo(this.model, 'change:version', this.render)
|
98
|
+
this.listenTo(this.model, 'change:name', this.renderName)
|
99
|
+
this.title = $('#site-title')
|
100
|
+
},
|
118
101
|
|
119
|
-
|
120
|
-
|
121
|
-
|
102
|
+
render: function() {
|
103
|
+
var version = this.model.get('version')
|
104
|
+
this.$el.text(version)
|
105
|
+
this.title.attr('href', '#' + version)
|
106
|
+
return this
|
107
|
+
},
|
122
108
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
109
|
+
renderName: function() {
|
110
|
+
var name = this.model.get('name')
|
111
|
+
var title = name + ' API'
|
112
|
+
this.title.text(title)
|
113
|
+
document.title = title
|
114
|
+
return this
|
115
|
+
},
|
116
|
+
})
|
128
117
|
|
129
|
-
|
130
|
-
|
131
|
-
args = fdata[fname]['args']
|
132
|
-
for(var i=0; i<args.length; i++) {
|
133
|
-
arg = args[i]
|
134
|
-
row = $('<tr>')
|
135
|
-
row.append($('<td>').attr('valign', 'top').attr('nowrap', true).append(this.hotLink(arg.type)))
|
136
|
-
row.append($('<td>').attr('valign', 'top').addClass('var').append(arg.name))
|
137
|
-
row.append($('<td>').addClass('comment').append(arg.comment))
|
138
|
-
argtable.append(row)
|
139
|
-
}
|
140
|
-
content.append(argtable)
|
141
|
-
|
142
|
-
// Show Function Return Value
|
143
|
-
retdiv = $('<div>').addClass('returns')
|
144
|
-
retdiv.append($('<h3>').append("returns"))
|
145
|
-
rettable = $('<table>').addClass('funcTable')
|
146
|
-
retrow = $('<tr>')
|
147
|
-
rettable.append(retrow)
|
148
|
-
retdiv.append(rettable)
|
149
|
-
|
150
|
-
ret = fdata[fname]['return']
|
151
|
-
retrow.append($('<td>').attr('valign', 'top').append(this.hotLink(ret.type)))
|
152
|
-
if(ret.comment) {
|
153
|
-
retrow.append($('<td>').addClass('comment').append(ret.comment))
|
154
|
-
}
|
155
|
-
content.append(retdiv)
|
156
|
-
|
157
|
-
// Show Non-Parsed Function Comments
|
158
|
-
if (fdata[fname]['comments'])
|
159
|
-
content.append($('<div>').append(fdata[fname]['comments']))
|
160
|
-
|
161
|
-
// Show Function Signature
|
162
|
-
ex = $('<code>').addClass('params')
|
163
|
-
ex.append(this.hotLink(fdata[fname]['return']['type'] + ' ' + fname + '(' + fdata[fname]['argline'] + ');'))
|
164
|
-
example = $('<div>').addClass('example')
|
165
|
-
example.append($('<h3>').append("signature"))
|
166
|
-
example.append(ex)
|
167
|
-
content.append(example)
|
168
|
-
|
169
|
-
// Show Function History
|
170
|
-
sigs = $('<div>').addClass('signatures')
|
171
|
-
sigs.append($('<h3>').append("versions"))
|
172
|
-
sigHist = docurium.get('signatures')[fname]
|
173
|
-
var list = $('<ul>')
|
174
|
-
for(var i in sigHist.exists) {
|
175
|
-
ver = sigHist.exists[i]
|
176
|
-
link = $('<a>').attr('href', '#' + groupLink(gname, fname, ver)).append(ver)
|
177
|
-
if(sigHist.changes[ver]) {
|
178
|
-
link.addClass('changed')
|
179
|
-
}
|
180
|
-
if(ver == docurium.get('version')) {
|
181
|
-
link.addClass('current')
|
182
|
-
}
|
183
|
-
list.append($('<li>').append(link))
|
184
|
-
}
|
185
|
-
sigs.append(list)
|
186
|
-
content.append(sigs)
|
187
|
-
|
188
|
-
// Link to Function Def on GitHub
|
189
|
-
link = this.github_file(fdata[fname].file, fdata[fname].line, fdata[fname].lineto)
|
190
|
-
flink = $('<a>').attr('target', 'github').attr('href', link).append(fdata[fname].file)
|
191
|
-
content.append($('<div>').addClass('fileLink').append("Defined in: ").append(flink))
|
192
|
-
|
193
|
-
// Show where this is used in the examples
|
194
|
-
if(ex = fdata[fname].examples) {
|
195
|
-
also = $('<div>').addClass('funcEx')
|
196
|
-
also.append("Used in examples: ")
|
197
|
-
for( fname in ex ) {
|
198
|
-
lines = ex[fname]
|
199
|
-
line = $('<li>')
|
200
|
-
line.append($('<strong>').append(fname))
|
201
|
-
for( var i in lines ) {
|
202
|
-
flink = $('<a>').attr('href', lines[i]).append(' [' + (parseInt(i) + 1) + '] ')
|
203
|
-
line.append(flink)
|
204
|
-
}
|
205
|
-
also.append(line)
|
206
|
-
}
|
207
|
-
content.append(also)
|
208
|
-
}
|
118
|
+
var VersionPickerView = Backbone.View.extend({
|
119
|
+
el: $('#versions'),
|
209
120
|
|
210
|
-
|
211
|
-
also = $('<div>').addClass('also')
|
212
|
-
flink = $('<a href="#' + docurium.get('version') + '/group/' + group[0] + '">' + group[0] + '</a>')
|
213
|
-
flink.click( docurium.showGroup )
|
214
|
-
also.append("Also in ")
|
215
|
-
also.append(flink)
|
216
|
-
also.append(" group: <br/>")
|
217
|
-
|
218
|
-
for(i=0; i<functions.length; i++) {
|
219
|
-
f = functions[i]
|
220
|
-
d = fdata[f]
|
221
|
-
link = $('<a>').attr('href', '#' + groupLink(gname, f)).append(f)
|
222
|
-
also.append(link)
|
223
|
-
also.append(', ')
|
224
|
-
}
|
225
|
-
content.append(also)
|
121
|
+
list: $('#version-list'),
|
226
122
|
|
123
|
+
template: _.template($('#version-picker-template').html()),
|
227
124
|
|
228
|
-
|
125
|
+
initialize: function() {
|
126
|
+
this.listenTo(this.model, 'change:versions', this.render)
|
229
127
|
},
|
230
128
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
129
|
+
events: {
|
130
|
+
'click #version-picker': 'toggleList',
|
131
|
+
'click': 'hideList',
|
132
|
+
},
|
133
|
+
|
134
|
+
hideList: function() {
|
135
|
+
this.list.hide(100)
|
136
|
+
},
|
137
|
+
|
138
|
+
toggleList: function(e) {
|
139
|
+
$(e.currentTarget).next().toggle(100)
|
140
|
+
return false
|
141
|
+
},
|
142
|
+
|
143
|
+
render: function() {
|
144
|
+
var vers = this.model.get('versions')
|
145
|
+
list = this.template({versions: vers})
|
146
|
+
this.list.html(list)
|
147
|
+
return this
|
148
|
+
},
|
149
|
+
})
|
150
|
+
|
151
|
+
var ChangelogView = Backbone.View.extend({
|
152
|
+
template: _.template($('#changelog-template').html()),
|
153
|
+
|
154
|
+
itemTemplate: _.template($('#changelog-item-template').html()),
|
155
|
+
|
156
|
+
initialize: function() {
|
235
157
|
// for every version, show which functions added, removed, changed - from HEAD down
|
236
|
-
versions =
|
237
|
-
sigHist =
|
158
|
+
var versions = this.model.get('versions')
|
159
|
+
var sigHist = this.model.get('signatures')
|
238
160
|
|
239
|
-
lastVer = _.first(versions)
|
161
|
+
var lastVer = _.first(versions)
|
240
162
|
|
241
163
|
// fill changelog struct
|
242
|
-
changelog = {}
|
164
|
+
var changelog = {}
|
243
165
|
for(var i in versions) {
|
244
|
-
version = versions[i]
|
166
|
+
var version = versions[i]
|
245
167
|
changelog[version] = {'deletes': [], 'changes': [], 'adds': []}
|
246
168
|
}
|
247
169
|
|
248
170
|
// figure out the adds, deletes and changes
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
171
|
+
_.forEach(sigHist, function(func, fname) {
|
172
|
+
var lastv = _.last(func.exists)
|
173
|
+
var firstv = _.first(func.exists)
|
174
|
+
changelog[firstv]['adds'].push(fname)
|
175
|
+
|
176
|
+
// figure out where it was deleted or changed
|
177
|
+
if (lastv && (lastv != lastVer)) {
|
178
|
+
var vi = _.indexOf(versions,lastv)
|
179
|
+
var delv = versions[vi-1]
|
180
|
+
changelog[delv]['deletes'].push(fname)
|
181
|
+
|
182
|
+
_.forEach(func.changes, function(_, v) {
|
183
|
+
changelog[v]['changes'].push(fname)
|
184
|
+
})
|
185
|
+
}
|
186
|
+
})
|
264
187
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
gname = docurium.groupOf(add)
|
281
|
-
addlink = $('<a>').attr('href', '#' + groupLink(gname, add, version)).append(add)
|
282
|
-
} else {
|
283
|
-
addlink = add
|
284
|
-
}
|
285
|
-
addsection.append($('<li>').addClass(type).append(addlink))
|
286
|
-
}
|
287
|
-
cl.append(addsection)
|
288
|
-
}
|
289
|
-
content.append(cl)
|
290
|
-
}
|
188
|
+
var vers = _.map(versions, function(version) {
|
189
|
+
var deletes = changelog[version]['deletes']
|
190
|
+
deletes.sort()
|
191
|
+
|
192
|
+
var additions = changelog[version]['adds']
|
193
|
+
additions.sort()
|
194
|
+
var adds = _.map(additions, function(add) {
|
195
|
+
var gname = this.model.groupOf(add)
|
196
|
+
return {link: functionLink(gname, add, version), text: add}
|
197
|
+
}, this)
|
198
|
+
|
199
|
+
return {title: version, listing: this.itemTemplate({dels: deletes, adds: adds})}
|
200
|
+
}, this)
|
201
|
+
|
202
|
+
this.el = this.template({versions: vers})
|
291
203
|
},
|
292
204
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
205
|
+
render: function() {
|
206
|
+
return this
|
207
|
+
}
|
208
|
+
})
|
209
|
+
|
210
|
+
var FunctionModel = Backbone.Model.extend({
|
211
|
+
initialize: function() {
|
212
|
+
var gname = this.get('gname')
|
213
|
+
var fname = this.get('fname')
|
214
|
+
var docurium = this.get('docurium')
|
215
|
+
|
216
|
+
var group = docurium.getGroup(gname)
|
217
|
+
|
218
|
+
var fdata = docurium.get('data')['functions']
|
219
|
+
var functions = group[1]
|
220
|
+
|
221
|
+
// Function Arguments
|
222
|
+
var args = _.map(fdata[fname]['args'], function(arg) {
|
223
|
+
return {link: this.hotLink(arg.type), name: arg.name, comment: arg.comment}
|
224
|
+
}, docurium)
|
225
|
+
|
226
|
+
var data = fdata[fname]
|
227
|
+
// function return value
|
228
|
+
var ret = data['return']
|
229
|
+
var returns = {link: docurium.hotLink(ret.type), comment: ret.comment}
|
230
|
+
// function signature
|
231
|
+
var sig = docurium.hotLink(ret.type) + ' ' + fname + '(' + data['argline'] + ');'
|
232
|
+
// version history
|
233
|
+
var sigHist = docurium.get('signatures')[fname]
|
234
|
+
var version = docurium.get('version')
|
235
|
+
var sigs = _.map(sigHist.exists, function(ver) {
|
236
|
+
var klass = []
|
237
|
+
if (sigHist.changes[ver])
|
238
|
+
klass.push('changed')
|
239
|
+
if (ver == version)
|
240
|
+
klass.push('current')
|
241
|
+
|
242
|
+
return {url: '#' + functionLink(gname, fname, ver), name: ver, klass: klass.join(' ')}
|
243
|
+
})
|
244
|
+
// GitHub link
|
245
|
+
var fileLink = docurium.github_file(data.file, data.line, data.lineto)
|
246
|
+
// link to the group
|
247
|
+
var version = docurium.get('version')
|
248
|
+
var alsoGroup = '#' + groupLink(group[0], version)
|
249
|
+
var alsoLinks = _.map(functions, function(f) {
|
250
|
+
return {url: '#' + functionLink(gname, f, version), name: f}
|
251
|
+
})
|
252
|
+
|
253
|
+
this.set('data', {name: fname, data: data, args: args, returns: returns, sig: sig,
|
254
|
+
sigs: sigs, fileLink: fileLink, groupName: gname,
|
255
|
+
alsoGroup: alsoGroup, alsoLinks: alsoLinks})
|
256
|
+
}
|
257
|
+
})
|
303
258
|
|
304
|
-
|
259
|
+
var FunctionView = Backbone.View.extend({
|
260
|
+
template: _.template($('#function-template').html()),
|
261
|
+
argsTemplate: _.template($('#function-args-template').html()),
|
262
|
+
|
263
|
+
render: function() {
|
305
264
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
265
|
+
var data = this.model.get('data')
|
266
|
+
data.argsTemplate = this.argsTemplate
|
267
|
+
var cont = this.template(data)
|
306
268
|
|
307
|
-
|
308
|
-
|
309
|
-
|
269
|
+
this.el = cont
|
270
|
+
return this
|
271
|
+
},
|
272
|
+
})
|
310
273
|
|
311
|
-
|
274
|
+
var GroupCollection = Backbone.Collection.extend({
|
275
|
+
initialize: function(o) {
|
276
|
+
this.docurium = o.docurium
|
277
|
+
this.listenTo(this.docurium, 'change:data', this.refill)
|
278
|
+
},
|
312
279
|
|
313
|
-
|
314
|
-
|
315
|
-
|
280
|
+
refill: function(o, doc) {
|
281
|
+
var data = o.changed.data
|
282
|
+
var sigHist = this.docurium.get('signatures')
|
283
|
+
var version = this.docurium.get('version')
|
316
284
|
|
317
|
-
|
318
|
-
|
319
|
-
|
285
|
+
var groups = _.map(data.groups, function(group) {
|
286
|
+
var gname = group[0]
|
287
|
+
var funs = _.map(group[1], function(fun) {
|
288
|
+
var klass = ''
|
289
|
+
if (sigHist[fun].changes[version])
|
290
|
+
klass = 'changed'
|
320
291
|
|
321
|
-
|
322
|
-
|
323
|
-
content.append($('<h3>').append('Returns'))
|
324
|
-
}
|
325
|
-
for(var i=0; i<ret.length; i++) {
|
326
|
-
gname = docurium.groupOf(ret[i])
|
327
|
-
flink = $('<a>').attr('href', '#' + groupLink(gname, ret[i])).append(ret[i])
|
328
|
-
flink.click( docurium.showFun )
|
329
|
-
content.append(flink)
|
330
|
-
content.append(', ')
|
331
|
-
}
|
292
|
+
if (version == _.first(sigHist[fun].exists))
|
293
|
+
klass = 'introd'
|
332
294
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
}
|
337
|
-
for(var i=0; i<needs.length; i++) {
|
338
|
-
gname = docurium.groupOf(needs[i])
|
339
|
-
flink = $('<a>').attr('href', '#' + groupLink(gname, needs[i])).append(needs[i])
|
340
|
-
flink.click( docurium.showFun )
|
341
|
-
content.append(flink)
|
342
|
-
content.append(', ')
|
343
|
-
}
|
295
|
+
return {name: fun, url: '#' + functionLink(gname, fun, version), klass: klass}
|
296
|
+
})
|
297
|
+
return {name: gname, funs: funs}
|
298
|
+
})
|
344
299
|
|
345
|
-
|
346
|
-
|
347
|
-
|
300
|
+
this.reset(groups)
|
301
|
+
},
|
302
|
+
})
|
348
303
|
|
349
|
-
|
304
|
+
var MainListView = Backbone.View.extend({
|
305
|
+
template: _.template($('#index-template').html()),
|
306
|
+
|
307
|
+
initialize: function() {
|
308
|
+
this.listenTo(this.collection, 'reset', this.render)
|
350
309
|
},
|
351
310
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
}
|
359
|
-
group = docurium.get('data')['groups'][ref]
|
360
|
-
fdata = docurium.get('data')['functions']
|
361
|
-
gname = group[0]
|
311
|
+
render: function() {
|
312
|
+
this.el = this.template({groups: this.collection.toJSON()})
|
313
|
+
this.trigger('redraw')
|
314
|
+
return this
|
315
|
+
},
|
316
|
+
})
|
362
317
|
|
363
|
-
|
364
|
-
|
318
|
+
var TypeModel = Backbone.Model.extend({
|
319
|
+
initialize: function() {
|
320
|
+
var typename = this.get('typename')
|
321
|
+
var docurium = this.get('docurium')
|
322
|
+
var version = docurium.get('version')
|
323
|
+
var types = docurium.get('data')['types']
|
324
|
+
var tdata = _.find(types, function(g) {
|
325
|
+
return g[0] == typename
|
326
|
+
})
|
327
|
+
var tname = tdata[0]
|
328
|
+
var data = tdata[1]
|
365
329
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
table = $('<table>').addClass('methods')
|
371
|
-
for(i=0; i<functions.length; i++) {
|
372
|
-
f = functions[i]
|
373
|
-
d = fdata[f]
|
374
|
-
row = $('<tr>')
|
375
|
-
row.append($('<td>').attr('nowrap', true).attr('valign', 'top').append(d['return']['type'].substring(0, 20)))
|
376
|
-
link = $('<a>').attr('href', '#' + groupLink(gname, f)).append(f)
|
377
|
-
row.append($('<td>').attr('valign', 'top').addClass('methodName').append( link ))
|
378
|
-
args = d['args']
|
379
|
-
argtd = $('<td>')
|
380
|
-
for(j=0; j<args.length; j++) {
|
381
|
-
argtd.append(args[j].type + ' ' + args[j].name)
|
382
|
-
argtd.append($('<br>'))
|
383
|
-
}
|
384
|
-
row.append(argtd)
|
385
|
-
table.append(row)
|
330
|
+
var toPair = function(fun) {
|
331
|
+
var gname = this.groupOf(fun)
|
332
|
+
var url = '#' + functionLink(gname, fun, version)
|
333
|
+
return {name: fun, url: url}
|
386
334
|
}
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
335
|
+
|
336
|
+
var returns = _.map(data.used.returns, toPair, docurium)
|
337
|
+
var needs = _.map(data.used.needs, toPair, docurium)
|
338
|
+
var fileLink = {name: data.file, url: docurium.github_file(data.file, data.line, data.lineto)}
|
339
|
+
|
340
|
+
this.set('data', {tname: tname, data: data, returns: returns, needs: needs, fileLink: fileLink})
|
341
|
+
}
|
342
|
+
})
|
343
|
+
|
344
|
+
var TypeView = Backbone.View.extend({
|
345
|
+
template: _.template($('#type-template').html()),
|
346
|
+
|
347
|
+
render: function() {
|
348
|
+
var content = this.template(this.model.get('data'))
|
349
|
+
this.el = content
|
350
|
+
return this
|
351
|
+
}
|
352
|
+
})
|
353
|
+
|
354
|
+
var GroupView = Backbone.View.extend({
|
355
|
+
template: _.template($('#group-template').html()),
|
356
|
+
|
357
|
+
initialize: function(o) {
|
358
|
+
var group = o.group
|
359
|
+
var gname = group[0]
|
360
|
+
var fdata = o.functions
|
361
|
+
var version = o.version
|
362
|
+
|
363
|
+
this.functions = _.map(group[1], function(name) {
|
364
|
+
var url = '#' + functionLink(gname, name, version)
|
365
|
+
var d = fdata[name]
|
366
|
+
return {name: name, url: url, returns: d['return']['type'], argline: d['argline'],
|
367
|
+
description: d['description'], comments: d['comments'], args: d['args']}
|
368
|
+
})
|
401
369
|
},
|
402
370
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
371
|
+
render: function() {
|
372
|
+
var content = this.template({gname: this.gname, functions: this.functions})
|
373
|
+
|
374
|
+
this.el = content
|
375
|
+
return this
|
376
|
+
},
|
377
|
+
})
|
378
|
+
|
379
|
+
var SearchFieldView = Backbone.View.extend({
|
380
|
+
tagName: 'input',
|
381
|
+
|
382
|
+
el: $('#search-field'),
|
383
|
+
|
384
|
+
events: {
|
385
|
+
'keyup': function() {
|
386
|
+
this.trigger('keyup')
|
387
|
+
if (this.$el.val() == '')
|
388
|
+
this.trigger('empty')
|
413
389
|
}
|
414
|
-
return text
|
415
390
|
},
|
391
|
+
})
|
416
392
|
|
417
|
-
|
418
|
-
|
393
|
+
var SearchCollection = Backbone.Collection.extend({
|
394
|
+
defaults: {
|
395
|
+
value: '',
|
419
396
|
},
|
420
397
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
className = '.typeLink' + domSafe(typeName)
|
427
|
-
$(className).click( this.showType )
|
428
|
-
}
|
398
|
+
initialize: function(o) {
|
399
|
+
this.field = o.field
|
400
|
+
this.docurium = o.docurium
|
401
|
+
|
402
|
+
this.listenTo(this.field, 'keyup', this.keyup)
|
429
403
|
},
|
430
404
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
menu = $('<li>')
|
436
|
-
title = $('<h3><a href="#">Functions</a></h3>').click( this.collapseSection )
|
437
|
-
menu.append(title)
|
438
|
-
list = $('<ul>')
|
439
|
-
_.each(data['groups'], function(group, i) {
|
440
|
-
flink = $('<a href="#" ref="' + i.toString() + '" id="groupItem' + group[0] + '">' + group[0] + ' <small>(' + group[1].length + ')</small></a>')
|
441
|
-
flink.click( this.showGroup )
|
442
|
-
fitem = $('<li>')
|
443
|
-
fitem.append(flink)
|
444
|
-
list.append(fitem)
|
445
|
-
}, this)
|
446
|
-
menu.append(list)
|
405
|
+
keyup: function() {
|
406
|
+
var newValue = this.field.$el.val()
|
407
|
+
if (this.value == newValue || newValue.length < 3)
|
408
|
+
return
|
447
409
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
410
|
+
this.value = newValue
|
411
|
+
this.refreshSearch()
|
412
|
+
},
|
413
|
+
|
414
|
+
refreshSearch: function() {
|
415
|
+
var docurium = this.docurium
|
416
|
+
var value = this.value
|
417
|
+
|
418
|
+
var data = docurium.get('data')
|
419
|
+
var searchResults = []
|
420
|
+
|
421
|
+
var version = docurium.get('version')
|
422
|
+
// look for functions (name, comment, argline)
|
423
|
+
_.forEach(data.functions, function(f, name) {
|
424
|
+
var gname = docurium.groupOf(name)
|
425
|
+
// look in the function name first
|
426
|
+
if (name.search(value) > -1) {
|
427
|
+
var gl = functionLink(gname, name, version)
|
428
|
+
var url = '#' + gl
|
429
|
+
searchResults.push({url: url, name: name, match: 'function', navigate: gl})
|
430
|
+
return
|
464
431
|
}
|
465
|
-
}, this)
|
466
432
|
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
if(group[1]['block'] && group[1]['type'] != 'enum') {
|
473
|
-
flink = $('<a href="#" ref="' + i.toString() + '" id="typeItem' + domSafe(group[0]) + '">' + group[0] + '</a>')
|
474
|
-
flink.click( this.showType )
|
475
|
-
fitem = $('<li>')
|
476
|
-
fitem.append(flink)
|
477
|
-
list.append(fitem)
|
433
|
+
// if we didn't find it there, let's look in the argline
|
434
|
+
if (f.argline && f.argline.search(value) > -1) {
|
435
|
+
var gl = functionLink(gname, name, version)
|
436
|
+
var url = '#' + gl
|
437
|
+
searchResults.push({url: url, name: name, match: f.argline, navigate: gl})
|
478
438
|
}
|
479
|
-
}
|
439
|
+
})
|
480
440
|
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
if(
|
487
|
-
|
488
|
-
flink.click( this.showType )
|
489
|
-
fitem = $('<li>')
|
490
|
-
fitem.append(flink)
|
491
|
-
list.append(fitem)
|
441
|
+
// look for types
|
442
|
+
data.types.forEach(function(type) {
|
443
|
+
var name = type[0]
|
444
|
+
var tl = typeLink(name, version)
|
445
|
+
var url = '#' + tl
|
446
|
+
if (name.search(value) > -1) {
|
447
|
+
searchResults.push({url: url, name: name, match: type[1].type, navigate: tl})
|
492
448
|
}
|
493
|
-
}
|
494
|
-
list.hide()
|
495
|
-
menu.append(list)
|
449
|
+
})
|
496
450
|
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
filelist = $('<ul>')
|
501
|
-
_.each(data['files'], function(file) {
|
502
|
-
url = this.github_file(file['file'])
|
503
|
-
flink = $('<a target="github" href="' + url + '">' + file['file'] + '</a>')
|
504
|
-
fitem = $('<li>')
|
505
|
-
fitem.append(flink)
|
506
|
-
filelist.append(fitem)
|
507
|
-
}, this)
|
508
|
-
filelist.hide()
|
509
|
-
menu.append(filelist)
|
451
|
+
this.reset(searchResults)
|
452
|
+
},
|
453
|
+
})
|
510
454
|
|
511
|
-
|
512
|
-
|
513
|
-
title = $('<h3><a href="#">Examples</a></h3>').click( this.collapseSection )
|
514
|
-
menu.append(title)
|
515
|
-
filelist = $('<ul>')
|
516
|
-
_.each(data['examples'], function(file) {
|
517
|
-
fname = file[0]
|
518
|
-
fpath = file[1]
|
519
|
-
flink = $('<a>').attr('href', fpath).append(fname)
|
520
|
-
fitem = $('<li>')
|
521
|
-
fitem.append(flink)
|
522
|
-
filelist.append(fitem)
|
523
|
-
}, this)
|
524
|
-
menu.append(filelist)
|
525
|
-
}
|
455
|
+
var SearchView = Backbone.View.extend({
|
456
|
+
template: _.template($('#search-template').html()),
|
526
457
|
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
},
|
458
|
+
// initialize: function() {
|
459
|
+
// this.listenTo(this.model, 'reset', this.render)
|
460
|
+
// },
|
531
461
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
462
|
+
render: function() {
|
463
|
+
var content = this.template({results: this.collection.toJSON()})
|
464
|
+
this.el = content
|
465
|
+
}
|
466
|
+
})
|
467
|
+
|
468
|
+
var MainView = Backbone.View.extend({
|
469
|
+
el: $('#content'),
|
470
|
+
|
471
|
+
setActive: function(view) {
|
472
|
+
view.render()
|
473
|
+
|
474
|
+
if (this.activeView) {
|
475
|
+
this.stopListening()
|
476
|
+
this.activeView.remove()
|
542
477
|
}
|
543
|
-
|
478
|
+
|
479
|
+
this.activeView = view
|
480
|
+
// make sure we know when the view wants to render again
|
481
|
+
this.listenTo(view, 'redraw', this.render)
|
482
|
+
|
483
|
+
this.$el.html(view.el)
|
484
|
+
|
485
|
+
// move back to the top when we switch views
|
486
|
+
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
544
487
|
},
|
545
488
|
|
546
|
-
|
547
|
-
|
548
|
-
|
489
|
+
render: function() {
|
490
|
+
this.$el.html(this.activeView.el)
|
491
|
+
},
|
492
|
+
})
|
549
493
|
|
550
|
-
|
551
|
-
|
552
|
-
return
|
553
|
-
}
|
494
|
+
// our document model - stores the datastructure generated from docurium
|
495
|
+
var Docurium = Backbone.Model.extend({
|
554
496
|
|
555
|
-
|
497
|
+
defaults: {'version': 'unknown'},
|
556
498
|
|
557
|
-
|
499
|
+
initialize: function() {
|
500
|
+
this.loadVersions()
|
501
|
+
this.bind('change:version', this.loadDoc)
|
502
|
+
},
|
558
503
|
|
559
|
-
|
504
|
+
loadVersions: function() {
|
505
|
+
$.getJSON("project.json").then(function(data) {
|
506
|
+
docurium.set({'versions': data.versions, 'github': data.github, 'signatures': data.signatures, 'name': data.name, 'groups': data.groups})
|
507
|
+
docurium.setVersion()
|
508
|
+
})
|
509
|
+
},
|
560
510
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
if (name.search(value) > -1) {
|
565
|
-
gname = docurium.groupOf(name)
|
566
|
-
var flink = $('<a>').attr('href', '#' + groupLink(gname, name)).append(name)
|
567
|
-
searchResults.push(['fun-' + name, flink, 'function'])
|
568
|
-
}
|
569
|
-
if (f.argline) {
|
570
|
-
if (f.argline.search(value) > -1) {
|
571
|
-
gname = docurium.groupOf(name)
|
572
|
-
var flink = $('<a>').attr('href', '#' + groupLink(gname, name)).append(name)
|
573
|
-
searchResults.push(['fun-' + name, flink, f.argline])
|
574
|
-
}
|
575
|
-
}
|
511
|
+
setVersion: function (version) {
|
512
|
+
if(!version) {
|
513
|
+
version = _.first(docurium.get('versions'))
|
576
514
|
}
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
}
|
515
|
+
docurium.set({version: version})
|
516
|
+
},
|
517
|
+
|
518
|
+
loadDoc: function() {
|
519
|
+
version = this.get('version')
|
520
|
+
$.getJSON(version + '.json').then(function(data) {
|
521
|
+
docurium.set({data: data})
|
522
|
+
})
|
523
|
+
},
|
524
|
+
|
525
|
+
getGroup: function(gname) {
|
526
|
+
var groups = docurium.get('data')['groups']
|
527
|
+
return _.find(groups, function(g) {
|
528
|
+
return g[0] == gname
|
529
|
+
})
|
530
|
+
},
|
531
|
+
|
532
|
+
// look for structs and link them
|
533
|
+
hotLink: function(text) {
|
534
|
+
types = this.get('data')['types']
|
535
|
+
var version = this.get('version')
|
536
|
+
for(var i=0; i<types.length; i++) {
|
537
|
+
type = types[i]
|
538
|
+
typeName = type[0]
|
539
|
+
typeData = type[1]
|
540
|
+
re = new RegExp(typeName + ' ', 'gi');
|
541
|
+
var link = $('<a>').attr('href', '#' + typeLink(typeName, version)).append(typeName)[0]
|
542
|
+
text = text.replace(re, link.outerHTML + ' ')
|
584
543
|
}
|
544
|
+
return text
|
545
|
+
},
|
585
546
|
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
link = result[1]
|
599
|
-
match = result[2]
|
600
|
-
row.append($('<td>').append(link))
|
601
|
-
row.append($('<td>').append(match))
|
602
|
-
table.append(row)
|
603
|
-
shown[result[0]] = true
|
547
|
+
groupOf: function (func) {
|
548
|
+
return this.get('groups')[func]
|
549
|
+
},
|
550
|
+
|
551
|
+
github_file: function(file, line, lineto) {
|
552
|
+
var data = this.get('data')
|
553
|
+
url = ['https://github.com', docurium.get('github'),
|
554
|
+
'blob', docurium.get('version'), data.prefix, file].join('/')
|
555
|
+
if(line) {
|
556
|
+
url += '#L' + line.toString()
|
557
|
+
if(lineto) {
|
558
|
+
url += '-' + lineto.toString()
|
604
559
|
}
|
560
|
+
} else {
|
561
|
+
url += '#files'
|
605
562
|
}
|
606
|
-
content.append(table)
|
607
|
-
|
608
|
-
}
|
609
563
|
|
564
|
+
return url
|
565
|
+
},
|
610
566
|
})
|
611
567
|
|
612
568
|
var Workspace = Backbone.Router.extend({
|
613
569
|
|
614
570
|
routes: {
|
615
|
-
"": "
|
571
|
+
"": "index",
|
616
572
|
":version": "main",
|
617
573
|
":version/group/:group": "group",
|
618
574
|
":version/type/:type": "showtype",
|
@@ -621,77 +577,114 @@ $(function() {
|
|
621
577
|
"p/changelog": "changelog",
|
622
578
|
},
|
623
579
|
|
580
|
+
initialize: function(o) {
|
581
|
+
this.doc = o.docurium
|
582
|
+
this.search = o.search
|
583
|
+
this.mainView = o.mainView
|
584
|
+
this.groups = o.groups
|
585
|
+
},
|
586
|
+
|
587
|
+
index: function() {
|
588
|
+
// set the default version
|
589
|
+
this.doc.setVersion()
|
590
|
+
// and replate our URL with it, to avoid a back-button loop
|
591
|
+
this.navigate(this.doc.get('version'), {replace: true, trigger: true})
|
592
|
+
},
|
593
|
+
|
624
594
|
main: function(version) {
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
docurium.showIndexPage(replace)
|
595
|
+
this.doc.setVersion(version)
|
596
|
+
var view = new MainListView({collection: this.groups})
|
597
|
+
this.mainView.setActive(view)
|
629
598
|
},
|
630
599
|
|
631
600
|
group: function(version, gname) {
|
632
|
-
|
633
|
-
|
601
|
+
this.doc.setVersion(version)
|
602
|
+
var group = this.doc.getGroup(gname)
|
603
|
+
var fdata = this.doc.get('data')['functions']
|
604
|
+
var version = this.doc.get('version')
|
605
|
+
var view = new GroupView({group: group, functions: fdata, version: version})
|
606
|
+
this.mainView.setActive(view)
|
634
607
|
},
|
635
608
|
|
636
609
|
groupFun: function(version, gname, fname) {
|
637
|
-
|
638
|
-
docurium.
|
610
|
+
this.doc.setVersion(version)
|
611
|
+
var model = new FunctionModel({docurium: this.doc, gname: gname, fname: fname})
|
612
|
+
var view = new FunctionView({model: model})
|
613
|
+
this.mainView.setActive(view)
|
639
614
|
},
|
640
615
|
|
641
616
|
showtype: function(version, tname) {
|
642
|
-
|
643
|
-
docurium.
|
617
|
+
this.doc.setVersion(version)
|
618
|
+
var model = new TypeModel({docurium: this.doc, typename: tname})
|
619
|
+
var view = new TypeView({model: model})
|
620
|
+
this.mainView.setActive(view)
|
644
621
|
},
|
645
622
|
|
646
623
|
search: function(version, query) {
|
647
|
-
|
648
|
-
|
649
|
-
|
624
|
+
this.doc.setVersion(version)
|
625
|
+
var view = new SearchView({collection: this.search})
|
626
|
+
$('#search-field').val(query).keyup()
|
627
|
+
this.mainView.setActive(view)
|
650
628
|
},
|
651
629
|
|
652
630
|
changelog: function(version, tname) {
|
653
|
-
|
654
|
-
|
631
|
+
// let's wait to process it until it's asked, and let's only do
|
632
|
+
// it once
|
633
|
+
if (this.changelogView == undefined) {
|
634
|
+
this.changelogView = new ChangelogView({model: this.doc})
|
635
|
+
}
|
636
|
+
this.doc.setVersion()
|
637
|
+
this.mainView.setActive(this.ChangelogView)
|
655
638
|
},
|
656
|
-
|
657
639
|
});
|
658
640
|
|
659
|
-
function
|
660
|
-
if(!version) {
|
661
|
-
version = docurium.get('version')
|
662
|
-
}
|
663
|
-
if(fname) {
|
641
|
+
function functionLink(gname, fname, version) {
|
664
642
|
return version + "/group/" + gname + '/' + fname
|
665
|
-
} else {
|
666
|
-
return version + "/group/" + gname
|
667
|
-
}
|
668
643
|
}
|
669
644
|
|
670
|
-
function
|
671
|
-
|
645
|
+
function groupLink(gname, version) {
|
646
|
+
return version + "/group/" + gname
|
672
647
|
}
|
673
648
|
|
674
|
-
function
|
675
|
-
return
|
649
|
+
function typeLink(tname, version) {
|
650
|
+
return version + "/type/" + tname
|
676
651
|
}
|
677
652
|
|
678
|
-
function
|
679
|
-
return
|
653
|
+
function searchLink(term, version) {
|
654
|
+
return version + "/search/" + term
|
680
655
|
}
|
681
656
|
|
682
|
-
|
683
|
-
window.docurium = new Docurium
|
684
|
-
window.ws = new Workspace
|
657
|
+
//_.templateSettings.variable = 'rc'
|
685
658
|
|
686
|
-
docurium
|
687
|
-
|
688
|
-
})
|
689
|
-
docurium
|
690
|
-
|
659
|
+
var docurium = new Docurium
|
660
|
+
|
661
|
+
var searchField = new SearchFieldView({id: 'search-field'})
|
662
|
+
var searchCol = new SearchCollection({docurium: docurium, field: searchField})
|
663
|
+
var groupCol = new GroupCollection({docurium: docurium})
|
664
|
+
|
665
|
+
var mainView = new MainView()
|
666
|
+
|
667
|
+
var router = new Workspace({docurium: docurium, search: searchCol, mainView: mainView,
|
668
|
+
groups: groupCol})
|
669
|
+
|
670
|
+
searchField.on('empty', function() {
|
671
|
+
router.navigate(docurium.get('version'), {trigger: true})
|
691
672
|
})
|
692
673
|
|
693
|
-
|
674
|
+
docurium.once('change:data', function() {Backbone.history.start()})
|
694
675
|
|
695
|
-
|
676
|
+
var fileList = new FileListModel({docurium: docurium})
|
677
|
+
var fileListView = new FileListView({model: fileList})
|
678
|
+
var versionView = new VersionView({model: docurium})
|
679
|
+
var versionPickerView = new VersionPickerView({model: docurium})
|
696
680
|
|
681
|
+
searchCol.on('reset', function(col, prev) {
|
682
|
+
if (col.length == 1) {
|
683
|
+
router.navigate(col.pluck('navigate')[0], {trigger: true, replace: true})
|
684
|
+
} else {
|
685
|
+
var version = docurium.get('version')
|
686
|
+
// FIXME: this keeps recreating the view
|
687
|
+
router.navigate(searchLink(col.value, version), {trigger: true})
|
688
|
+
}
|
689
|
+
})
|
697
690
|
})
|