docjs 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +14 -0
- data/bin/docjs +85 -46
- data/bin/docjs.rb +85 -46
- data/docjs.gemspec +2 -2
- data/docs/guides/CUSTOMIZE.md +90 -0
- data/lib/boot.rb +12 -2
- data/lib/code_object/base.rb +0 -4
- data/lib/code_object/converter.rb +10 -11
- data/lib/configs.rb +28 -0
- data/lib/document/document.rb +21 -0
- data/lib/dom/dom.rb +0 -9
- data/lib/generator/generator.rb +168 -53
- data/lib/helper/helper.rb +3 -0
- data/lib/parser/comment.rb +1 -1
- data/lib/parser/comment_parser.rb +8 -4
- data/lib/parser/meta_container.rb +5 -1
- data/lib/parser/parser.rb +36 -10
- data/lib/processor.rb +70 -38
- data/lib/renderer.rb +100 -1
- data/lib/thor.rb +2 -0
- data/lib/token/container.rb +9 -5
- data/lib/token/handler.rb +1 -3
- data/lib/token/token.rb +2 -0
- data/templates/generators/api_index_generator.rb +1 -0
- data/templates/generators/api_pages_generator.rb +2 -0
- data/templates/generators/docs_generator.rb +2 -0
- data/templates/generators/json_generator.rb +16 -0
- data/templates/helpers/template.rb +24 -7
- data/templates/resources/css/application.css +18 -3
- data/templates/resources/scss/_header.scss +2 -2
- data/templates/resources/scss/_helpers.scss +3 -2
- data/templates/resources/scss/application.scss +15 -0
- data/test/parser/intelligent_skip_until.rb +10 -0
- data/test/parser/parser.rb +44 -0
- metadata +50 -47
@@ -1,5 +1,7 @@
|
|
1
1
|
module Generator
|
2
2
|
|
3
|
+
# renders documented objects type-dependant (Functions and Objects). Each CodeObject is rendered to
|
4
|
+
# it's own page. The path is calculated using {Helper::Linker#path_to}
|
3
5
|
class ApiPagesGenerator < Generator
|
4
6
|
|
5
7
|
describe 'renders documented objects type-dependant (Functions and Objects)'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Generator
|
2
2
|
|
3
|
+
# renders all specified Markdown files to static documentation. The path to each documentation-page
|
4
|
+
# is derived from it's position in the Dom, using {Helper::Linker#path_to}.
|
3
5
|
class DocsGenerator < Generator
|
4
6
|
|
5
7
|
describe 'renders all specified Markdown files to static documentation'
|
@@ -1,5 +1,21 @@
|
|
1
1
|
module Generator
|
2
2
|
|
3
|
+
# renders all documented objects to a json file. Objects and Functions are handled seperatly.
|
4
|
+
# Needed for the JavaScript-search / filter. Renders the file `js/apisearch-data.js` which looks
|
5
|
+
# like:
|
6
|
+
#
|
7
|
+
# J.data.apisearch = {
|
8
|
+
#
|
9
|
+
# "functions":[
|
10
|
+
# { "namespace":"Core",
|
11
|
+
# "fullname":"Core.extend",
|
12
|
+
# "path":"api/Core/extend.html",
|
13
|
+
# "name":".extend",
|
14
|
+
# "constructor":false
|
15
|
+
# },...],
|
16
|
+
#
|
17
|
+
# "objects": [...]
|
18
|
+
# }
|
3
19
|
class JsonGenerator < Generator
|
4
20
|
|
5
21
|
describe 'renders all documented objects to a json file. Objects and Functions are handled seperatly'
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# They are included in the Typed-RenderTask
|
4
4
|
module Helper::Template
|
5
5
|
|
6
|
+
# Creates the html-signature of a function, including the markup for a tooltip
|
6
7
|
def signature(method_or_token)
|
7
8
|
|
8
9
|
if method_or_token.is_a? Token::Token
|
@@ -24,14 +25,16 @@ module Helper::Template
|
|
24
25
|
"(#{return_types || 'Void'}) <span class='name'>#{method_or_token.name}</span>(<span class='params'>#{params}</span>)"
|
25
26
|
end
|
26
27
|
|
27
|
-
def subsection(id, opts = {})
|
28
|
-
unless opts[:collection].nil? or opts[:collection].size == 0
|
29
|
-
"<h3>#{opts[:title]}</h3><ul class=\"#{id} subsection\">" +
|
30
|
-
render(:partial => opts[:partial], :collection => opts[:collection]) +
|
31
|
-
"</ul>"
|
32
|
-
end
|
33
|
-
end
|
34
28
|
|
29
|
+
# Creates an hierarchy-overview, which can be seen in the sidebar. The direct parent and
|
30
|
+
# all children are listed in the overview:
|
31
|
+
#
|
32
|
+
# DocJs
|
33
|
+
# > CurrentNode
|
34
|
+
# ChildNode1
|
35
|
+
# ChildNode2
|
36
|
+
# ...
|
37
|
+
#
|
35
38
|
def hierarchy(object)
|
36
39
|
|
37
40
|
children = object.children.values.reject {|c| c.is_a? CodeObject::Function }
|
@@ -43,6 +46,20 @@ module Helper::Template
|
|
43
46
|
"</ul>" * (parents.size + 2)
|
44
47
|
end
|
45
48
|
|
49
|
+
# Creates the markup for the Api-Tree Browser in the heading-section. The JavaScript tree is
|
50
|
+
# powered by jquery-treeview by Jörn Zaefferer
|
51
|
+
#
|
52
|
+
# @example output
|
53
|
+
# <ul>
|
54
|
+
# <li class="object"><a href="api/Core.html"><span>Core</span></a>
|
55
|
+
# <ul>
|
56
|
+
# <li class="function"><a href="api/Core/extend.html"><span>extend</span></a>
|
57
|
+
# <li class="function"><a href="api/Core/extensions.html"><span>extensions</span></a>
|
58
|
+
# </ul>
|
59
|
+
# </ul>
|
60
|
+
#
|
61
|
+
# @see http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
|
62
|
+
# @see http://docs.jquery.com/Plugins/Treeview
|
46
63
|
def api_browser(root = Dom.root)
|
47
64
|
if root == Dom.root
|
48
65
|
output = ""
|
@@ -1,4 +1,19 @@
|
|
1
1
|
@charset "UTF-8";
|
2
|
+
/*
|
3
|
+
* README
|
4
|
+
* ======
|
5
|
+
*
|
6
|
+
* The application.css is generated using SCSS (see http://sass-lang.com/). You can manipulate it
|
7
|
+
* yourself or edit the *.scss template files and afterwards run
|
8
|
+
*
|
9
|
+
* sass templates/resources/scss/application.scss:templates/resources/css/application.css`
|
10
|
+
*
|
11
|
+
* All needed partials (like `_print.scss`) will be required automatically through the use of `@import`.
|
12
|
+
*
|
13
|
+
* Please note, that all manual changes to application.css will be lost, by running the command
|
14
|
+
* above.
|
15
|
+
*
|
16
|
+
*/
|
2
17
|
/* Global Colors */
|
3
18
|
/* Header-colors */
|
4
19
|
/*#4096ee;*/
|
@@ -384,12 +399,12 @@ input:invalid, textarea:invalid {
|
|
384
399
|
border: 1px solid #eee;
|
385
400
|
padding: 0;
|
386
401
|
margin: 0;
|
387
|
-
overflow:
|
388
|
-
|
402
|
+
overflow: auto;
|
403
|
+
max-height: 450px; }
|
389
404
|
#header .col50 section > ul::-webkit-scrollbar {
|
390
405
|
width: 7px;
|
391
406
|
height: 9px; }
|
392
|
-
#header .col50 section > ul::-webkit-scrollbar-button:start:decrement, #header .col50 section > ul
|
407
|
+
#header .col50 section > ul::-webkit-scrollbar-button:start:decrement, #header .col50 section > ul::-webkit-scrollbar-button:end:increment {
|
393
408
|
display: block;
|
394
409
|
height: 0;
|
395
410
|
background-color: transparent; }
|
@@ -32,7 +32,8 @@ $golden_ratio: 1.618;
|
|
32
32
|
/* inspired by http://docs.sencha.com/ext-js/4-0/ */
|
33
33
|
@mixin scrollbars() {
|
34
34
|
&::-webkit-scrollbar { width: 7px; height: 9px; }
|
35
|
-
&::-webkit-scrollbar-button:start:decrement,
|
35
|
+
&::-webkit-scrollbar-button:start:decrement,
|
36
|
+
&::-webkit-scrollbar-button:end:increment { display: block; height: 0; background-color: transparent; }
|
36
37
|
&::-webkit-scrollbar-track-piece { -webkit-border-radius: 0; -webkit-border-bottom-right-radius: 4px; -webkit-border-bottom-left-radius: 4px; }
|
37
38
|
&::-webkit-scrollbar-thumb:vertical { height: 50px; background-color: rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; }
|
38
39
|
&::-webkit-scrollbar-thumb:horizontal { width: 50px; background-color: rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; }
|
@@ -94,4 +95,4 @@ $golden_ratio: 1.618;
|
|
94
95
|
@mixin float($direction) {
|
95
96
|
display: block;
|
96
97
|
float: $direction;
|
97
|
-
}
|
98
|
+
}
|
@@ -1,3 +1,18 @@
|
|
1
|
+
/*!
|
2
|
+
* README
|
3
|
+
* ======
|
4
|
+
*
|
5
|
+
* The application.css is generated using SCSS (see http://sass-lang.com/). You can manipulate it
|
6
|
+
* yourself or edit the *.scss template files and afterwards run
|
7
|
+
*
|
8
|
+
* sass templates/resources/scss/application.scss:templates/resources/css/application.css`
|
9
|
+
*
|
10
|
+
* All needed partials (like `_print.scss`) will be required automatically through the use of `@import`.
|
11
|
+
*
|
12
|
+
* Please note, that all manual changes to application.css will be lost, by running the command
|
13
|
+
* above.
|
14
|
+
*
|
15
|
+
*/
|
1
16
|
$default-fonts: Arial, sans-serif;
|
2
17
|
$font-size: 10pt;
|
3
18
|
|
@@ -40,6 +40,16 @@ describe StringScanner, "#intelligent_skip_until" do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
context "strings as code context (pattern from scope search)" do
|
44
|
+
before do
|
45
|
+
@scanner = StringScanner.new "var string = \"1234567\;\"\nsome more"
|
46
|
+
@scanner.intelligent_skip_until /\{|\(|\}|\)|$/
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should find linebreak at pos 23" do
|
50
|
+
@scanner.pos.should == 23
|
51
|
+
end
|
52
|
+
end
|
43
53
|
|
44
54
|
context "regular expressions" do
|
45
55
|
before do
|
data/test/parser/parser.rb
CHANGED
@@ -244,6 +244,50 @@ describe Parser::Parser, ".parse" do
|
|
244
244
|
end
|
245
245
|
|
246
246
|
|
247
|
+
context "parsing regular expressions" do
|
248
|
+
|
249
|
+
before do
|
250
|
+
|
251
|
+
@comments = Parser::Parser.new("/**
|
252
|
+
* @function _dispatchResponse
|
253
|
+
*/
|
254
|
+
function _dispatchResponse(response) {
|
255
|
+
var code = response.statusCode;
|
256
|
+
var data = response.data || response.rawData;
|
257
|
+
|
258
|
+
_respond(code.toString().replace(/\d{2}$/, 'XX'), data, response);
|
259
|
+
}").parse
|
260
|
+
end
|
261
|
+
|
262
|
+
subject { @comments.first }
|
263
|
+
|
264
|
+
it "should find the correct source" do
|
265
|
+
subject.source.should == "function _dispatchResponse(response) {
|
266
|
+
var code = response.statusCode;
|
267
|
+
var data = response.data || response.rawData;
|
268
|
+
|
269
|
+
_respond(code.toString().replace(/\d{2}$/, 'XX'), data, response);
|
270
|
+
}"
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
context "parsing strings and lineends correctly for scope" do
|
275
|
+
before do
|
276
|
+
@comments = Parser::Parser.new("/**
|
277
|
+
* @object someString
|
278
|
+
*/
|
279
|
+
var string = \"1234567\";
|
280
|
+
").parse
|
281
|
+
end
|
282
|
+
|
283
|
+
subject { @comments.first }
|
284
|
+
|
285
|
+
it "should parse the string correctly" do
|
286
|
+
subject.source.should == "var string = \"1234567\";\n"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
|
247
291
|
context "parsing multibyte character" do
|
248
292
|
|
249
293
|
before do
|
metadata
CHANGED
@@ -1,49 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: docjs
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
4
5
|
prerelease:
|
5
|
-
version: "0.2"
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
7
|
+
authors:
|
8
|
+
- Jonathan Brachthäuser
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: rdiscount
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: thor
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
31
33
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
36
38
|
type: :runtime
|
37
|
-
|
38
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Create beautiful Javascript documentations with this ruby-gem. It's pretty
|
47
|
+
easy to customize and add your own tokens/DSL.
|
39
48
|
email: jonathan@b-studios.de
|
40
|
-
executables:
|
49
|
+
executables:
|
41
50
|
- docjs
|
42
51
|
extensions: []
|
43
|
-
|
44
52
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
53
|
+
files:
|
47
54
|
- LICENSE.md
|
48
55
|
- README.md
|
49
56
|
- bin/docjs
|
@@ -157,33 +164,29 @@ files:
|
|
157
164
|
- test/rspec_helper.rb
|
158
165
|
- test/token/handler.rb
|
159
166
|
- test/token/tokens.rb
|
160
|
-
has_rdoc: true
|
161
167
|
homepage: https://github.com/b-studios/doc.js
|
162
168
|
licenses: []
|
163
|
-
|
164
169
|
post_install_message:
|
165
170
|
rdoc_options: []
|
166
|
-
|
167
|
-
require_paths:
|
171
|
+
require_paths:
|
168
172
|
- lib
|
169
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
174
|
none: false
|
171
|
-
requirements:
|
172
|
-
- -
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version:
|
175
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '1.9'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
180
|
none: false
|
177
|
-
requirements:
|
178
|
-
- -
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version:
|
181
|
+
requirements:
|
182
|
+
- - ! '>='
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '1.5'
|
181
185
|
requirements: []
|
182
|
-
|
183
186
|
rubyforge_project: docjs
|
184
|
-
rubygems_version: 1.
|
187
|
+
rubygems_version: 1.8.24
|
185
188
|
signing_key:
|
186
189
|
specification_version: 3
|
187
190
|
summary: Javascript Documentation Generator
|
188
191
|
test_files: []
|
189
|
-
|
192
|
+
has_rdoc:
|