docjs 0.1.5 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +11 -14
- data/README.md +27 -18
- data/docjs.gemspec +3 -3
- data/docs/PATTERNS.md +2 -2
- data/docs/guides/CUSTOMIZE.md +125 -28
- data/docs/guides/TRY.md +2 -1
- data/docs/guides/USE.md +139 -89
- data/lib/code_object/base.rb +0 -10
- data/lib/code_object/converter.rb +3 -3
- data/lib/dom/dom.rb +24 -21
- data/lib/dom/no_doc.rb +2 -2
- data/lib/dom/node.rb +25 -26
- data/lib/helper/helper.rb +161 -36
- data/lib/helper/linker.rb +47 -11
- data/lib/parser/comment.rb +9 -8
- data/lib/parser/comment_parser.rb +9 -10
- data/lib/parser/parser.rb +4 -6
- data/lib/processor.rb +1 -1
- data/lib/token/handler.rb +13 -0
- data/lib/token/token.rb +3 -4
- data/templates/generators/api_pages_generator.rb +0 -4
- data/templates/generators/docs_generator.rb +1 -2
- data/templates/resources/css/application.css +92 -17
- data/templates/resources/js/jcore.js +37 -2
- data/templates/resources/scss/_header.scss +4 -5
- data/templates/resources/scss/_helpers.scss +6 -0
- data/templates/resources/scss/_highlighter.scss +5 -8
- data/templates/resources/scss/_tooltip.scss +2 -2
- data/templates/resources/scss/application.scss +6 -4
- data/templates/tokens/tokens.rb +47 -9
- data/templates/types/function.rb +19 -57
- data/templates/types/object.rb +3 -10
- data/templates/types/prototype.rb +1 -1
- data/test/docs/README.md +35 -14
- metadata +3 -7
- data/docs/ARCHITECTURE.md +0 -0
- data/docs/CONCEPT.md +0 -80
- data/docs/DOCUMENTATION.md +0 -39
- data/templates/views/index.html.erb +0 -0
@@ -69,7 +69,27 @@ var J = J || jCore;
|
|
69
69
|
};
|
70
70
|
|
71
71
|
/**
|
72
|
-
* @function
|
72
|
+
* @function J.create
|
73
|
+
*
|
74
|
+
* @example
|
75
|
+
* J.create("Person", {
|
76
|
+
* constructor: function(name) {
|
77
|
+
* this.name = name;
|
78
|
+
* },
|
79
|
+
* say_name: function() { return this.name; }
|
80
|
+
* });
|
81
|
+
*
|
82
|
+
* @example Using revealing module pattern
|
83
|
+
* J.create("Person", {
|
84
|
+
* constructor: function(name) {
|
85
|
+
* return {
|
86
|
+
* say_name: function() { return name; }
|
87
|
+
* };
|
88
|
+
* }
|
89
|
+
* });
|
90
|
+
*
|
91
|
+
* @example Extending an object
|
92
|
+
* J.create("Student", Person
|
73
93
|
*
|
74
94
|
* Also mitigates the problem of using 'new' to create new instances. After
|
75
95
|
* creating the class Foo with creat, the following versions of instantiation
|
@@ -78,7 +98,22 @@ var J = J || jCore;
|
|
78
98
|
* Foo("bar");
|
79
99
|
* new Foo("bar");
|
80
100
|
*
|
81
|
-
* @overload
|
101
|
+
* @overload
|
102
|
+
* Creates a class called `path` and extends it with the given options
|
103
|
+
*
|
104
|
+
* @param [String] path
|
105
|
+
* @param options
|
106
|
+
* All options will be added as property to the object
|
107
|
+
* [Function] constructor The constructor of the class, which will be called, when
|
108
|
+
* instantiating a new object
|
109
|
+
*
|
110
|
+
* @overload
|
111
|
+
* Creates a class `path`, that inherits from `parent` and will be extended with the given
|
112
|
+
* options
|
113
|
+
*
|
114
|
+
* @param [String] path
|
115
|
+
* @param [Object] parent
|
116
|
+
* @param [Hash] options (see other overload)
|
82
117
|
*/
|
83
118
|
J.create = function(path, inherited, options) {
|
84
119
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
}
|
35
35
|
|
36
36
|
input#search {
|
37
|
-
border-radius
|
37
|
+
@include border-radius($radius);
|
38
38
|
outline: none;
|
39
39
|
padding: 0.2em 0.5em;
|
40
40
|
}
|
@@ -48,8 +48,8 @@
|
|
48
48
|
@include float(left);
|
49
49
|
|
50
50
|
/* rounded corners */
|
51
|
-
&:first-child a { border-radius
|
52
|
-
&:last-child a { border-radius
|
51
|
+
&:first-child a { @include border-radius(0 0 0 $radius); }
|
52
|
+
&:last-child a { @include border-radius(0 0 $radius 0); }
|
53
53
|
}
|
54
54
|
|
55
55
|
a {
|
@@ -87,9 +87,8 @@
|
|
87
87
|
|
88
88
|
> ul {
|
89
89
|
@include scrollbars;
|
90
|
-
|
90
|
+
@include border-radius($radius);
|
91
91
|
border: 1px solid #eee;
|
92
|
-
border-radius: $radius;
|
93
92
|
padding: 0; margin: 0;
|
94
93
|
|
95
94
|
overflow: hidden;
|
@@ -85,6 +85,12 @@ $golden_ratio: 1.618;
|
|
85
85
|
}
|
86
86
|
}
|
87
87
|
|
88
|
+
@mixin border-radius($radius) {
|
89
|
+
-moz-border-radius: $radius; /* Firefox */
|
90
|
+
-webkit-border-radius: $radius; /* Safari, Chrome */
|
91
|
+
border-radius: $radius; /* CSS3 */
|
92
|
+
}
|
93
|
+
|
88
94
|
@mixin float($direction) {
|
89
95
|
display: block;
|
90
96
|
float: $direction;
|
@@ -1,11 +1,7 @@
|
|
1
|
-
@mixin line-height-fix() {
|
2
|
-
font-size: 9pt;
|
3
|
-
line-height: 1.4em;
|
4
|
-
}
|
5
|
-
|
6
1
|
code.source, code.example {
|
7
2
|
@include code-box;
|
8
|
-
|
3
|
+
font-size: 9pt;
|
4
|
+
line-height: 1.6em;
|
9
5
|
padding: 0.5em;
|
10
6
|
margin-bottom: $element-margin;
|
11
7
|
}
|
@@ -34,7 +30,7 @@ code.source, code.example {
|
|
34
30
|
text-align: right;
|
35
31
|
|
36
32
|
.line {
|
37
|
-
|
33
|
+
height: 1.6em;
|
38
34
|
}
|
39
35
|
}
|
40
36
|
|
@@ -43,7 +39,8 @@ code.source, code.example {
|
|
43
39
|
width: 100%;
|
44
40
|
|
45
41
|
.line {
|
46
|
-
|
42
|
+
height: 1.6em;
|
43
|
+
padding: 0 0.5em;
|
47
44
|
&:hover { background: #f5f5f5; }
|
48
45
|
}
|
49
46
|
}
|
@@ -2,7 +2,8 @@
|
|
2
2
|
/*@include double-border(1px, #fff, #ccc);*/
|
3
3
|
@include gradient(#333, #555);
|
4
4
|
@include reset-fonts;
|
5
|
-
|
5
|
+
@include border-radius($radius/2);
|
6
|
+
|
6
7
|
display: none;
|
7
8
|
position: absolute;
|
8
9
|
padding: 0.5em;
|
@@ -12,7 +13,6 @@
|
|
12
13
|
font-size: 9pt;
|
13
14
|
color: #eee;
|
14
15
|
border: 1px solid #fff;
|
15
|
-
border-radius: $radius/2;
|
16
16
|
box-shadow: 0 0 10px rgba(0,0,0,0.15);
|
17
17
|
|
18
18
|
a {
|
@@ -86,11 +86,12 @@ $element-margin: 1.33em;
|
|
86
86
|
@if $terminal == true {
|
87
87
|
@include terminal;
|
88
88
|
}
|
89
|
+
@include border-radius($radius/2);
|
89
90
|
display: block;
|
90
91
|
background: $color;
|
91
92
|
border: 1px solid darken($color, 8%);
|
92
93
|
color: darken($fontcolor, 40%);
|
93
|
-
|
94
|
+
|
94
95
|
padding: 0.4em 1em;
|
95
96
|
}
|
96
97
|
|
@@ -140,10 +141,11 @@ div#main {
|
|
140
141
|
@include page-center;
|
141
142
|
@include typography;
|
142
143
|
@include clearfix;
|
144
|
+
@include border-radius(10px 10px 0 0);
|
143
145
|
|
144
146
|
margin-top: -$page-indent;
|
145
147
|
|
146
|
-
|
148
|
+
|
147
149
|
box-shadow: 0px -0px 5px rgba(0,0,0,0.1);
|
148
150
|
|
149
151
|
border-top: 1px solid #eee;
|
@@ -169,10 +171,10 @@ div#main nav.sidebar {
|
|
169
171
|
|
170
172
|
@include float(right);
|
171
173
|
@include code-box;
|
174
|
+
@include border-radius(5px);
|
172
175
|
|
173
176
|
margin: 2*$page-padding 0 $box-spacing $box-spacing;
|
174
|
-
padding: 0;
|
175
|
-
border-radius: 5px;
|
177
|
+
padding: 0;
|
176
178
|
font-size: 8pt;
|
177
179
|
color: #999;
|
178
180
|
|
data/templates/tokens/tokens.rb
CHANGED
@@ -1,19 +1,50 @@
|
|
1
1
|
module Token::Handler
|
2
2
|
|
3
|
-
|
4
|
-
register :
|
3
|
+
# @group Metainfo-Tokens
|
4
|
+
register :author, :area => :sidebar
|
5
|
+
register :public, :area => :sidebar
|
5
6
|
register :private, :area => :sidebar
|
6
7
|
register :version, :area => :sidebar
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
# @group Notification Tokens
|
10
10
|
register :deprecated, :area => :notification
|
11
|
-
register :todo,
|
12
|
-
register :note,
|
13
|
-
register :warn,
|
14
|
-
|
15
|
-
|
11
|
+
register :todo, :area => :notification
|
12
|
+
register :note, :area => :notification
|
13
|
+
register :warn, :area => :notification
|
14
|
+
|
15
|
+
# @group Function specific Tokens
|
16
|
+
|
17
|
+
# We want to support either named-typed-tokens like
|
18
|
+
# @param [Foo] barname some description
|
19
|
+
#
|
20
|
+
# or multiline tokens like:
|
21
|
+
# @param configs
|
22
|
+
# Some configuration Object with following properties:
|
23
|
+
# [String] foo some string
|
24
|
+
# [Bar] bar and another one
|
25
|
+
register :param,
|
26
|
+
:area => :none,
|
27
|
+
:description => "Token for Function-Parameters like '@param [String] name your name'" do |tokenklass, content|
|
28
|
+
|
29
|
+
# it's @param [String] name some content
|
30
|
+
if content.lines.first.match Token::Handler::TOKEN_W_TYPE_NAME
|
31
|
+
self.add_token Token::Handler.apply(:typed_with_name, Token::Token::ParamToken, content)
|
32
|
+
|
33
|
+
# it maybe a multiline
|
34
|
+
else
|
35
|
+
self.add_token Token::Handler.apply(:named_nested_shorthand, Token::Token::ParamToken, content)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
register :return, :handler => :typed, :area => :none, :description => "Returnvalue of a Function"
|
40
|
+
register :throws, :handler => :typed
|
16
41
|
|
42
|
+
# MethodAlias
|
43
|
+
register :method, :handler => :noop, :area => :none, :type => CodeObject::Function
|
44
|
+
|
45
|
+
# ConstructorAlias
|
46
|
+
register(:constructor, :type => CodeObject::Function) { |token, content| @constructor = true }
|
47
|
+
|
17
48
|
# Every @overload can contain **text-documentation**, **@param**- and **@return**-tokens
|
18
49
|
#
|
19
50
|
# It may look like:
|
@@ -62,6 +93,9 @@ module Token::Handler
|
|
62
93
|
self.add_token token_klass.new :content => documentation.join("\n"), :children => children, :name => self.name
|
63
94
|
end
|
64
95
|
|
96
|
+
|
97
|
+
# @group Miscellaneous Tokens
|
98
|
+
|
65
99
|
# Example:
|
66
100
|
# @event MyCustomEvent
|
67
101
|
# This event will be triggered, if something special happens. The registered handler will be
|
@@ -69,5 +103,9 @@ module Token::Handler
|
|
69
103
|
# [Object] obj This object
|
70
104
|
# [String] msg Some message
|
71
105
|
register :event, :area => :body, :handler => :named_nested_shorthand
|
106
|
+
register :example, :template => :examples, :handler => :named_multiline
|
107
|
+
register :prop, :handler => :typed_with_name
|
108
|
+
register :see, :area => :footnote
|
72
109
|
|
73
110
|
end
|
111
|
+
|
data/templates/types/function.rb
CHANGED
@@ -1,63 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@constructor || false
|
10
|
-
end
|
11
|
-
|
12
|
-
# @todo i need a @prototype token in object
|
13
|
-
def prototype
|
14
|
-
children[:prototype]
|
15
|
-
end
|
1
|
+
class CodeObject::Function < CodeObject::Object
|
2
|
+
|
3
|
+
token_reader :params, :param
|
4
|
+
token_reader :returns, :return
|
5
|
+
|
6
|
+
def constructor?
|
7
|
+
@constructor || false
|
8
|
+
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
# @todo i need a @prototype token in object
|
11
|
+
def prototype
|
12
|
+
children[:prototype]
|
13
|
+
end
|
14
|
+
|
15
|
+
def display_name
|
16
|
+
@name + '()'
|
17
|
+
end
|
22
18
|
|
23
|
-
end
|
19
|
+
end
|
24
20
|
|
25
21
|
Token::Handler.register :function,
|
26
22
|
:handler => :noop,
|
27
23
|
:area => :none,
|
28
|
-
:
|
29
|
-
|
30
|
-
|
31
|
-
# We want to support either named-typed-tokens like
|
32
|
-
# @param [Foo] barname some description
|
33
|
-
#
|
34
|
-
# or multiline tokens like:
|
35
|
-
# @param configs
|
36
|
-
# Some configuration Object with following properties:
|
37
|
-
# [String] foo some string
|
38
|
-
# [Bar] bar and another one
|
39
|
-
#
|
40
|
-
# @note this can also be utilized for JavaScript-Event-Triggers or Callbacks with Parameters
|
41
|
-
Token::Handler.register :param, :area => :none, :description => "Token for Function-Parameters like '@param [String] name your name'" do |tokenklass, content|
|
42
|
-
|
43
|
-
# it's @param [String] name some content
|
44
|
-
if content.lines.first.match Token::Handler::TOKEN_W_TYPE_NAME
|
45
|
-
self.add_token Token::Handler.apply(:typed_with_name, Token::Token::ParamToken, content)
|
46
|
-
|
47
|
-
# it maybe a multiline
|
48
|
-
else
|
49
|
-
self.add_token Token::Handler.apply(:named_nested_shorthand, Token::Token::ParamToken, content)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
Token::Handler.register :return, :handler => :typed, :area => :none, :description => "Returnvalue of a Function"
|
55
|
-
Token::Handler.register :throws, :handler => :typed
|
56
|
-
|
57
|
-
# MethodAlias
|
58
|
-
class CodeObject::Method < CodeObject::Function; end
|
59
|
-
Token::Handler.register :method, :handler => :noop, :area => :none
|
60
|
-
|
61
|
-
# ConstructorAlias
|
62
|
-
class CodeObject::Constructor < CodeObject::Function; end
|
63
|
-
Token::Handler.register(:constructor) { |token, content| @constructor = true }
|
24
|
+
:type => CodeObject::Function,
|
25
|
+
:description => "Type-Token to categorize all kind of JavaScript-Functions"
|
data/templates/types/object.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Object < CodeObject::Base
|
4
|
-
|
5
|
-
token_reader :props, :prop
|
6
|
-
|
7
|
-
end
|
8
|
-
|
1
|
+
class CodeObject::Object < CodeObject::Base
|
2
|
+
token_reader :props, :prop
|
9
3
|
end
|
10
4
|
|
11
|
-
Token::Handler.register :object, :handler => :noop, :area => :none
|
12
|
-
Token::Handler.register :prop, :handler => :typed_with_name
|
5
|
+
Token::Handler.register :object, :handler => :noop, :area => :none, :type => CodeObject::Object
|
data/test/docs/README.md
CHANGED
@@ -1,14 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
Beautiful, flexible JavaScript Documentation
|
2
|
+
============================================
|
3
|
+
Doc.js automatically creates beautiful documentation from your JavaScript-Source.
|
4
|
+
|
5
|
+
Features
|
6
|
+
--------
|
7
|
+
- One command to install
|
8
|
+
- Use markdown in your documentation
|
9
|
+
- Easy to customize (Create your own DSL in a sec!)
|
10
|
+
- Nice and clean default template
|
11
|
+
- Integrates well with your existing deployment
|
12
|
+
- For ruby lovers - it's written in ruby
|
13
|
+
|
14
|
+
Installation
|
15
|
+
------------
|
16
|
+
If you have Ruby 1.9 and rubygems installed you only need to type
|
17
|
+
|
18
|
+
gem install docjs
|
19
|
+
|
20
|
+
That's Your Part
|
21
|
+
----------------
|
22
|
+
Because Doc.js basically is language unaware, you have to tell it what to do. This example shows how
|
23
|
+
your documentation could look like
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @function medianight.create_poster
|
27
|
+
*
|
28
|
+
* This function creates a poster, which can be used at the MediaNight
|
29
|
+
* @param [String] term Something like "SS2011"
|
30
|
+
* @param [Numeric] dpi The target-resolution of the poster
|
31
|
+
* @return [Poster] The finished poster
|
32
|
+
*/
|
33
|
+
medianight.create_poster = function(term, dpi) {
|
34
|
+
...
|
35
|
+
}
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: docjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: "0.2"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Jonathan Brachth\xC3\xA4user"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-28 00:00:00 +02:00
|
14
14
|
default_executable: bin/docjs
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
version: "0"
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
|
-
description: Create
|
38
|
+
description: Create beautiful Javascript documentations with this ruby-gem. It's pretty easy to customize and add your own tokens/DSL.
|
39
39
|
email: jonathan@b-studios.de
|
40
40
|
executables:
|
41
41
|
- docjs
|
@@ -49,9 +49,6 @@ files:
|
|
49
49
|
- bin/docjs
|
50
50
|
- bin/docjs.rb
|
51
51
|
- docjs.gemspec
|
52
|
-
- docs/ARCHITECTURE.md
|
53
|
-
- docs/CONCEPT.md
|
54
|
-
- docs/DOCUMENTATION.md
|
55
52
|
- docs/PATTERNS.md
|
56
53
|
- docs/guides/CUSTOMIZE.md
|
57
54
|
- docs/guides/TRY.md
|
@@ -126,7 +123,6 @@ files:
|
|
126
123
|
- templates/views/doc_page.html.erb
|
127
124
|
- templates/views/function/_detail.html.erb
|
128
125
|
- templates/views/function/index.html.erb
|
129
|
-
- templates/views/index.html.erb
|
130
126
|
- templates/views/layout/application.html.erb
|
131
127
|
- templates/views/layout/json.html.erb
|
132
128
|
- templates/views/object/index.html.erb
|