rdoc 4.1.2 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.autotest +3 -1
  3. data/History.rdoc +70 -3
  4. data/LEGAL.rdoc +11 -0
  5. data/Manifest.txt +6 -2
  6. data/Rakefile +8 -1
  7. data/lib/rdoc.rb +3 -1
  8. data/lib/rdoc/context.rb +2 -0
  9. data/lib/rdoc/encoding.rb +3 -1
  10. data/lib/rdoc/generator.rb +1 -0
  11. data/lib/rdoc/generator/darkfish.rb +3 -2
  12. data/lib/rdoc/generator/json_index.rb +44 -0
  13. data/lib/rdoc/generator/pot.rb +97 -0
  14. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  15. data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -12
  16. data/lib/rdoc/generator/template/darkfish/{fonts.css → css/fonts.css} +0 -0
  17. data/lib/rdoc/generator/template/darkfish/{rdoc.css → css/rdoc.css} +11 -1
  18. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +32 -11
  19. data/lib/rdoc/markdown.kpeg +6 -1
  20. data/lib/rdoc/markdown.rb +174 -2
  21. data/lib/rdoc/markup.rb +2 -2
  22. data/lib/rdoc/markup/attribute_manager.rb +1 -1
  23. data/lib/rdoc/markup/to_html.rb +5 -4
  24. data/lib/rdoc/markup/to_label.rb +1 -1
  25. data/lib/rdoc/method_attr.rb +11 -3
  26. data/lib/rdoc/options.rb +55 -3
  27. data/lib/rdoc/parser.rb +1 -1
  28. data/lib/rdoc/parser/c.rb +5 -6
  29. data/lib/rdoc/parser/changelog.rb +7 -3
  30. data/lib/rdoc/parser/ruby.rb +8 -12
  31. data/lib/rdoc/rd/block_parser.rb +1 -1
  32. data/lib/rdoc/rd/inline_parser.rb +1 -1
  33. data/lib/rdoc/rdoc.rb +5 -3
  34. data/lib/rdoc/ruby_lex.rb +3 -3
  35. data/lib/rdoc/ruby_token.rb +7 -7
  36. data/lib/rdoc/single_class.rb +4 -0
  37. data/lib/rdoc/stats.rb +4 -0
  38. data/lib/rdoc/stats/normal.rb +22 -11
  39. data/lib/rdoc/task.rb +1 -1
  40. data/lib/rdoc/test_case.rb +1 -1
  41. data/lib/rdoc/text.rb +9 -0
  42. data/lib/rdoc/token_stream.rb +1 -1
  43. data/test/test_rdoc_context.rb +2 -0
  44. data/test/test_rdoc_encoding.rb +23 -0
  45. data/test/test_rdoc_generator_darkfish.rb +2 -2
  46. data/test/test_rdoc_generator_json_index.rb +55 -0
  47. data/test/test_rdoc_generator_markup.rb +1 -1
  48. data/test/test_rdoc_generator_pot.rb +91 -0
  49. data/test/test_rdoc_generator_pot_po.rb +51 -0
  50. data/test/test_rdoc_generator_pot_po_entry.rb +139 -0
  51. data/test/test_rdoc_i18n_locale.rb +73 -0
  52. data/test/test_rdoc_i18n_text.rb +123 -0
  53. data/test/test_rdoc_markup_attribute_manager.rb +6 -0
  54. data/test/test_rdoc_markup_heading.rb +4 -4
  55. data/test/test_rdoc_markup_pre_process.rb +1 -1
  56. data/test/test_rdoc_markup_to_html.rb +46 -26
  57. data/test/test_rdoc_markup_to_html_snippet.rb +8 -7
  58. data/test/test_rdoc_markup_to_label.rb +4 -4
  59. data/test/test_rdoc_method_attr.rb +31 -1
  60. data/test/test_rdoc_normal_class.rb +4 -4
  61. data/test/test_rdoc_options.rb +19 -0
  62. data/test/test_rdoc_parser.rb +16 -1
  63. data/test/test_rdoc_parser_c.rb +31 -1
  64. data/test/test_rdoc_parser_changelog.rb +1 -1
  65. data/test/test_rdoc_parser_markdown.rb +1 -1
  66. data/test/test_rdoc_parser_rd.rb +1 -1
  67. data/test/test_rdoc_parser_ruby.rb +22 -25
  68. data/test/test_rdoc_parser_simple.rb +1 -1
  69. data/test/test_rdoc_rd_block_parser.rb +3 -1
  70. data/test/test_rdoc_rdoc.rb +24 -3
  71. data/test/test_rdoc_ruby_lex.rb +11 -0
  72. data/test/test_rdoc_rubygems_hook.rb +0 -3
  73. data/test/test_rdoc_single_class.rb +13 -5
  74. data/test/test_rdoc_stats.rb +55 -0
  75. data/test/test_rdoc_task.rb +1 -0
  76. metadata +18 -7
@@ -23,12 +23,22 @@ h3 span,
23
23
  h4 span,
24
24
  h5 span,
25
25
  h6 span {
26
+ position: relative;
27
+
26
28
  display: none;
27
29
  padding-left: 1em;
30
+ line-height: 0;
31
+ vertical-align: baseline;
28
32
  font-size: 10px;
29
- vertical-align: super;
30
33
  }
31
34
 
35
+ h1 span { top: -1.3em; }
36
+ h2 span { top: -1.2em; }
37
+ h3 span { top: -1.0em; }
38
+ h4 span { top: -0.8em; }
39
+ h5 span { top: -0.5em; }
40
+ h6 span { top: -0.5em; }
41
+
32
42
  h1:hover span,
33
43
  h2:hover span,
34
44
  h3:hover span,
@@ -44,14 +44,6 @@ function hookSourceViews() {
44
44
  $('.method-heading').click( showSource );
45
45
  };
46
46
 
47
- function toggleDebuggingSection() {
48
- $('.debugging-section').slideToggle();
49
- };
50
-
51
- function hookDebuggingToggle() {
52
- $('#debugging-toggle img').click( toggleDebuggingSection );
53
- };
54
-
55
47
  function hookSearch() {
56
48
  var input = $('#search-field').eq(0);
57
49
  var result = $('#search-results').eq(0);
@@ -129,12 +121,41 @@ function highlightClickTarget( event ) {
129
121
  };
130
122
  };
131
123
 
124
+ function loadAsync(path, success) {
125
+ $.ajax({
126
+ url: rdoc_rel_prefix + path,
127
+ dataType: 'script',
128
+ success: success,
129
+ cache: true
130
+ });
131
+ };
132
132
 
133
133
  $(document).ready( function() {
134
134
  hookSourceViews();
135
- hookDebuggingToggle();
136
- hookSearch();
137
135
  highlightLocationTarget();
138
-
139
136
  $('ul.link-list a').bind( "click", highlightClickTarget );
137
+
138
+ var search_scripts_loaded = {
139
+ navigation_loaded: false,
140
+ search_loaded: false,
141
+ search_index_loaded: false,
142
+ searcher_loaded: false,
143
+ }
144
+
145
+ var search_success_function = function(variable) {
146
+ return (function (data, status, xhr) {
147
+ search_scripts_loaded[variable] = true;
148
+
149
+ if (search_scripts_loaded['navigation_loaded'] == true &&
150
+ search_scripts_loaded['search_loaded'] == true &&
151
+ search_scripts_loaded['search_index_loaded'] == true &&
152
+ search_scripts_loaded['searcher_loaded'] == true)
153
+ hookSearch();
154
+ });
155
+ }
156
+
157
+ loadAsync('js/navigation.js', search_success_function('navigation_loaded'));
158
+ loadAsync('js/search.js', search_success_function('search_loaded'));
159
+ loadAsync('js/search_index.js', search_success_function('search_index_loaded'));
160
+ loadAsync('js/searcher.js', search_success_function('searcher_loaded'));
140
161
  });
@@ -602,6 +602,10 @@ ListBlockLine = !@BlankLine
602
602
  # Parsers for different kinds of block-level HTML content.
603
603
  # This is repetitive due to constraints of PEG grammar.
604
604
 
605
+ HtmlOpenAnchor = "<" Spnl ("a" | "A") Spnl HtmlAttribute* ">"
606
+ HtmlCloseAnchor = "<" Spnl "/" ("a" | "A") Spnl ">"
607
+ HtmlAnchor = HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor
608
+
605
609
  HtmlBlockOpenAddress = "<" Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* ">"
606
610
  HtmlBlockCloseAddress = "<" Spnl "/" ("address" | "ADDRESS") Spnl ">"
607
611
  HtmlBlockAddress = HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress
@@ -735,7 +739,8 @@ HtmlBlockCloseScript = "<" Spnl "/" ("script" | "SCRIPT") Spnl ">"
735
739
  HtmlBlockScript = HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript
736
740
 
737
741
 
738
- HtmlBlockInTags = HtmlBlockAddress
742
+ HtmlBlockInTags = HtmlAnchor
743
+ | HtmlBlockAddress
739
744
  | HtmlBlockBlockquote
740
745
  | HtmlBlockCenter
741
746
  | HtmlBlockDir
@@ -2822,6 +2822,172 @@ class RDoc::Markdown
2822
2822
  return _tmp
2823
2823
  end
2824
2824
 
2825
+ # HtmlOpenAnchor = "<" Spnl ("a" | "A") Spnl HtmlAttribute* ">"
2826
+ def _HtmlOpenAnchor
2827
+
2828
+ _save = self.pos
2829
+ while true # sequence
2830
+ _tmp = match_string("<")
2831
+ unless _tmp
2832
+ self.pos = _save
2833
+ break
2834
+ end
2835
+ _tmp = apply(:_Spnl)
2836
+ unless _tmp
2837
+ self.pos = _save
2838
+ break
2839
+ end
2840
+
2841
+ _save1 = self.pos
2842
+ while true # choice
2843
+ _tmp = match_string("a")
2844
+ break if _tmp
2845
+ self.pos = _save1
2846
+ _tmp = match_string("A")
2847
+ break if _tmp
2848
+ self.pos = _save1
2849
+ break
2850
+ end # end choice
2851
+
2852
+ unless _tmp
2853
+ self.pos = _save
2854
+ break
2855
+ end
2856
+ _tmp = apply(:_Spnl)
2857
+ unless _tmp
2858
+ self.pos = _save
2859
+ break
2860
+ end
2861
+ while true
2862
+ _tmp = apply(:_HtmlAttribute)
2863
+ break unless _tmp
2864
+ end
2865
+ _tmp = true
2866
+ unless _tmp
2867
+ self.pos = _save
2868
+ break
2869
+ end
2870
+ _tmp = match_string(">")
2871
+ unless _tmp
2872
+ self.pos = _save
2873
+ end
2874
+ break
2875
+ end # end sequence
2876
+
2877
+ set_failed_rule :_HtmlOpenAnchor unless _tmp
2878
+ return _tmp
2879
+ end
2880
+
2881
+ # HtmlCloseAnchor = "<" Spnl "/" ("a" | "A") Spnl ">"
2882
+ def _HtmlCloseAnchor
2883
+
2884
+ _save = self.pos
2885
+ while true # sequence
2886
+ _tmp = match_string("<")
2887
+ unless _tmp
2888
+ self.pos = _save
2889
+ break
2890
+ end
2891
+ _tmp = apply(:_Spnl)
2892
+ unless _tmp
2893
+ self.pos = _save
2894
+ break
2895
+ end
2896
+ _tmp = match_string("/")
2897
+ unless _tmp
2898
+ self.pos = _save
2899
+ break
2900
+ end
2901
+
2902
+ _save1 = self.pos
2903
+ while true # choice
2904
+ _tmp = match_string("a")
2905
+ break if _tmp
2906
+ self.pos = _save1
2907
+ _tmp = match_string("A")
2908
+ break if _tmp
2909
+ self.pos = _save1
2910
+ break
2911
+ end # end choice
2912
+
2913
+ unless _tmp
2914
+ self.pos = _save
2915
+ break
2916
+ end
2917
+ _tmp = apply(:_Spnl)
2918
+ unless _tmp
2919
+ self.pos = _save
2920
+ break
2921
+ end
2922
+ _tmp = match_string(">")
2923
+ unless _tmp
2924
+ self.pos = _save
2925
+ end
2926
+ break
2927
+ end # end sequence
2928
+
2929
+ set_failed_rule :_HtmlCloseAnchor unless _tmp
2930
+ return _tmp
2931
+ end
2932
+
2933
+ # HtmlAnchor = HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor
2934
+ def _HtmlAnchor
2935
+
2936
+ _save = self.pos
2937
+ while true # sequence
2938
+ _tmp = apply(:_HtmlOpenAnchor)
2939
+ unless _tmp
2940
+ self.pos = _save
2941
+ break
2942
+ end
2943
+ while true
2944
+
2945
+ _save2 = self.pos
2946
+ while true # choice
2947
+ _tmp = apply(:_HtmlAnchor)
2948
+ break if _tmp
2949
+ self.pos = _save2
2950
+
2951
+ _save3 = self.pos
2952
+ while true # sequence
2953
+ _save4 = self.pos
2954
+ _tmp = apply(:_HtmlCloseAnchor)
2955
+ _tmp = _tmp ? nil : true
2956
+ self.pos = _save4
2957
+ unless _tmp
2958
+ self.pos = _save3
2959
+ break
2960
+ end
2961
+ _tmp = get_byte
2962
+ unless _tmp
2963
+ self.pos = _save3
2964
+ end
2965
+ break
2966
+ end # end sequence
2967
+
2968
+ break if _tmp
2969
+ self.pos = _save2
2970
+ break
2971
+ end # end choice
2972
+
2973
+ break unless _tmp
2974
+ end
2975
+ _tmp = true
2976
+ unless _tmp
2977
+ self.pos = _save
2978
+ break
2979
+ end
2980
+ _tmp = apply(:_HtmlCloseAnchor)
2981
+ unless _tmp
2982
+ self.pos = _save
2983
+ end
2984
+ break
2985
+ end # end sequence
2986
+
2987
+ set_failed_rule :_HtmlAnchor unless _tmp
2988
+ return _tmp
2989
+ end
2990
+
2825
2991
  # HtmlBlockOpenAddress = "<" Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* ">"
2826
2992
  def _HtmlBlockOpenAddress
2827
2993
 
@@ -8289,11 +8455,14 @@ class RDoc::Markdown
8289
8455
  return _tmp
8290
8456
  end
8291
8457
 
8292
- # HtmlBlockInTags = (HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)
8458
+ # HtmlBlockInTags = (HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)
8293
8459
  def _HtmlBlockInTags
8294
8460
 
8295
8461
  _save = self.pos
8296
8462
  while true # choice
8463
+ _tmp = apply(:_HtmlAnchor)
8464
+ break if _tmp
8465
+ self.pos = _save
8297
8466
  _tmp = apply(:_HtmlBlockAddress)
8298
8467
  break if _tmp
8299
8468
  self.pos = _save
@@ -15748,6 +15917,9 @@ class RDoc::Markdown
15748
15917
  Rules[:_Enumerator] = rule_info("Enumerator", "@NonindentSpace [0-9]+ \".\" @Spacechar+")
15749
15918
  Rules[:_OrderedList] = rule_info("OrderedList", "&Enumerator (ListTight | ListLoose):a { RDoc::Markup::List.new(:NUMBER, *a) }")
15750
15919
  Rules[:_ListBlockLine] = rule_info("ListBlockLine", "!@BlankLine !(Indent? (Bullet | Enumerator)) !HorizontalRule OptionallyIndentedLine")
15920
+ Rules[:_HtmlOpenAnchor] = rule_info("HtmlOpenAnchor", "\"<\" Spnl (\"a\" | \"A\") Spnl HtmlAttribute* \">\"")
15921
+ Rules[:_HtmlCloseAnchor] = rule_info("HtmlCloseAnchor", "\"<\" Spnl \"/\" (\"a\" | \"A\") Spnl \">\"")
15922
+ Rules[:_HtmlAnchor] = rule_info("HtmlAnchor", "HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor")
15751
15923
  Rules[:_HtmlBlockOpenAddress] = rule_info("HtmlBlockOpenAddress", "\"<\" Spnl (\"address\" | \"ADDRESS\") Spnl HtmlAttribute* \">\"")
15752
15924
  Rules[:_HtmlBlockCloseAddress] = rule_info("HtmlBlockCloseAddress", "\"<\" Spnl \"/\" (\"address\" | \"ADDRESS\") Spnl \">\"")
15753
15925
  Rules[:_HtmlBlockAddress] = rule_info("HtmlBlockAddress", "HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress")
@@ -15847,7 +16019,7 @@ class RDoc::Markdown
15847
16019
  Rules[:_HtmlBlockOpenScript] = rule_info("HtmlBlockOpenScript", "\"<\" Spnl (\"script\" | \"SCRIPT\") Spnl HtmlAttribute* \">\"")
15848
16020
  Rules[:_HtmlBlockCloseScript] = rule_info("HtmlBlockCloseScript", "\"<\" Spnl \"/\" (\"script\" | \"SCRIPT\") Spnl \">\"")
15849
16021
  Rules[:_HtmlBlockScript] = rule_info("HtmlBlockScript", "HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript")
15850
- Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)")
16022
+ Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)")
15851
16023
  Rules[:_HtmlBlock] = rule_info("HtmlBlock", "< (HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) > @BlankLine+ { if html? then RDoc::Markup::Raw.new text end }")
15852
16024
  Rules[:_HtmlUnclosed] = rule_info("HtmlUnclosed", "\"<\" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl \">\"")
15853
16025
  Rules[:_HtmlUnclosedType] = rule_info("HtmlUnclosedType", "(\"HR\" | \"hr\")")
@@ -84,7 +84,7 @@
84
84
  #
85
85
  # markup.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
86
86
  #
87
- # wh = WikiHtml.new markup
87
+ # wh = WikiHtml.new RDoc::Options.new, markup
88
88
  # wh.add_tag(:STRIKE, "<strike>", "</strike>")
89
89
  #
90
90
  # puts "<body>#{wh.convert ARGF.read}</body>"
@@ -163,7 +163,7 @@
163
163
  #
164
164
  # The header's id would be:
165
165
  #
166
- # <h1 id="method-i-do_fun_things-label-Example">Example</h3>
166
+ # <h1 id="method-i-do_fun_things-label-Example">Example</h1>
167
167
  #
168
168
  # The label can be linked-to using <tt>SomeClass@Headers</tt>. See
169
169
  # {Links}[RDoc::Markup@Links] for further details.
@@ -130,7 +130,7 @@ class RDoc::Markup::AttributeManager
130
130
  # first do matching ones
131
131
  tags = @matching_word_pairs.keys.join("")
132
132
 
133
- re = /(^|\W)([#{tags}])([#:\\]?[\w.\/-]+?\S?)\2(\W|$)/
133
+ re = /(^|\W)([#{tags}])([#\\]?[\w:.\/-]+?\S?)\2(\W|$)/
134
134
 
135
135
  1 while str.gsub!(re) do
136
136
  attr = @matching_word_pairs[$2]
@@ -286,7 +286,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
286
286
  @res << to_html(heading.text)
287
287
  unless @options.pipe then
288
288
  @res << "<span><a href=\"##{label}\">&para;</a>"
289
- @res << " <a href=\"#documentation\">&uarr;</a></span>"
289
+ @res << " <a href=\"#top\">&uarr;</a></span>"
290
290
  end
291
291
  @res << "</h#{level}>\n"
292
292
  end
@@ -379,11 +379,12 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
379
379
  end
380
380
 
381
381
  ##
382
- # Returns true if Ripper is available it can create a sexp from +text+
382
+ # Returns true if text is valid ruby syntax
383
383
 
384
384
  def parseable? text
385
- text =~ /\b(def|class|module|require) |=>|\{\s?\||do \|/ and
386
- text !~ /<%|%>/
385
+ eval("BEGIN {return true}\n#{text}")
386
+ rescue SyntaxError
387
+ false
387
388
  end
388
389
 
389
390
  ##
@@ -31,7 +31,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
31
31
  def convert text
32
32
  label = convert_flow @am.flow text
33
33
 
34
- CGI.escape label
34
+ CGI.escape(label).gsub('%', '-').sub(/^-/, '')
35
35
  end
36
36
 
37
37
  ##
@@ -110,12 +110,15 @@ class RDoc::MethodAttr < RDoc::CodeObject
110
110
  # Order by #singleton then #name
111
111
 
112
112
  def <=>(other)
113
+ return unless other.respond_to?(:singleton) &&
114
+ other.respond_to?(:name)
115
+
113
116
  [ @singleton ? 0 : 1, name] <=>
114
117
  [other.singleton ? 0 : 1, other.name]
115
118
  end
116
119
 
117
120
  def == other # :nodoc:
118
- super or self.class == other.class and full_name == other.full_name
121
+ equal?(other) or self.class == other.class and full_name == other.full_name
119
122
  end
120
123
 
121
124
  ##
@@ -181,8 +184,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
181
184
  parent != kernel && !searched.include?(kernel)
182
185
 
183
186
  searched.each do |ancestor|
184
- next if parent == ancestor
185
187
  next if String === ancestor
188
+ next if parent == ancestor
186
189
 
187
190
  other = ancestor.find_method_named('#' << name) ||
188
191
  ancestor.find_attribute_named(name)
@@ -358,7 +361,12 @@ class RDoc::MethodAttr < RDoc::CodeObject
358
361
  end
359
362
 
360
363
  def pretty_print q # :nodoc:
361
- alias_for = @is_alias_for ? "alias for #{@is_alias_for.name}" : nil
364
+ alias_for =
365
+ if @is_alias_for.respond_to? :name then
366
+ "alias for #{@is_alias_for.name}"
367
+ elsif Array === @is_alias_for then
368
+ "alias for #{@is_alias_for.last}"
369
+ end
362
370
 
363
371
  q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
364
372
  if alias_for then
@@ -213,6 +213,16 @@ class RDoc::Options
213
213
 
214
214
  attr_accessor :line_numbers
215
215
 
216
+ ##
217
+ # The output locale.
218
+
219
+ attr_accessor :locale
220
+
221
+ ##
222
+ # The directory where locale data live.
223
+
224
+ attr_accessor :locale_dir
225
+
216
226
  ##
217
227
  # Name of the file, class or module to display in the initial index page (if
218
228
  # not specified the first file we encounter is used)
@@ -325,7 +335,7 @@ class RDoc::Options
325
335
  # other visibilities may be overridden on a per-method basis with the :doc:
326
336
  # directive.
327
337
 
328
- attr_accessor :visibility
338
+ attr_reader :visibility
329
339
 
330
340
  def initialize # :nodoc:
331
341
  init_ivars
@@ -343,6 +353,9 @@ class RDoc::Options
343
353
  @generators = RDoc::RDoc::GENERATORS
344
354
  @hyperlink_all = false
345
355
  @line_numbers = false
356
+ @locale = nil
357
+ @locale_name = nil
358
+ @locale_dir = 'locale'
346
359
  @main_page = nil
347
360
  @markup = 'rdoc'
348
361
  @coverage_report = false
@@ -388,6 +401,8 @@ class RDoc::Options
388
401
  @generator_name = map['generator_name']
389
402
  @hyperlink_all = map['hyperlink_all']
390
403
  @line_numbers = map['line_numbers']
404
+ @locale_name = map['locale_name']
405
+ @locale_dir = map['locale_dir']
391
406
  @main_page = map['main_page']
392
407
  @markup = map['markup']
393
408
  @op_dir = map['op_dir']
@@ -412,6 +427,8 @@ class RDoc::Options
412
427
  @generator_name == other.generator_name and
413
428
  @hyperlink_all == other.hyperlink_all and
414
429
  @line_numbers == other.line_numbers and
430
+ @locale == other.locale and
431
+ @locale_dir == other.locale_dir and
415
432
  @main_page == other.main_page and
416
433
  @markup == other.markup and
417
434
  @op_dir == other.op_dir and
@@ -515,6 +532,13 @@ class RDoc::Options
515
532
  @template_dir = template_dir_for @template
516
533
  end
517
534
 
535
+ if @locale_name
536
+ @locale = RDoc::I18n::Locale[@locale_name]
537
+ @locale.load(@locale_dir)
538
+ else
539
+ @locale = nil
540
+ end
541
+
518
542
  self
519
543
  end
520
544
 
@@ -677,6 +701,19 @@ Usage: #{opt.program_name} [options] [names...]
677
701
  opt.separator nil
678
702
  end
679
703
 
704
+
705
+ opt.on("--locale=NAME",
706
+ "Specifies the output locale.") do |value|
707
+ @locale_name = value
708
+ end
709
+
710
+ opt.on("--locale-data-dir=DIR",
711
+ "Specifies the directory where locale data live.") do |value|
712
+ @locale_dir = value
713
+ end
714
+
715
+ opt.separator nil
716
+
680
717
  opt.on("--all", "-a",
681
718
  "Synonym for --visibility=private.") do |value|
682
719
  @visibility = :private
@@ -1016,8 +1053,7 @@ Usage: #{opt.program_name} [options] [names...]
1016
1053
 
1017
1054
  opt.separator nil
1018
1055
 
1019
- opt.on("--help",
1020
- "Display this help") do
1056
+ opt.on("--help", "-h", "Display this help") do
1021
1057
  RDoc::RDoc::GENERATORS.each_key do |generator|
1022
1058
  setup_generator generator
1023
1059
  end
@@ -1174,6 +1210,22 @@ Usage: #{opt.program_name} [options] [names...]
1174
1210
  end
1175
1211
  end
1176
1212
 
1213
+ # Sets the minimum visibility of a documented method.
1214
+ #
1215
+ # Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+.
1216
+ #
1217
+ # When +:all+ is passed, visibility is set to +:private+, similarly to
1218
+ # RDOCOPT="--all", see #visibility for more information.
1219
+
1220
+ def visibility= visibility
1221
+ case visibility
1222
+ when :all
1223
+ @visibility = :private
1224
+ else
1225
+ @visibility = visibility
1226
+ end
1227
+ end
1228
+
1177
1229
  ##
1178
1230
  # Displays a warning using Kernel#warn if we're being verbose
1179
1231