docjs 0.1.2 → 0.1.3

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.
Files changed (39) hide show
  1. data/README.md +7 -5
  2. data/bin/docjs +33 -8
  3. data/bin/docjs.rb +239 -0
  4. data/docjs.gemspec +2 -2
  5. data/lib/boot.rb +5 -3
  6. data/lib/code_object/base.rb +1 -0
  7. data/lib/code_object/function.rb +21 -37
  8. data/lib/code_object/object.rb +1 -1
  9. data/lib/helper/helper.rb +16 -3
  10. data/lib/helper/linker.rb +5 -2
  11. data/lib/parser/parser.rb +20 -6
  12. data/lib/token/container.rb +0 -1
  13. data/lib/token/handler.rb +46 -6
  14. data/lib/token/token.rb +3 -2
  15. data/templates/helpers/template.rb +15 -5
  16. data/templates/resources/css/application.css +65 -14
  17. data/templates/resources/js/application.js +33 -11
  18. data/templates/resources/js/regexpx.js +652 -0
  19. data/templates/resources/js/shBrushJScript.js +55 -0
  20. data/templates/resources/js/shCore.js +1596 -0
  21. data/templates/resources/scss/_header.scss +2 -1
  22. data/templates/resources/scss/_helpers.scss +6 -6
  23. data/templates/resources/scss/_highlighter.scss +70 -0
  24. data/templates/resources/scss/application.scss +8 -8
  25. data/templates/tokens/tokens.rb +55 -4
  26. data/templates/views/function/_detail.html.erb +1 -1
  27. data/templates/views/function/index.html.erb +16 -4
  28. data/templates/views/layout/application.html.erb +5 -5
  29. data/templates/views/layout/json.html.erb +3 -3
  30. data/templates/views/object/index.html.erb +3 -3
  31. data/templates/views/tokens/_default.html.erb +4 -2
  32. data/templates/views/tokens/_default_token.html.erb +2 -1
  33. data/templates/views/tokens/_example.html.erb +1 -1
  34. data/templates/views/tokens/_overload.html.erb +12 -0
  35. data/test/interactive.rb +5 -2
  36. data/test/js-files/core-doc.js +20 -12
  37. data/test/parser/intelligent_skip_until.rb +1 -1
  38. data/test/parser/parser.rb +3 -6
  39. metadata +8 -2
@@ -92,7 +92,8 @@
92
92
  border-radius: $radius;
93
93
  padding: 0; margin: 0;
94
94
 
95
- overflow-y: scroll;
95
+ overflow: hidden;
96
+ /*overflow-y: scroll;*/
96
97
  }
97
98
  }
98
99
 
@@ -1,11 +1,11 @@
1
1
  $golden_ratio: 1.618;
2
2
 
3
- @mixin transition($property, $time) {
4
- -webkit-transition: $property $time ease-in-out;
5
- -moz-transition: $property $time ease-in-out;
6
- -o-transition: $property $time ease-in-out;
7
- -ms-transition: $property $time ease-in-out;
8
- transition: $property $time ease-in-out;
3
+ @mixin transition($property, $time, $transition: ease-in-out) {
4
+ -webkit-transition: $property $time $transition;
5
+ -moz-transition: $property $time $transition;
6
+ -o-transition: $property $time $transition;
7
+ -ms-transition: $property $time $transition;
8
+ transition: $property $time $transition;
9
9
  }
10
10
 
11
11
  /* Kudos to http://www.colorzilla.com/gradient-editor/ */
@@ -0,0 +1,70 @@
1
+ @mixin line-height-fix() {
2
+ font-size: 9pt;
3
+ line-height: 1.4em;
4
+ }
5
+
6
+ code.source, code.example {
7
+ @include code-box;
8
+ @include line-height-fix;
9
+ padding: 0.5em;
10
+ margin-bottom: $element-margin;
11
+ }
12
+
13
+ /* js-replaced version */
14
+ .syntaxhighlighter {
15
+ @extend code.source;
16
+
17
+ /* revert no-js settings */
18
+ background: #fff;
19
+ padding: 0;
20
+
21
+ table {
22
+ width: 100%;
23
+
24
+ td {
25
+ border: 1px solid #fff; /* rebuild double-border effect */
26
+ }
27
+ }
28
+
29
+ .gutter {
30
+ background-color: $codegrey;
31
+ color: darken($codegrey, 20%);
32
+ padding: 0.5em;
33
+ border-right: 1px solid darken($codegrey, 10%);
34
+ text-align: right;
35
+
36
+ .line {
37
+ @include line-height-fix;
38
+ }
39
+ }
40
+
41
+ .code {
42
+ padding: 0.5em 0;
43
+ width: 100%;
44
+
45
+ .line {
46
+ padding: 0 0.5em;
47
+ &:hover { background: #f5f5f5; }
48
+ }
49
+ }
50
+
51
+ &.example {
52
+ background: #f3f3f3;
53
+ .line {
54
+ padding-left: 1em;
55
+ &:hover { background: #efefef; }
56
+ }
57
+ }
58
+
59
+ /* syntaxhighlighting settings */
60
+ .spaces {}
61
+ .keyword { font-weight: bold; }
62
+ .plain {}
63
+ .string { color: $orange; }
64
+ .comments { color: #998; font-style: italic; }
65
+ .comments a { color: #998; }
66
+ .variable {}
67
+ .functions {}
68
+ .constants { color: $blue; }
69
+ .script {}
70
+ }
@@ -78,6 +78,7 @@ $element-margin: 1.33em;
78
78
  @mixin code-box() {
79
79
  @include double-border(1px, #ffffff, darken($codegrey, 10%));
80
80
  @include terminal;
81
+ display: block;
81
82
  background: $codegrey;
82
83
  }
83
84
 
@@ -96,6 +97,7 @@ $element-margin: 1.33em;
96
97
  @import 'header';
97
98
  @import 'footer';
98
99
  @import 'tooltip';
100
+ @import 'highlighter';
99
101
 
100
102
  body, select, input, textarea {
101
103
  @include reset-fonts;
@@ -248,13 +250,6 @@ div#main .body {
248
250
  }
249
251
  }
250
252
 
251
- code.block {
252
- @include code-box;
253
- display: block;
254
- padding: 0.5em;
255
- color: #555;
256
- margin-bottom: $element-margin;
257
- }
258
253
 
259
254
  .section {
260
255
  padding-bottom: $box-spacing;
@@ -292,7 +287,7 @@ div#main .body {
292
287
  }
293
288
  }
294
289
 
295
- .source {
290
+ h3.source {
296
291
  @extend .icon.arrow_down;
297
292
  cursor: pointer;
298
293
  &.collapsed {
@@ -327,6 +322,11 @@ div#main .body {
327
322
  }
328
323
  }
329
324
  }
325
+
326
+
327
+ .overload {
328
+ margin-bottom: 3em;
329
+ }
330
330
  }
331
331
 
332
332
  div#main .notification {
@@ -13,10 +13,61 @@ module Token::Handler
13
13
  register :warn, :area => :notification
14
14
 
15
15
  register :example, :template => 'examples', :handler => :named_multiline
16
-
17
- register :overload, :area => :none do |token, content|
18
-
19
-
16
+
17
+ # Every @overload can contain **text-documentation**, **@param**- and **@return**-tokens
18
+ #
19
+ # It may look like:
20
+ #
21
+ # @overload
22
+ # This is the documentation for a overload
23
+ # It can have multiple lines of docs
24
+ #
25
+ # @param [String] foo please notice the optional empty
26
+ # line above and the linebreak of this param
27
+ # @return [Array] something special will be returned
28
+ #
29
+ # Followed by some more random documentation
30
+ #
31
+ # If no return should be possible, the more simple :named_nested_shorthand handler could be used...
32
+ register :overload, :area => :none do |token_klass, content|
33
+
34
+ documentation = []
35
+ children = []
36
+
37
+ # First remove linebreaks with 2-times intendation
38
+ content.gsub!(/\n((?!\n)\s){2}/, ' ')
39
+
40
+ # Then we take every line and analyse it
41
+ content.split(/\n/).each do |line|
42
+
43
+
44
+ # We utilize Parser's Tokenline-Regexp here
45
+ matches = Parser::TOKENLINE.match(line)
46
+
47
+ if matches.nil?
48
+ documentation << line
49
+
50
+ else
51
+ name, content = matches.captures
52
+
53
+ if name == 'param'
54
+ children << Token::Handler.apply(:typed_with_name, Token::Token::ParamToken, content)
55
+ elsif name == 'return'
56
+ children << Token::Handler.apply(:typed, Token::Token::ReturnToken, content)
57
+ end
58
+
59
+ end
60
+ end
61
+
62
+ self.add_token token_klass.new :content => documentation.join("\n"), :children => children, :name => self.name
20
63
  end
21
64
 
65
+ # Example:
66
+ # @event MyCustomEvent
67
+ # This event will be triggered, if something special happens. The registered handler will be
68
+ # called with the following parameters:
69
+ # [Object] obj This object
70
+ # [String] msg Some message
71
+ register :event, :area => :body, :handler => :named_nested_shorthand
72
+
22
73
  end
@@ -4,5 +4,5 @@
4
4
  <%= render_tokens :of => detail, :in => :body %>
5
5
 
6
6
  <h3 class="source">Source</h3>
7
- <%= code detail.source %>
7
+ <%= code detail.source, :firstline => detail.line_start, :class => "source" %>
8
8
  </section>
@@ -20,7 +20,7 @@
20
20
  <div class="method-list">
21
21
  <h3>Methods</h3>
22
22
  <ul>
23
- <% @methods.each do |child| %>
23
+ <% @methods.sort{|a,b| a.name <=> b.name }.each do |child| %>
24
24
  <li><%= link_to child %></li>
25
25
  <% end %>
26
26
  </ul>
@@ -41,12 +41,24 @@
41
41
  <%= to_html @function.docs %>
42
42
 
43
43
  <!--span class="flag">constructor</span-->
44
+
45
+ <%= render_tokens :of => @function, :in => :body %>
44
46
 
45
- <h2 class="signature"><%= signature @function %></h2>
46
- <%= render_tokens :of => @function, :in => :body %>
47
+ <%# if it has overloads, we need another template %>
48
+ <% if @function.tokens[:overload].nil? %>
49
+
50
+ <h2 class="signature"><%= signature @function %></h2>
51
+ <%= render :partial => 'tokens/default', :locals => { :tokens => @function.params } %>
52
+ <%= render :partial => 'tokens/default', :locals => { :tokens => @function.returns } %>
53
+
54
+ <% else %>
55
+
56
+ <%= render :partial => 'tokens/overload', :collection => @function.tokens[:overload] %>
57
+
58
+ <% end %>
47
59
 
48
60
  <h3 class="source">Source</h3>
49
- <%= code @function.source %>
61
+ <%= code @function.source, :firstline => @function.line_start, :class => "source" %>
50
62
 
51
63
  </div>
52
64
 
@@ -58,16 +58,16 @@
58
58
  </div>
59
59
  <footer id="footer">
60
60
  <div class="wrapper">
61
- Documentation created automagically with <a href="http://www.github.com/b-studios/jsdoc">JSDoc for Ruby</a>.
61
+ Documentation created automagically with <a href="http://www.github.com/b-studios/doc.js">Doc.js for ruby</a>.
62
62
  </div>
63
63
  </footer>
64
64
  <%= script "jcore" %>
65
65
  <script>
66
- var JSDOC = JSDOC || {};
67
- JSDOC.root = "<%= to_relative(Configs.output) + '/' %>";
68
- window.jQuery || document.write("<script src='"+JSDOC.root+"js/jquery.js'>\x3C/script>")
66
+ var J = J || {};
67
+ J.root = "<%= to_relative(Configs.output) + '/' %>";
68
+ window.jQuery || document.write("<script src='"+J.root+"js/jquery.js'>\x3C/script>")
69
69
  </script>
70
70
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js"></script>
71
- <%= script "jquery.treeview", "jquery.cookie", "jquery.tooltip", "application", "apisearch-data" %>
71
+ <%= script "jquery.treeview", "jquery.cookie", "jquery.tooltip", "regexpx", "shCore", "shBrushJScript", "application", "apisearch-data" %>
72
72
  <body>
73
73
  </html>
@@ -1,3 +1,3 @@
1
- var JSDOC = JSDOC || {};
2
- JSDOC.data = JSDOC.data || {};
3
- JSDOC.data.<%= @varname %> = <%= @data.to_json %>
1
+ var J = J || {};
2
+ J.data = J.data || {};
3
+ J.data.<%= @varname %> = <%= @data.to_json %>
@@ -13,7 +13,7 @@
13
13
  <div class="method-list">
14
14
  <h3>Methods</h3>
15
15
  <ul>
16
- <% @methods.each do |child| %>
16
+ <% @methods.sort{|a,b| a.name <=> b.name }.each do |child| %>
17
17
  <li><%= link_to child %></li>
18
18
  <% end %>
19
19
  </ul>
@@ -31,14 +31,14 @@
31
31
 
32
32
  <div class="body">
33
33
 
34
- <%= to_html @object.docs %>
34
+ <%=to_html @object.docs %>
35
35
 
36
36
  <!-- SUMMARY -->
37
37
  <% unless @methods.nil? or @methods.size == 0 %>
38
38
  <section>
39
39
  <h3 class="icon function">Methods</h3>
40
40
  <ul class="summary collapsed">
41
- <% @methods.each do |child| %>
41
+ <% @methods.sort{|a,b| a.name <=> b.name }.each do |child| %>
42
42
  <li><%= link_to child %></li>
43
43
  <% end %>
44
44
  </ul>
@@ -1,4 +1,5 @@
1
- <%
1
+ <% unless tokens.nil?
2
+
2
3
 
3
4
  opts = tokens.first.html
4
5
  opts[:class] = (opts[:class] || "") + " subsection"
@@ -8,4 +9,5 @@
8
9
  <ul>
9
10
  <%= render :partial => 'tokens/default_token', :collection => tokens %>
10
11
  </ul>
11
- </section>
12
+ </section>
13
+ <% end %>
@@ -4,6 +4,7 @@
4
4
  <% end %>
5
5
 
6
6
  <% unless default_token.children.nil? %>
7
+ <%=to_html default_token.content %>
7
8
  <ul>
8
9
  <%= render :partial => 'tokens/default_token', :collection => default_token.children %>
9
10
  </ul>
@@ -13,7 +14,7 @@
13
14
  <% unless default_token.types.nil? %>
14
15
  (<span class="types"><%= default_token.types.map {|t| link_to(t) }.join ', ' %></span>)
15
16
  <% end %>
16
- <%= replace_links to_html default_token.content %>
17
+ <%=to_html default_token.content %>
17
18
 
18
19
  <% end %>
19
20
  </li>
@@ -1,2 +1,2 @@
1
1
  <h3>Example <%= example.name %></h3>
2
- <%=code example.content %>
2
+ <%=code example.content, :class => "example" %>
@@ -0,0 +1,12 @@
1
+ <section class="overload">
2
+ <h2 class="signature"><%= signature overload %></h2>
3
+ <%=to_html overload.content %>
4
+ <%
5
+
6
+ params = overload.children.select {|t| t.token == :param }
7
+ returns = overload.children.select {|t| t.token == :return }
8
+
9
+ %>
10
+ <%= render :partial => 'tokens/default', :locals => { :tokens => params } unless params.empty? %>
11
+ <%= render :partial => 'tokens/default', :locals => { :tokens => returns } unless returns.empty? %>
12
+ </section>
@@ -1,6 +1,9 @@
1
- require_relative '../lib/boot.rb'
1
+ require 'pathname'
2
+ require Pathname.new(__FILE__).realpath + '../../lib/boot'
2
3
 
3
- Logger.setup :level => :debug
4
+ Configs.set :root => Pathname.new(__FILE__).realpath + '../..'
5
+
6
+ setup_application :templates => '../templates', :output => '../out'
4
7
 
5
8
  def load_core_doc
6
9
  Processor.process_files_to_dom 'test/js-files/core-doc.js'
@@ -54,25 +54,30 @@ var Core = Core || (function(){
54
54
  var core = {
55
55
 
56
56
  /**
57
- * register new {Core.extensions}
58
- *
59
57
  * @function Core.extend
58
+ *
59
+ * register new {Core.extensions}
60
+ *
61
+ * @example Testextension
62
+ * // This is some http://www.link.com
63
+ * Core.extend('testextension', function() {
64
+ * return {};
65
+ * });
66
+ *
67
+ * @event CoreExtended
68
+ * Fires, if a new Extension has been registered.
69
+ * [Core.extension] ext The newly registered extension
60
70
  *
61
71
  * @param [String] id the id to register the new {Core.extensionss extension} under
62
72
  * @param [Function] constructor a callback function, which acts as
63
73
  * constructor for {Core.extensions}
64
74
  * @param settings
75
+ * This is the configuration object for {Core.extend}
65
76
  * [String] name the name of the extension
66
77
  * [Number] pos the position to put the extension to (Defaults to 0)
67
78
  * [String] color the background-color of the extension
68
79
  *
69
- * @return [Core.logger] the constructed extension
70
- *
71
- *
72
- * @example Testextension
73
- * Core.extend('testextension', function() {
74
- * return {};
75
- * });
80
+ * @return [Core.logger] the constructed extension
76
81
  */
77
82
  extend: function(id, constructor) {
78
83
 
@@ -113,11 +118,14 @@ var Core = Core || (function(){
113
118
  *
114
119
  * @function Core.logger.log
115
120
  *
116
- * @overload log(msg)
121
+ * @overload
117
122
  * @param [String] msg The message to log
118
123
  *
119
- * @overload log(level, msg)
120
- *
124
+ * @overload
125
+ * This is just some documentation
126
+ *
127
+ * @param [String] level The Loglevel
128
+ * @param [String] msg The message to log
121
129
  */
122
130
  log: function(msg) {
123
131
  if(!!window.console) {
@@ -106,5 +106,5 @@ describe StringScanner, "#intelligent_skip_until" do
106
106
  end
107
107
  end
108
108
  end
109
-
109
+
110
110
  end
@@ -1,4 +1,4 @@
1
- #encoding utf-8
1
+ #<Encoding:UTF-8>
2
2
 
3
3
  require_relative '../../lib/parser/parser'
4
4
 
@@ -245,7 +245,7 @@ describe Parser::Parser, ".parse" do
245
245
 
246
246
 
247
247
  context "parsing multibyte character" do
248
- =begin
248
+
249
249
  before do
250
250
 
251
251
  @parser = Parser::Parser.new("/**
@@ -264,10 +264,7 @@ Foo Bar")
264
264
  it "should find the correct source" do
265
265
  subject.source.should == "Foo Bar"
266
266
  end
267
-
268
- =end
269
- pending("There are Problems with utf-8 encoded string")
270
-
267
+
271
268
  end
272
269
 
273
270
  end