docjs 0.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/CONCEPT.md +80 -0
- data/DOCUMENTATION.md +41 -0
- data/LICENSE.md +19 -0
- data/README.md +19 -0
- data/RENDERING.md +8 -0
- data/bin/docjs +190 -0
- data/docjs.gemspec +32 -0
- data/lib/boot.rb +34 -0
- data/lib/code_object/base.rb +48 -0
- data/lib/code_object/converter.rb +48 -0
- data/lib/code_object/exceptions.rb +5 -0
- data/lib/code_object/function.rb +84 -0
- data/lib/code_object/object.rb +18 -0
- data/lib/code_object/type.rb +43 -0
- data/lib/configs.rb +53 -0
- data/lib/document/document.rb +25 -0
- data/lib/dom/dom.rb +188 -0
- data/lib/dom/exceptions.rb +12 -0
- data/lib/dom/no_doc.rb +26 -0
- data/lib/dom/node.rb +415 -0
- data/lib/helper/helper.rb +120 -0
- data/lib/helper/linker.rb +130 -0
- data/lib/logger.rb +49 -0
- data/lib/parser/comment.rb +69 -0
- data/lib/parser/comment_parser.rb +90 -0
- data/lib/parser/exceptions.rb +6 -0
- data/lib/parser/meta_container.rb +20 -0
- data/lib/parser/parser.rb +269 -0
- data/lib/processor.rb +123 -0
- data/lib/renderer.rb +108 -0
- data/lib/tasks/render_task.rb +112 -0
- data/lib/thor.rb +27 -0
- data/lib/token/container.rb +84 -0
- data/lib/token/exceptions.rb +6 -0
- data/lib/token/handler.rb +242 -0
- data/lib/token/token.rb +46 -0
- data/templates/application.rb +14 -0
- data/templates/helpers/template.rb +66 -0
- data/templates/resources/css/.sass-cache/98c121fba905284c2c8ca6220fe3c590e5c9ec19/application.scssc +0 -0
- data/templates/resources/css/application.css +836 -0
- data/templates/resources/img/arrow_down.png +0 -0
- data/templates/resources/img/arrow_right.png +0 -0
- data/templates/resources/img/arrow_up.png +0 -0
- data/templates/resources/img/bullet_toggle_minus.png +0 -0
- data/templates/resources/img/bullet_toggle_plus.png +0 -0
- data/templates/resources/img/constructor.png +0 -0
- data/templates/resources/img/function.png +0 -0
- data/templates/resources/img/object.png +0 -0
- data/templates/resources/img/page.png +0 -0
- data/templates/resources/img/prototype.png +0 -0
- data/templates/resources/img/tag.png +0 -0
- data/templates/resources/js/application.js +318 -0
- data/templates/resources/js/jcore.js +129 -0
- data/templates/resources/js/jquery.cookie.js +92 -0
- data/templates/resources/js/jquery.js +16 -0
- data/templates/resources/js/jquery.tooltip.js +77 -0
- data/templates/resources/js/jquery.treeview.js +238 -0
- data/templates/resources/scss/_footer.scss +10 -0
- data/templates/resources/scss/_header.scss +184 -0
- data/templates/resources/scss/_helpers.scss +91 -0
- data/templates/resources/scss/_print.scss +20 -0
- data/templates/resources/scss/_resets.scss +132 -0
- data/templates/resources/scss/_tooltip.scss +26 -0
- data/templates/resources/scss/application.scss +442 -0
- data/templates/tasks/api_index_task.rb +26 -0
- data/templates/tasks/docs_task.rb +33 -0
- data/templates/tasks/json_data_task.rb +55 -0
- data/templates/tasks/typed_task.rb +54 -0
- data/templates/tokens/tokens.rb +22 -0
- data/templates/types/prototype.rb +20 -0
- data/templates/views/api_index.html.erb +21 -0
- data/templates/views/doc_page.html.erb +11 -0
- data/templates/views/function/_detail.html.erb +8 -0
- data/templates/views/function/index.html.erb +53 -0
- data/templates/views/index.html.erb +0 -0
- data/templates/views/layout/application.html.erb +73 -0
- data/templates/views/layout/json.html.erb +3 -0
- data/templates/views/object/index.html.erb +63 -0
- data/templates/views/tokens/_default.html.erb +11 -0
- data/templates/views/tokens/_default_token.html.erb +19 -0
- data/templates/views/tokens/_example.html.erb +2 -0
- data/templates/views/tokens/_examples.html.erb +1 -0
- data/test/code_object/converter.rb +78 -0
- data/test/code_object/prototype.rb +70 -0
- data/test/configs.rb +65 -0
- data/test/docs/README.CONCEPT.md +83 -0
- data/test/docs/README.md +14 -0
- data/test/dom/dom.absolute_nodes.rb +40 -0
- data/test/dom/dom.rb +72 -0
- data/test/dom/node.rb +53 -0
- data/test/integration/converter.rb +72 -0
- data/test/integration/parser_factory.rb +28 -0
- data/test/interactive.rb +7 -0
- data/test/js-files/absolute.js +11 -0
- data/test/js-files/comments_in_strings.js +31 -0
- data/test/js-files/core-doc-relative.js +77 -0
- data/test/js-files/core-doc.js +145 -0
- data/test/js-files/nested.js +34 -0
- data/test/js-files/nested_with_strings.js +35 -0
- data/test/js-files/prototype.js +33 -0
- data/test/js-files/simple.js +17 -0
- data/test/js-files/tokens.js +32 -0
- data/test/parser/comments_in_strings.rb +51 -0
- data/test/parser/intelligent_skip_until.rb +110 -0
- data/test/parser/parser.rb +273 -0
- data/test/rspec_helper.rb +23 -0
- data/test/token/handler.rb +136 -0
- data/test/token/tokens.rb +52 -0
- metadata +184 -0
data/test/dom/node.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# ../data.img#1772233:1
|
2
|
+
require_relative '../../lib/dom/dom'
|
3
|
+
require_relative '../../lib/code_object/function'
|
4
|
+
|
5
|
+
describe Dom::Node, "#resolve" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
Dom.clear
|
9
|
+
@o1 = CodeObject::Object.new
|
10
|
+
@o2 = CodeObject::Object.new
|
11
|
+
@o3 = CodeObject::Object.new
|
12
|
+
@o4 = CodeObject::Object.new
|
13
|
+
|
14
|
+
Dom.add_node "Foo.bar" , @o1
|
15
|
+
@o1.add_node ".baz" , @o2
|
16
|
+
@o1.add_node ".baz.bam", @o3
|
17
|
+
@o1.add_node ".baz.poo", @o4
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should find existing node in domtree" do
|
21
|
+
@o4.resolve('.bar').should == @o1
|
22
|
+
@o4.resolve('.baz').should == @o2
|
23
|
+
@o4.resolve('.bam').should == @o3
|
24
|
+
@o4.resolve('.poo').should == @o4
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not find non existing nodes" do
|
28
|
+
@o1.resolve('fofofo').should == nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe Dom::Node, "#qualified_name" do
|
33
|
+
|
34
|
+
before do
|
35
|
+
Dom.clear
|
36
|
+
@o1 = CodeObject::Object.new "bar"
|
37
|
+
@o2 = CodeObject::Object.new "baz"
|
38
|
+
@o3 = CodeObject::Object.new "bam"
|
39
|
+
@o4 = CodeObject::Object.new "poo"
|
40
|
+
|
41
|
+
Dom.add_node "Foo.bar" , @o1
|
42
|
+
@o1.add_node ".baz" , @o2
|
43
|
+
@o1.add_node ".baz.bam", @o3
|
44
|
+
@o1.add_node ".baz.poo", @o4
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should generate correct qualified name from structure" do
|
48
|
+
@o1.qualified_name.should == "Foo.bar"
|
49
|
+
@o2.qualified_name.should == "Foo.bar.baz"
|
50
|
+
@o3.qualified_name.should == "Foo.bar.baz.bam"
|
51
|
+
@o4.qualified_name.should == "Foo.bar.baz.poo"
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative '../../lib/parser/parser'
|
2
|
+
require_relative '../../lib/dom/dom'
|
3
|
+
|
4
|
+
describe CodeObject::Converter, "#to_code_object" do
|
5
|
+
|
6
|
+
context "Parsing tokens.js" do
|
7
|
+
|
8
|
+
before do
|
9
|
+
Dom.clear
|
10
|
+
|
11
|
+
stream = File.read File.expand_path('../../js-files/tokens.js', __FILE__)
|
12
|
+
comments = Parser::Parser.new(stream).parse
|
13
|
+
@objects = comments.map {|comment| comment.to_code_object }.compact
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have built three objects" do
|
17
|
+
@objects.length.should == 3
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "First CodeObject" do
|
21
|
+
subject { @objects[0] }
|
22
|
+
|
23
|
+
it "should be a function named 'say_hello'" do
|
24
|
+
subject.class.should == CodeObject::Function
|
25
|
+
subject.name.should == "say_hello"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a 'public'-token" do
|
29
|
+
subject.token(:public).nil?.should == false
|
30
|
+
subject.token(:public).length.should == 1
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have one param 'foo'" do
|
34
|
+
subject.params.length.should == 1
|
35
|
+
subject.params.first.should_be_named_typed_token("foo", ["String"], "some parameter\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a return value" do
|
39
|
+
subject.returns.length.should == 1
|
40
|
+
subject.returns.first.should_be_typed_token(['String', 'Integer'], "returns a string \"hello\"\n")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "Second CodeObject" do
|
45
|
+
subject { @objects[1] }
|
46
|
+
|
47
|
+
it "should be an Object named 'FOO'" do
|
48
|
+
subject.class.should == CodeObject::Object
|
49
|
+
subject.name.should == "FOO"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "Third CodeObject" do
|
54
|
+
subject { @objects[2] }
|
55
|
+
|
56
|
+
it "should be an Function named 'some_function'" do
|
57
|
+
subject.class.should == CodeObject::Function
|
58
|
+
subject.name.should == "some_function"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should be flagged as constructor" do
|
62
|
+
subject.constructor?.should == true
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should contain one param 'parameter1'" do
|
66
|
+
subject.params.length.should == 1
|
67
|
+
subject.params.first.should_be_named_typed_token("parameter1", ["String"], "The first parameter\n")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../../lib/parser/parser'
|
2
|
+
require_relative '../../lib/dom/dom'
|
3
|
+
|
4
|
+
describe CodeObject::Converter, ".build" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
stream = File.read File.expand_path('../../js-files/tokens.js', __FILE__)
|
8
|
+
@parser = Parser::Parser.new stream
|
9
|
+
@comments = @parser.parse
|
10
|
+
|
11
|
+
@objects = @comments.map {|comment| comment.to_code_object }.compact
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have built three objects" do
|
15
|
+
@objects.length.should == 3
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have built the first object as Function" do
|
19
|
+
@objects.first.class.should == CodeObject::Function
|
20
|
+
@objects.first.name.should == "say_hello"
|
21
|
+
@objects.first.token(:public).nil?.should == false
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have built the second object as Object" do
|
25
|
+
@objects[1].class.should == CodeObject::Object
|
26
|
+
@objects[1].name.should == "FOO"
|
27
|
+
end
|
28
|
+
end
|
data/test/interactive.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
var foo = "/** \
|
2
|
+
* @function Outer \
|
3
|
+
*/"
|
4
|
+
var Outer = function(){
|
5
|
+
|
6
|
+
var bar ="/** \
|
7
|
+
* This is an inner function \
|
8
|
+
* @function .inner\
|
9
|
+
*/"
|
10
|
+
var inner = function() {
|
11
|
+
string = "}}"
|
12
|
+
}
|
13
|
+
|
14
|
+
/* regular expression */
|
15
|
+
var baz = /@function .inner_two/i
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Hello World
|
19
|
+
* @object only_one
|
20
|
+
*/
|
21
|
+
var innerTwo = function() {
|
22
|
+
|
23
|
+
var another_string = "({})\n\n\n)){()[])"
|
24
|
+
|
25
|
+
single_string = '// @object .foo'
|
26
|
+
var foo = {
|
27
|
+
bar: 4,
|
28
|
+
baz: function() {}
|
29
|
+
};
|
30
|
+
}
|
31
|
+
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Man könnte überlegen den Extensions ein Sandbox-Element zu geben, welches diese auch erweitern
|
4
|
+
* können. z.B. könnte damit die Hooks-extension die Sandbox erweitern, ohne dass diese von modulen
|
5
|
+
* erreichbar wären.
|
6
|
+
*
|
7
|
+
* @todo Extensions als Packages: Core.extend('foo.bar') => Core.foo.bar mit foo = foo|| {}
|
8
|
+
* @todo Dependency Check der Extensions
|
9
|
+
* @todo Extensionloader
|
10
|
+
*
|
11
|
+
* @object Core
|
12
|
+
*/
|
13
|
+
var Core = Core || (function(){
|
14
|
+
|
15
|
+
var _extensions = {};
|
16
|
+
|
17
|
+
var core = {
|
18
|
+
|
19
|
+
/**
|
20
|
+
* register new {Core}-extension
|
21
|
+
*
|
22
|
+
* @function .extend
|
23
|
+
*
|
24
|
+
* @param [String] id the id to register the new extension under
|
25
|
+
* @param [Function] constructor a callback function, which acts as
|
26
|
+
* constructor
|
27
|
+
*/
|
28
|
+
extend: function(id, constructor) {
|
29
|
+
|
30
|
+
// Already defined
|
31
|
+
if(!!core[id]) {
|
32
|
+
core.logger.log("Info: Overwriting '"+id+"'. It is already defined.");
|
33
|
+
}
|
34
|
+
|
35
|
+
var ext = constructor();
|
36
|
+
if(!!ext) {
|
37
|
+
core[id] = ext;
|
38
|
+
_extensions[id] = ext;
|
39
|
+
} else {
|
40
|
+
core.logger.log("Info: Constructor of '"+id+"' did not return a valid value.");
|
41
|
+
}
|
42
|
+
},
|
43
|
+
|
44
|
+
/**
|
45
|
+
* List all registered {Core.extension extensions}
|
46
|
+
*
|
47
|
+
* @function .extensions
|
48
|
+
*
|
49
|
+
* @return [Array] all registered extensions
|
50
|
+
*/
|
51
|
+
extensions: function() {
|
52
|
+
return _extensions;
|
53
|
+
},
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Adds minimal logging functionality to {Core}
|
57
|
+
*
|
58
|
+
* @object .logger
|
59
|
+
*/
|
60
|
+
logger: {
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Logs a message if the console is present. Can be extended with a custom {Core.extension}.
|
64
|
+
*
|
65
|
+
* @function .log
|
66
|
+
* @param [String] msg The message to log
|
67
|
+
*/
|
68
|
+
log: function(msg) {
|
69
|
+
if(!!window.console) {
|
70
|
+
window.console.log(msg);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
return core;
|
77
|
+
})();
|
@@ -0,0 +1,145 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Man könnte überlegen den Extensions ein Sandbox-Element zu geben, welches diese auch erweitern
|
4
|
+
* können. z.B. könnte damit die Hooks-extension die Sandbox erweitern, ohne dass diese von modulen
|
5
|
+
* erreichbar wären.
|
6
|
+
*
|
7
|
+
* Noch eine Überschrift
|
8
|
+
* =====================
|
9
|
+
* Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt
|
10
|
+
* ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
|
11
|
+
* dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
|
12
|
+
* sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
13
|
+
* invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et
|
14
|
+
*
|
15
|
+
* if(!!core[id]) {
|
16
|
+
* core.logger.log("Info: Overwriting '"+id+"'. It is already defined.");
|
17
|
+
* }
|
18
|
+
*
|
19
|
+
*
|
20
|
+
* Justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
|
21
|
+
* dolor sit amet.
|
22
|
+
*
|
23
|
+
* Testüberschrift
|
24
|
+
* ---------------
|
25
|
+
* Dies ist nur ein Absatz in **Markdown**, um zu testen, ob dies funnktioniert.
|
26
|
+
*
|
27
|
+
* Core contains a simple {Core.logger logger} which only supports one functionality {.log}.
|
28
|
+
*
|
29
|
+
* @todo Extensions als Packages: Core.extend('foo.bar') => Core.foo.bar mit foo = foo|| {}
|
30
|
+
* @todo Dependency Check der Extensions
|
31
|
+
* @todo Extensionloader
|
32
|
+
*
|
33
|
+
* @note something to note, which is really important, because im testing the style of `@note-tokens`
|
34
|
+
* var foo = {
|
35
|
+
* bar: 4
|
36
|
+
* }
|
37
|
+
*
|
38
|
+
* @deprecated since 1.0 - because this is not as cool, as i suspected first.
|
39
|
+
*
|
40
|
+
* @warn don't use without parental advise
|
41
|
+
*
|
42
|
+
* @author Jonathan Brachthäuser
|
43
|
+
* @version 1.2.245
|
44
|
+
*
|
45
|
+
* @example foobar
|
46
|
+
* This is just a stupid test
|
47
|
+
*
|
48
|
+
* @object Core
|
49
|
+
*/
|
50
|
+
var Core = Core || (function(){
|
51
|
+
|
52
|
+
var _extensions = {};
|
53
|
+
|
54
|
+
var core = {
|
55
|
+
|
56
|
+
/**
|
57
|
+
* register new {Core.extensions}
|
58
|
+
*
|
59
|
+
* @function Core.extend
|
60
|
+
*
|
61
|
+
* @param [String] id the id to register the new {Core.extensionss extension} under
|
62
|
+
* @param [Function] constructor a callback function, which acts as
|
63
|
+
* constructor for {Core.extensions}
|
64
|
+
* @param settings
|
65
|
+
* [String] name the name of the extension
|
66
|
+
* [Number] pos the position to put the extension to (Defaults to 0)
|
67
|
+
* [String] color the background-color of the extension
|
68
|
+
*
|
69
|
+
* @return [Core.logger] the constructed extension
|
70
|
+
*
|
71
|
+
*
|
72
|
+
* @example Testextension
|
73
|
+
* Core.extend('testextension', function() {
|
74
|
+
* return {};
|
75
|
+
* });
|
76
|
+
*/
|
77
|
+
extend: function(id, constructor) {
|
78
|
+
|
79
|
+
// Already defined
|
80
|
+
if(!!core[id]) {
|
81
|
+
core.logger.log("Info: Overwriting '"+id+"'. It is already defined.");
|
82
|
+
}
|
83
|
+
|
84
|
+
var ext = constructor();
|
85
|
+
if(!!ext) {
|
86
|
+
core[id] = ext;
|
87
|
+
_extensions[id] = ext;
|
88
|
+
} else {
|
89
|
+
core.logger.log("Info: Constructor of '"+id+"' did not return a valid value.");
|
90
|
+
}
|
91
|
+
},
|
92
|
+
|
93
|
+
/**
|
94
|
+
* List all registered {Core.extensions extensions}
|
95
|
+
*
|
96
|
+
* @function Core.extensions
|
97
|
+
*
|
98
|
+
* @return [Array] all registered extensions
|
99
|
+
*/
|
100
|
+
extensions: function() {
|
101
|
+
return _extensions;
|
102
|
+
},
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Adds minimal logging functionality to {Core}
|
106
|
+
*
|
107
|
+
* @object Core.logger
|
108
|
+
*/
|
109
|
+
logger: {
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Logs a message if the console is present
|
113
|
+
*
|
114
|
+
* @function Core.logger.log
|
115
|
+
*
|
116
|
+
* @overload log(msg)
|
117
|
+
* @param [String] msg The message to log
|
118
|
+
*
|
119
|
+
* @overload log(level, msg)
|
120
|
+
*
|
121
|
+
*/
|
122
|
+
log: function(msg) {
|
123
|
+
if(!!window.console) {
|
124
|
+
window.console.log(msg);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
},
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Config Object for Core
|
131
|
+
* @object Core.properties
|
132
|
+
*
|
133
|
+
* @prop [Boolean] logging turns internal logging on and off
|
134
|
+
* @prop [Numeric] maximalExtensions limits the maximum extensions count
|
135
|
+
* @prop [Boolean] autostart should Core start on Application-start?
|
136
|
+
*/
|
137
|
+
properties: {
|
138
|
+
logging: true,
|
139
|
+
maximalExtensions: 4,
|
140
|
+
autostart: true
|
141
|
+
}
|
142
|
+
};
|
143
|
+
|
144
|
+
return core;
|
145
|
+
})();
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* @function Outer
|
3
|
+
*/
|
4
|
+
var Outer = function(){
|
5
|
+
|
6
|
+
/**
|
7
|
+
* This is an inner function
|
8
|
+
* @function .inner
|
9
|
+
*/
|
10
|
+
var inner = function() {
|
11
|
+
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
/**
|
16
|
+
* This is a second inner function
|
17
|
+
* @function .inner_two
|
18
|
+
*/
|
19
|
+
var innerTwo = function() {
|
20
|
+
|
21
|
+
|
22
|
+
/**
|
23
|
+
* And again, here is a inner function
|
24
|
+
* @object .foo
|
25
|
+
*/
|
26
|
+
var foo = {
|
27
|
+
bar: 4,
|
28
|
+
baz: function() {}
|
29
|
+
};
|
30
|
+
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
};
|