docjs 0.1.5 → 0.2

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/lib/helper/linker.rb CHANGED
@@ -10,13 +10,31 @@ module Helper
10
10
  HASH = /^#\S*/
11
11
  DOCUMENTATION = /^doc\:([^\s#]+)(#\S+)?/
12
12
 
13
- # @note link_to - first argument can be
14
- # "file:some/path/to_a.file"
15
- # "Code.object.path"
16
- # ".relative.code_object.path"
17
- # "http://external.address.com"
18
- # instance_of_code_object
13
+ # link to can link many types of resources, the `target` can be one of:
14
+ #
15
+ # - `"file:some/path/to_a.file"`
16
+ # - `"doc:Document.path"`
17
+ # - `"Code.object.path"`
18
+ # - `".relative.code_object.path"`
19
+ # - `"http://external.address.com"`
20
+ # - `"mailto:me@example.com"`
21
+ # - `instance_of_code_object`
22
+ # - `instance_of_a_doc_object`
23
+ #
24
+ # Most of the time it will be used by {#replace_links} to automatically convert links in
25
+ # documentation like `{Core.some.object see some.object}`
19
26
  #
27
+ # @example
28
+ # link_to "doc:README", "see readme"
29
+ # link_to Dom.docs[:README], "see readme"
30
+ #
31
+ # link_to "file:pdf/information.pdf", "pdf-file (1.5MB)"
32
+ # link_to "http://b-studios.de", "b-studios"
33
+ #
34
+ # @param [String, Document::Document, CodeObject::Base] target for further information see above
35
+ # @param [String] text the link text
36
+ # @return [String] a html-link
37
+ # @param [Hash] args the arguments, which will be reached through to {Helper#tag}
20
38
  def link_to(target, text = nil, args = {})
21
39
 
22
40
  Logger.debug "Trying to link #{target}"
@@ -68,10 +86,19 @@ module Helper
68
86
  Logger.warn "Could not resolve link to '#{target}'"
69
87
  return text
70
88
  end
71
-
72
- tag :a, text, :href => link
89
+
90
+ tag :a, text, args.merge({ :href => link })
73
91
  end
74
92
 
93
+ # Creates a link, relative to the current output-path
94
+ #
95
+ # @example
96
+ # relative_link '/home/me/output/test.html', 'Click me'
97
+ # #=> "<a href='../test.html'>Click me</a>"
98
+ #
99
+ # @param [String] path absolute path to the resource
100
+ # @param [String] text the link text
101
+ # @return [String] html-link
75
102
  def relative_link(path, text)
76
103
  tag :a, text, :href => to_relative(path)
77
104
  end
@@ -104,8 +131,17 @@ module Helper
104
131
  object.to_s
105
132
  end
106
133
  end
107
-
108
- # (see https://github.com/lsegal/yard/blob/master/lib/yard/templates/helpers/html_helper.rb)
134
+
135
+ # finds any links, that look like `{my_link}` and replaces them with the help of {#link_to}
136
+ #
137
+ # @example
138
+ # replace_links "This is a text, containing a {some.reference link}"
139
+ # #=> "This is a text, containing a <a href='../some/reference.html'>link</a>"
140
+ #
141
+ # @param [String] text
142
+ # @return [String] text containing html-links
143
+ #
144
+ # @see https://github.com/lsegal/yard/blob/master/lib/yard/templates/helpers/html_helper.rb#L170
109
145
  def replace_links(text)
110
146
  code_tags = 0
111
147
  text.gsub(/<(\/)?(pre|code|tt)|(\\)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W<]|.+<\/|$)/m) do |str|
@@ -124,4 +160,4 @@ module Helper
124
160
  end
125
161
  end
126
162
  end
127
- end
163
+ end
@@ -3,22 +3,22 @@ require_relative '../code_object/converter'
3
3
 
4
4
  module Parser
5
5
 
6
- # Together with {Parser::Coment} it acts as an **Interface** between {Parser}
7
- # and {CodeObject}. Parser::Comment creates instances of Tokenline, which are
8
- # then analysed by {Token::Container#process_token}
6
+ # Together with {Parser::Coment} it acts as an **Interface** between {Parser} and {CodeObject}.
7
+ # Parser::Comment creates instances of Tokenline, which are then analysed by
8
+ # {Token::Container#process_token}
9
9
  #
10
10
  # @see Parser::Comment
11
11
  # @see Parser::CommentParser
12
12
  Tokenline = Struct.new :token, :content
13
13
 
14
14
  # Comment contains all **tokenlines** and **doclines**, which are created by the
15
- # {Parser::Parser parser}. The tokenlines are stored as {Tokenline}. Because
16
- # of this Comment and Tokenline act as **Interface** for {CodeObject::Base}.
15
+ # {Parser::Parser parser}. The tokenlines are stored as {Tokenline}. Because of this Comment and
16
+ # Tokenline act as **Interface** for {CodeObject::Base}.
17
17
  #
18
- # The tokens will further be processed by {Token::Container}, which
19
- # is mixed in to CodeObject::Base).
18
+ # The tokens will further be processed by {Token::Container}, which is mixed in to
19
+ # {CodeObject::Base}).
20
20
  #
21
- # @example creating of an comment
21
+ # @example creating an comment
22
22
  # c = Parser::Comment.new "the original string of the comment, with all tokens and doclines"
23
23
  # c.add_tokenline :param "[String] first_parameter this is the description for param1"
24
24
  # c.add_docline "Some documentation of the comment"
@@ -56,6 +56,7 @@ module Parser
56
56
  @children += comments
57
57
  end
58
58
 
59
+ # @return [Boolean]
59
60
  def has_tokens?
60
61
  not @tokenlines.empty?
61
62
  end
@@ -9,9 +9,8 @@ module Parser
9
9
  @comment = Comment.new(input)
10
10
  end
11
11
 
12
- # All lines, that start with a `@-symbol` will be processed as tokenline
13
- # if the next line after a token starts with two spaces, it will be
14
- # interpreted as continuation of the preceding token.
12
+ # All lines, that start with a `@-symbol` will be processed as tokenline. If the next line after
13
+ # a token starts with two spaces, it will be interpreted as continuation of the preceding token.
15
14
  #
16
15
  # @example multiline token
17
16
  # @multiline_token this is a multi_line token, it won't
@@ -19,8 +18,8 @@ module Parser
19
18
  #
20
19
  # All other lines are interpreted as doclines
21
20
  #
22
- # @return [Parser::Comment] Creates an instance of {Parser::Comment} and
23
- # attaches all find doc- and tokenlines to it.
21
+ # @return [Parser::Comment] Creates an instance of {Parser::Comment} and attaches all find doc-
22
+ # and tokenlines to it.
24
23
  def parse
25
24
  # we don't want the linebreak of the comment start in our first docline
26
25
  # i.e. ignore '/**\n'
@@ -34,8 +33,8 @@ module Parser
34
33
 
35
34
  protected
36
35
 
37
- # skips leading spaces with asterisk aka {Parser::LINE_START LINE_START}
38
- # then checks for {Parser::TOKENLINE_START @-symbol} to parse a token
36
+ # skips leading spaces with asterisk aka {Parser::LINE_START LINE_START} then checks for
37
+ # {Parser::TOKENLINE_START @-symbol} to parse a token
39
38
  def parse_comment_line
40
39
  self.skip LINE_START
41
40
 
@@ -59,9 +58,9 @@ module Parser
59
58
  # @token_two some text, and some more
60
59
  # and even some more.
61
60
  #
62
- # 1. Scan til the first linebreak (or end of string, if it reaches it first)
63
- # 2. Check if next line starts with two spaces, skip them
64
- # 3. Parse recursivly til the next line does not start with two spaces
61
+ # 1. Scan til the first linebreak (or end of string, if it reaches it first)
62
+ # 2. Check if next line starts with two spaces, skip them
63
+ # 3. Parse recursivly til the next line does not start with two spaces
65
64
  #
66
65
  # @see StringScanner.scan_until_ahead to see another example
67
66
  # of the positive lookahead
data/lib/parser/parser.rb CHANGED
@@ -58,8 +58,7 @@ module Parser
58
58
 
59
59
  attr_reader :filepath, :offset
60
60
 
61
- # A new StringScanner instance will be used to {#parse parse} the given
62
- # `input`.
61
+ # A new StringScanner instance will be used to {#parse parse} the given `input`.
63
62
  #
64
63
  # @param [String] input
65
64
  def initialize(input, args = {})
@@ -79,8 +78,8 @@ module Parser
79
78
  end
80
79
 
81
80
 
82
- # Recursivly parses the {#initialize given input} and thereby ignores
83
- # strings.
81
+ # Recursivly parses the {#initialize given input} and thereby ignores strings.
82
+ #
84
83
  # @todo Rewrite to use skip_intelligent_until
85
84
  # @return [Array<Parser::Comment>] the parsed comment-stream
86
85
  def parse()
@@ -220,8 +219,7 @@ class StringScanner
220
219
  return content
221
220
  end
222
221
 
223
- # will stop to scan at the specified pattern or at eos and returns the
224
- # consumed string.
222
+ # will stop to scan at the specified pattern or at eos and returns the consumed string.
225
223
  #
226
224
  # @param [Regexp] pattern the pattern to scan for
227
225
  # @return [String] the String before `pattern`
data/lib/processor.rb CHANGED
@@ -46,7 +46,7 @@ module Processor
46
46
  comments.each do |comment|
47
47
  code_object = comment.to_code_object # convert to code_object
48
48
  Logger.debug "Adding to Dom: #{code_object}"
49
- Dom.add_node(code_object.path, code_object) # add to dom
49
+ Dom.add_node(code_object.path, code_object) unless code_object.nil? # add to dom
50
50
  end
51
51
  end
52
52
 
data/lib/token/handler.rb CHANGED
@@ -240,6 +240,11 @@ module Token
240
240
  }
241
241
  @@handlers = {}
242
242
 
243
+ # Hash for all registered CodeObject-Types.
244
+ # For example:
245
+ # { :function => CodeObject::Function }
246
+ @@types = {}
247
+
243
248
  # Attribute-Reader for all registered `@@handlers`
244
249
  #
245
250
  # @return [Hash<Symbol, Block>]
@@ -247,6 +252,12 @@ module Token
247
252
  @@handlers
248
253
  end
249
254
 
255
+ # @return [Hash<Symbol, CodeObject::Base> with symbol beeing the token and CodeObject::Base any
256
+ # subclass
257
+ def self.types
258
+ @@types
259
+ end
260
+
250
261
  # Use a default handler
251
262
  def self.apply(default_handler, *args)
252
263
  @@defaults[default_handler].call(*args)
@@ -321,6 +332,8 @@ module Token
321
332
 
322
333
  });
323
334
 
335
+
336
+ @@types[tokenname] = options[:type] unless options[:type].nil?
324
337
  @@handlers[tokenname] = klass
325
338
  end
326
339
 
data/lib/token/token.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  module Token
2
2
 
3
- # Serves as Base-Class for all registered tokens.
4
- # Registering a token with
3
+ # Serves as Base-Class for all registered tokens. Registering a token with
5
4
  #
6
5
  # Token:Handler.register :awesome, :template => :foo, :description => "Description"
7
6
  #
@@ -28,8 +27,8 @@ module Token
28
27
  #
29
28
  # Token:Handler.register :awesome, :template => :foo, :description => "Description"
30
29
  #
31
- # This will create a class Token::AwesomeToken, which extends {Token::Token}. After creating the class
32
- # {.process_options} will be called with all provided options to apply those to the class.
30
+ # This will create a class Token::AwesomeToken, which extends {Token::Token}. After creating the
31
+ # class {.process_options} will be called with all provided options to apply those to the class.
33
32
  #
34
33
  # Because the options are valid for all instances of a tokenclass, the contents are stored in
35
34
  # class-variables and class-methods are defined as accessors:
@@ -2,8 +2,6 @@ module Generator
2
2
 
3
3
  class ApiPagesGenerator < Generator
4
4
 
5
- # @todo those methods and therefore all class-variables @@configs are shared with all inheriting
6
- # classes. i.e. The last change will be applied to all
7
5
  describe 'renders documented objects type-dependant (Functions and Objects)'
8
6
  layout 'application'
9
7
 
@@ -23,7 +21,6 @@ module Generator
23
21
  end
24
22
  end
25
23
 
26
- # @todo switch on registered Types to enable dynamic view-changing
27
24
  def render_object(code_object)
28
25
 
29
26
  Logger.info "Rendering CodeObject '#{code_object.name}'"
@@ -32,7 +29,6 @@ module Generator
32
29
  @object = code_object
33
30
  @methods = @object.children.values.select {|c| c.is_a? CodeObject::Function }
34
31
  @children = @object.children.values - @methods
35
- # Render has to be documented very well, because it will be used in RenderTasks
36
32
  render 'object/index', :to_file => path_to(code_object, :format => :html)
37
33
  end
38
34
  end
@@ -14,8 +14,7 @@ module Generator
14
14
  next if doc.is_a? Dom::NoDoc
15
15
 
16
16
  render_document doc
17
- end
18
-
17
+ end
19
18
 
20
19
  readme = Dom.docs.find('README')
21
20
  in_context readme do
@@ -292,7 +292,12 @@ input:invalid, textarea:invalid {
292
292
  display: block;
293
293
  float: right; }
294
294
  #header nav input#search {
295
+ -moz-border-radius: 10px;
296
+ /* Firefox */
297
+ -webkit-border-radius: 10px;
298
+ /* Safari, Chrome */
295
299
  border-radius: 10px;
300
+ /* CSS3 */
296
301
  outline: none;
297
302
  padding: 0.2em 0.5em; }
298
303
  #header nav #page-menu {
@@ -305,9 +310,19 @@ input:invalid, textarea:invalid {
305
310
  float: left;
306
311
  /* rounded corners */ }
307
312
  #header nav #page-menu li:first-child a {
308
- border-radius: 0 0 0 10px; }
313
+ -moz-border-radius: 0 0 0 10px;
314
+ /* Firefox */
315
+ -webkit-border-radius: 0 0 0 10px;
316
+ /* Safari, Chrome */
317
+ border-radius: 0 0 0 10px;
318
+ /* CSS3 */ }
309
319
  #header nav #page-menu li:last-child a {
310
- border-radius: 0 0 10px 0; }
320
+ -moz-border-radius: 0 0 10px 0;
321
+ /* Firefox */
322
+ -webkit-border-radius: 0 0 10px 0;
323
+ /* Safari, Chrome */
324
+ border-radius: 0 0 10px 0;
325
+ /* CSS3 */ }
311
326
  #header nav #page-menu a {
312
327
  background: #4a8fd3;
313
328
  /* Old browsers */
@@ -360,8 +375,13 @@ input:invalid, textarea:invalid {
360
375
  padding: 0 0 0 0.5em;
361
376
  margin-bottom: 0.5em; }
362
377
  #header .col50 section > ul {
363
- border: 1px solid #eee;
378
+ -moz-border-radius: 10px;
379
+ /* Firefox */
380
+ -webkit-border-radius: 10px;
381
+ /* Safari, Chrome */
364
382
  border-radius: 10px;
383
+ /* CSS3 */
384
+ border: 1px solid #eee;
365
385
  padding: 0;
366
386
  margin: 0;
367
387
  overflow: hidden;
@@ -483,6 +503,12 @@ input:invalid, textarea:invalid {
483
503
  /* W3C */
484
504
  font-family: Arial, sans-serif;
485
505
  font-size: 10pt;
506
+ -moz-border-radius: 5px;
507
+ /* Firefox */
508
+ -webkit-border-radius: 5px;
509
+ /* Safari, Chrome */
510
+ border-radius: 5px;
511
+ /* CSS3 */
486
512
  display: none;
487
513
  position: absolute;
488
514
  padding: 0.5em;
@@ -491,7 +517,6 @@ input:invalid, textarea:invalid {
491
517
  font-size: 9pt;
492
518
  color: #eee;
493
519
  border: 1px solid #fff;
494
- border-radius: 5px;
495
520
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
496
521
  .tooltip a {
497
522
  color: #8eb5db; }
@@ -506,7 +531,7 @@ code.source, .syntaxhighlighter, code.example {
506
531
  display: block;
507
532
  background: #f3f3f3;
508
533
  font-size: 9pt;
509
- line-height: 1.4em;
534
+ line-height: 1.6em;
510
535
  padding: 0.5em;
511
536
  margin-bottom: 1.33em; }
512
537
 
@@ -528,12 +553,12 @@ code.source, .syntaxhighlighter, code.example {
528
553
  border-right: 1px solid #d9d9d9;
529
554
  text-align: right; }
530
555
  .syntaxhighlighter .gutter .line {
531
- font-size: 9pt;
532
- line-height: 1.4em; }
556
+ height: 1.6em; }
533
557
  .syntaxhighlighter .code {
534
558
  padding: 0.5em 0;
535
559
  width: 100%; }
536
560
  .syntaxhighlighter .code .line {
561
+ height: 1.6em;
537
562
  padding: 0 0.5em; }
538
563
  .syntaxhighlighter .code .line:hover {
539
564
  background: #f5f5f5; }
@@ -634,8 +659,13 @@ div#main {
634
659
  max-width: 1000px;
635
660
  display: block;
636
661
  overflow: hidden;
637
- margin-top: -20px;
662
+ -moz-border-radius: 10px 10px 0 0;
663
+ /* Firefox */
664
+ -webkit-border-radius: 10px 10px 0 0;
665
+ /* Safari, Chrome */
638
666
  border-radius: 10px 10px 0 0;
667
+ /* CSS3 */
668
+ margin-top: -20px;
639
669
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
640
670
  border-top: 1px solid #eee; }
641
671
  div#main h1 {
@@ -656,11 +686,16 @@ div#main {
656
686
  padding-right: 20px; }
657
687
  div#main header h1 .flag {
658
688
  font-family: "Consolas", "monospace";
689
+ -moz-border-radius: 5px;
690
+ /* Firefox */
691
+ -webkit-border-radius: 5px;
692
+ /* Safari, Chrome */
693
+ border-radius: 5px;
694
+ /* CSS3 */
659
695
  display: block;
660
696
  background: #fcded1;
661
697
  border: 1px solid #f9c2ab;
662
698
  color: #5490c8;
663
- border-radius: 5px;
664
699
  padding: 0.4em 1em;
665
700
  display: block;
666
701
  float: right;
@@ -675,9 +710,14 @@ div#main nav.sidebar {
675
710
  font-family: "Consolas", "monospace";
676
711
  display: block;
677
712
  background: #f3f3f3;
713
+ -moz-border-radius: 5px;
714
+ /* Firefox */
715
+ -webkit-border-radius: 5px;
716
+ /* Safari, Chrome */
717
+ border-radius: 5px;
718
+ /* CSS3 */
678
719
  margin: 40px 0 12px 12px;
679
720
  padding: 0;
680
- border-radius: 5px;
681
721
  font-size: 8pt;
682
722
  color: #999; }
683
723
  div#main nav.sidebar > * {
@@ -727,11 +767,16 @@ div#main .body .summary {
727
767
  float: left; }
728
768
  div#main .body .summary a {
729
769
  font-family: "Consolas", "monospace";
770
+ -moz-border-radius: 5px;
771
+ /* Firefox */
772
+ -webkit-border-radius: 5px;
773
+ /* Safari, Chrome */
774
+ border-radius: 5px;
775
+ /* CSS3 */
730
776
  display: block;
731
777
  background: #eff4fa;
732
778
  border: 1px solid #d0e0f0;
733
779
  color: #5490c8;
734
- border-radius: 5px;
735
780
  padding: 0.4em 1em;
736
781
  margin: 0.25em; }
737
782
  div#main .body .summary a:hover {
@@ -763,11 +808,16 @@ div#main .body h3.source {
763
808
  margin-bottom: 1.33em; }
764
809
  div#main .body .signature {
765
810
  font-family: "Consolas", "monospace";
811
+ -moz-border-radius: 5px;
812
+ /* Firefox */
813
+ -webkit-border-radius: 5px;
814
+ /* Safari, Chrome */
815
+ border-radius: 5px;
816
+ /* CSS3 */
766
817
  display: block;
767
818
  background: #eff4fa;
768
819
  border: 1px solid #d0e0f0;
769
820
  color: #5490c8;
770
- border-radius: 5px;
771
821
  padding: 0.4em 1em;
772
822
  color: #000;
773
823
  font-size: 12pt;
@@ -775,11 +825,16 @@ div#main .body .signature {
775
825
  margin-bottom: 1.33em; }
776
826
  div#main .body .signature.constructor {
777
827
  font-family: "Consolas", "monospace";
828
+ -moz-border-radius: 5px;
829
+ /* Firefox */
830
+ -webkit-border-radius: 5px;
831
+ /* Safari, Chrome */
832
+ border-radius: 5px;
833
+ /* CSS3 */
778
834
  display: block;
779
835
  background: #fcded1;
780
836
  border: 1px solid #f9c2ab;
781
837
  color: #5490c8;
782
- border-radius: 5px;
783
838
  padding: 0.4em 1em;
784
839
  color: #000; }
785
840
  div#main .body .signature .name {
@@ -795,33 +850,53 @@ div#main .body .overload {
795
850
  div#main .notification {
796
851
  display: table; }
797
852
  div#main .notification section {
853
+ -moz-border-radius: 5px;
854
+ /* Firefox */
855
+ -webkit-border-radius: 5px;
856
+ /* Safari, Chrome */
857
+ border-radius: 5px;
858
+ /* CSS3 */
798
859
  display: block;
799
860
  background: #f3f3f3;
800
861
  border: 1px solid #dfdfdf;
801
862
  color: #666666;
802
- border-radius: 5px;
803
863
  padding: 0.4em 1em;
804
864
  margin-bottom: 0.5em; }
805
865
  div#main .notification section.deprecated {
866
+ -moz-border-radius: 5px;
867
+ /* Firefox */
868
+ -webkit-border-radius: 5px;
869
+ /* Safari, Chrome */
870
+ border-radius: 5px;
871
+ /* CSS3 */
806
872
  display: block;
807
873
  background: #cccccc;
808
874
  border: 1px solid #b8b8b8;
809
875
  color: #666666;
810
- border-radius: 5px;
811
876
  padding: 0.4em 1em; }
812
877
  div#main .notification section.todo {
878
+ -moz-border-radius: 5px;
879
+ /* Firefox */
880
+ -webkit-border-radius: 5px;
881
+ /* Safari, Chrome */
882
+ border-radius: 5px;
883
+ /* CSS3 */
813
884
  display: block;
814
885
  background: #fef377;
815
886
  border: 1px solid #feef4e;
816
887
  color: #4e4e07;
817
- border-radius: 5px;
818
888
  padding: 0.4em 1em; }
819
889
  div#main .notification section.warn {
890
+ -moz-border-radius: 5px;
891
+ /* Firefox */
892
+ -webkit-border-radius: 5px;
893
+ /* Safari, Chrome */
894
+ border-radius: 5px;
895
+ /* CSS3 */
820
896
  display: block;
821
897
  background: #ff5544;
822
898
  border: 1px solid #ff301b;
823
899
  color: #4e1a07;
824
- border-radius: 5px;
825
900
  padding: 0.4em 1em; }
826
901
  div#main .notification section ul {
827
902
  list-style: none;