rdoc 4.0.0.preview2 → 4.0.0.preview2.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +4 -1
  5. data/History.rdoc +26 -1
  6. data/Manifest.txt +2 -0
  7. data/Rakefile +1 -1
  8. data/lib/rdoc.rb +1 -1
  9. data/lib/rdoc/class_module.rb +13 -2
  10. data/lib/rdoc/context.rb +7 -5
  11. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +7 -1
  12. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +1 -1
  13. data/lib/rdoc/markdown/entities.rb +3 -0
  14. data/lib/rdoc/markup/document.rb +8 -8
  15. data/lib/rdoc/markup/formatter.rb +6 -1
  16. data/lib/rdoc/markup/heading.rb +2 -1
  17. data/lib/rdoc/markup/to_joined_paragraph.rb +5 -2
  18. data/lib/rdoc/markup/to_table_of_contents.rb +27 -1
  19. data/lib/rdoc/options.rb +36 -1
  20. data/lib/rdoc/parser.rb +30 -1
  21. data/lib/rdoc/parser/c.rb +56 -14
  22. data/lib/rdoc/parser/changelog.rb +186 -0
  23. data/lib/rdoc/parser/ruby.rb +53 -11
  24. data/lib/rdoc/rdoc.rb +9 -0
  25. data/lib/rdoc/ri/driver.rb +5 -1
  26. data/lib/rdoc/ruby_lex.rb +1 -1
  27. data/lib/rdoc/rubygems_hook.rb +16 -10
  28. data/lib/rdoc/servlet.rb +111 -6
  29. data/lib/rdoc/store.rb +110 -19
  30. data/test/test_rdoc_class_module.rb +32 -0
  31. data/test/test_rdoc_context.rb +25 -0
  32. data/test/test_rdoc_markup_document.rb +19 -0
  33. data/test/test_rdoc_markup_to_table_of_contents.rb +31 -0
  34. data/test/test_rdoc_options.rb +38 -0
  35. data/test/test_rdoc_parser.rb +56 -0
  36. data/test/test_rdoc_parser_c.rb +129 -6
  37. data/test/test_rdoc_parser_changelog.rb +294 -0
  38. data/test/test_rdoc_parser_ruby.rb +145 -8
  39. data/test/test_rdoc_rdoc.rb +25 -5
  40. data/test/test_rdoc_ri_driver.rb +27 -0
  41. data/test/test_rdoc_ruby_lex.rb +10 -0
  42. data/test/test_rdoc_rubygems_hook.rb +49 -18
  43. data/test/test_rdoc_store.rb +148 -37
  44. metadata +26 -23
  45. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: bd558c2cff419547ec57eda5fe512659e1dd04b4
4
- data.tar.gz: 1981e42e56784ea75c8bd9b9428e3da5c3ec695b
3
+ metadata.gz: be465a9f7229b4fa46271d90e7102066498c0b4d
4
+ data.tar.gz: f5297b952027d39046fcea6d3c4ead0fe569f40c
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: c3cebbb886df27b7ffb2288b958247f84e7b6a286dc0438544012d51d8402e804f84099ea421277c40b26b82f70c5c83d47a72bfe395c183273f885355925f98
7
- data.tar.gz: be6380482a950fd82393784de7df78027ea3ea70f83d2e863041a9400fd56e84ace8f5a240a1247b7e4c36745b004ea810893e332b54b9aa43d0762691d26314
6
+ metadata.gz: a4bbe645b202903651d0b3fa0d79bd331c2b7becd9d7feed0d24d215821a6625c27f6db475d3c495ddc3652651afe00c75d7c3a7dadad7c97948c7934c7d675a
7
+ data.tar.gz: 297ea3814b07df111090a99500b10f9f9a4e99448e9626b1f304d659e4b5d1fdf03a8f60562ecb25448e74e661efeae87d982f67a84f857c06db8ca9319cc527
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.autotest CHANGED
@@ -15,7 +15,10 @@ Autotest.add_hook :initialize do |at|
15
15
  f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
16
16
  f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
17
17
  f = f.map { |path| path =~ /^Test/ ? path : "Test#{path}" }
18
- f.join('::').gsub('Rdoc', 'RDoc').gsub('Ri', 'RI')
18
+ f.join('::').
19
+ gsub('Rdoc', 'RDoc').
20
+ gsub('Ri', 'RI').
21
+ gsub('Changelog', 'ChangeLog')
19
22
  end
20
23
  end
21
24
 
@@ -1,4 +1,4 @@
1
- === 4.0.0.preview2
1
+ === 4.0.0.preview2.1 / 2012-12-14
2
2
 
3
3
  As a preview release, please file bugs for any problems you have with rdoc at
4
4
  https://github.com/rdoc/rdoc/issues
@@ -10,6 +10,29 @@ Notable feature additions are markdown support and an WEBrick servlet that can
10
10
  serve HTML from an ri store. (This means that RubyGems 2.0+ no longer needs
11
11
  to build HTML documentation when installing gems.)
12
12
 
13
+ * Minor enhancements
14
+ * Added --page-dir option to give pretty names for a FAQ, guides, or other
15
+ documentation you write that is not stored in the project root. For
16
+ example, with the following layout:
17
+
18
+ README.txt
19
+ guides/syntax.txt
20
+ guides/conversion.txt
21
+
22
+ Running `rdoc --page-dir guides` will make the files in "guides" appear to
23
+ be at the top level of the project. This means they will appear to exist
24
+ at the top level in HTML output and you can access them with
25
+ `ri your_gem:syntax` and `ri your_gem:conversion`.
26
+
27
+ * Bug fixes
28
+ * Fully qualified names for constants declared from the top level are now
29
+ attached to their class or module properly.
30
+ * Fixed table of contents display in HTML output for classes and modules.
31
+ * Incremental ri builds of C files now work. C variable names from previous
32
+ runs are now saved between runs.
33
+
34
+ === 4.0.0.preview2 / 2012-12-01
35
+
13
36
  * Breaking changes
14
37
  * The default output encoding for RDoc is now UTF-8. Previously RDoc used
15
38
  the default external encoding which was determined from your locale.
@@ -79,6 +102,8 @@ to build HTML documentation when installing gems.)
79
102
 
80
103
  * Minor enhancements
81
104
  * Added --root for building documentation from outside the source dir.
105
+ * Added a ChangeLog parser. It automatically parses files that begin
106
+ with 'ChangeLog'
82
107
  * Added a table of contents to the sidebar.
83
108
  * RDoc markup format merges adjacent labels in a label or note list into a
84
109
  single definition list item for output.
@@ -141,6 +141,7 @@ lib/rdoc/normal_module.rb
141
141
  lib/rdoc/options.rb
142
142
  lib/rdoc/parser.rb
143
143
  lib/rdoc/parser/c.rb
144
+ lib/rdoc/parser/changelog.rb
144
145
  lib/rdoc/parser/markdown.rb
145
146
  lib/rdoc/parser/rd.rb
146
147
  lib/rdoc/parser/ruby.rb
@@ -256,6 +257,7 @@ test/test_rdoc_normal_module.rb
256
257
  test/test_rdoc_options.rb
257
258
  test/test_rdoc_parser.rb
258
259
  test/test_rdoc_parser_c.rb
260
+ test/test_rdoc_parser_changelog.rb
259
261
  test/test_rdoc_parser_markdown.rb
260
262
  test/test_rdoc_parser_rd.rb
261
263
  test/test_rdoc_parser_ruby.rb
data/Rakefile CHANGED
@@ -103,7 +103,7 @@ task "#{path}.gem" => package_parser_files
103
103
  # RUBINIUS_PATH.
104
104
 
105
105
  diff_options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
106
- rsync_options = "-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc' --exclude '*.rej' --exclude '*.orig'"
106
+ rsync_options = "-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc' --exclude '*.rej' --exclude '*.orig' --exclude '*.kpeg' --exclude '*.ry' --exclude 'literals_1_8.rb' --exclude 'gauntlet_rdoc.rb'"
107
107
 
108
108
  rubinius_dir = ENV['RUBINIUS_PATH'] || '../../../git/git.rubini.us/code'
109
109
  ruby_dir = ENV['RUBY_PATH'] || '../../svn/ruby/trunk'
@@ -64,7 +64,7 @@ module RDoc
64
64
  ##
65
65
  # RDoc version you are using
66
66
 
67
- VERSION = '4.0.0.preview2'
67
+ VERSION = '4.0.0.preview2.1'
68
68
 
69
69
  ##
70
70
  # Method visibilities
@@ -31,7 +31,7 @@ class RDoc::ClassModule < RDoc::Context
31
31
  ##
32
32
  # Comment and the location it came from. Use #add_comment to add comments
33
33
 
34
- attr_reader :comment_location
34
+ attr_accessor :comment_location
35
35
 
36
36
  attr_accessor :diagram # :nodoc:
37
37
 
@@ -134,6 +134,9 @@ class RDoc::ClassModule < RDoc::Context
134
134
  else
135
135
  normalize_comment comment
136
136
  end
137
+
138
+ @comment_location.delete_if { |(_, l)| l == location }
139
+
137
140
  @comment_location << [comment, location]
138
141
 
139
142
  self.comment = original
@@ -184,7 +187,7 @@ class RDoc::ClassModule < RDoc::Context
184
187
  # Appends +comment+ to the current comment, but separated by a rule. Works
185
188
  # more like <tt>+=</tt>.
186
189
 
187
- def comment= comment
190
+ def comment= comment # :nodoc:
188
191
  comment = case comment
189
192
  when RDoc::Comment then
190
193
  comment.normalize
@@ -216,6 +219,14 @@ class RDoc::ClassModule < RDoc::Context
216
219
  document_self || method_list.any?{ |m| m.document_self }
217
220
  end
218
221
 
222
+ ##
223
+ # Does this class or module have a comment with content or is
224
+ # #received_nodoc true?
225
+
226
+ def documented?
227
+ super or !@comment_location.empty?
228
+ end
229
+
219
230
  ##
220
231
  # Iterates the ancestors of this class or module for which an
221
232
  # RDoc::ClassModule exists.
@@ -447,11 +447,13 @@ class RDoc::Context < RDoc::CodeObject
447
447
  known = @methods_hash[key]
448
448
 
449
449
  if known then
450
- known.comment = method.comment if known.comment.empty?
451
- previously = ", previously in #{known.file}" unless
452
- method.file == known.file
453
- @store.rdoc.options.warn \
454
- "Duplicate method #{known.full_name} in #{method.file}#{previously}"
450
+ if @store then # otherwise we are loading
451
+ known.comment = method.comment if known.comment.empty?
452
+ previously = ", previously in #{known.file}" unless
453
+ method.file == known.file
454
+ @store.rdoc.options.warn \
455
+ "Duplicate method #{known.full_name} in #{method.file}#{previously}"
456
+ end
455
457
  else
456
458
  @methods_hash[key] = method
457
459
  method.visibility = @visibility
@@ -1,4 +1,10 @@
1
- <% table = current.parse(current.comment).table_of_contents
1
+ <% comment = if current.respond_to? :comment_location then
2
+ current.comment_location
3
+ else
4
+ current.comment
5
+ end
6
+ table = current.parse(comment).table_of_contents
7
+
2
8
  if table.length > 1 then %>
3
9
  <div id="table-of-contents">
4
10
  <nav class="section">
@@ -30,7 +30,7 @@
30
30
  <li class="<%= klass.type %>">
31
31
  <a href="<%= klass.path %>"><%= klass.full_name %></a>
32
32
  <% table = []
33
- table.concat klass.parse(klass.comment).table_of_contents
33
+ table.concat klass.parse(klass.comment_location).table_of_contents
34
34
  table.concat klass.section_contents
35
35
 
36
36
  unless table.empty? then %>
@@ -1,3 +1,6 @@
1
+ ##
2
+ # HTML entity name map for RDoc::Markdown
3
+
1
4
  RDoc::Markdown::HTML_ENTITIES = {
2
5
  "AElig" => [0x000C6],
3
6
  "AMP" => [0x00026],
@@ -11,6 +11,12 @@ class RDoc::Markup::Document
11
11
 
12
12
  attr_reader :file
13
13
 
14
+ ##
15
+ # If a heading is below the given level it will be omitted from the
16
+ # table_of_contents
17
+
18
+ attr_accessor :omit_headings_below
19
+
14
20
  ##
15
21
  # The parts of the Document
16
22
 
@@ -24,6 +30,7 @@ class RDoc::Markup::Document
24
30
  @parts.concat parts
25
31
 
26
32
  @file = nil
33
+ @omit_headings_from_table_of_contents_below = nil
27
34
  end
28
35
 
29
36
  ##
@@ -57,14 +64,7 @@ class RDoc::Markup::Document
57
64
  def accept visitor
58
65
  visitor.start_accepting
59
66
 
60
- @parts.each do |item|
61
- case item
62
- when RDoc::Markup::Document then # HACK
63
- visitor.accept_document item
64
- else
65
- item.accept visitor
66
- end
67
- end
67
+ visitor.accept_document self
68
68
 
69
69
  visitor.end_accepting
70
70
  end
@@ -42,7 +42,12 @@ class RDoc::Markup::Formatter
42
42
 
43
43
  def accept_document document
44
44
  document.parts.each do |item|
45
- item.accept self
45
+ case item
46
+ when RDoc::Markup::Document then # HACK
47
+ accept_document item
48
+ else
49
+ item.accept self
50
+ end
46
51
  end
47
52
  end
48
53
 
@@ -1,7 +1,8 @@
1
1
  ##
2
2
  # A heading with a level (1-6) and text
3
3
 
4
- class RDoc::Markup::Heading < Struct.new :level, :text
4
+ RDoc::Markup::Heading =
5
+ Struct.new :level, :text do
5
6
 
6
7
  @to_html = nil
7
8
  @to_label = nil
@@ -12,12 +12,15 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
12
12
  super nil
13
13
  end
14
14
 
15
- def start_accepting
15
+ def start_accepting # :nodoc:
16
16
  end
17
17
 
18
- def end_accepting
18
+ def end_accepting # :nodoc:
19
19
  end
20
20
 
21
+ ##
22
+ # Converts the parts of +paragraph+ to a single entry.
23
+
21
24
  def accept_paragraph paragraph
22
25
  parts = []
23
26
  string = false
@@ -18,15 +18,31 @@ class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
18
18
 
19
19
  attr_reader :res
20
20
 
21
+ ##
22
+ # Omits headings with a level less than the given level.
23
+
24
+ attr_accessor :omit_headings_below
25
+
21
26
  def initialize # :nodoc:
22
27
  super nil
28
+
29
+ @omit_headings_below = nil
30
+ end
31
+
32
+ ##
33
+ # Adds +document+ to the output, using its heading cutoff if present
34
+
35
+ def accept_document document
36
+ @omit_headings_below = document.omit_headings_below
37
+
38
+ super
23
39
  end
24
40
 
25
41
  ##
26
42
  # Adds +heading+ to the table of contents
27
43
 
28
44
  def accept_heading heading
29
- @res << heading
45
+ @res << heading unless suppressed? heading
30
46
  end
31
47
 
32
48
  ##
@@ -40,9 +56,19 @@ class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
40
56
  # Prepares the visitor for text generation
41
57
 
42
58
  def start_accepting
59
+ @omit_headings_below = nil
43
60
  @res = []
44
61
  end
45
62
 
63
+ ##
64
+ # Returns true if +heading+ is below the display threshold
65
+
66
+ def suppressed? heading
67
+ return false unless @omit_headings_below
68
+
69
+ heading.level > @omit_headings_below
70
+ end
71
+
46
72
  # :stopdoc:
47
73
  alias accept_block_quote ignore
48
74
  alias accept_raw ignore
@@ -228,6 +228,12 @@ class RDoc::Options
228
228
 
229
229
  attr_accessor :option_parser
230
230
 
231
+ ##
232
+ # Directory where guides, FAQ, and other pages not associated with a class
233
+ # live. You may leave this unset if these are at the root of your project.
234
+
235
+ attr_accessor :page_dir
236
+
231
237
  ##
232
238
  # Is RDoc in pipe mode?
233
239
 
@@ -317,6 +323,7 @@ class RDoc::Options
317
323
  @markup = 'rdoc'
318
324
  @coverage_report = false
319
325
  @op_dir = nil
326
+ @page_dir = nil
320
327
  @pipe = false
321
328
  @rdoc_include = []
322
329
  @root = Pathname(Dir.pwd)
@@ -468,6 +475,8 @@ class RDoc::Options
468
475
  @exclude = Regexp.new(@exclude.join("|"))
469
476
  end
470
477
 
478
+ finish_page_dir
479
+
471
480
  check_files
472
481
 
473
482
  # If no template was specified, use the default template for the output
@@ -481,6 +490,20 @@ class RDoc::Options
481
490
  self
482
491
  end
483
492
 
493
+ ##
494
+ # Fixes the page_dir to be relative to the root_dir and adds the page_dir to
495
+ # the files list.
496
+
497
+ def finish_page_dir
498
+ return unless @page_dir
499
+
500
+ @files << @page_dir.to_s
501
+
502
+ page_dir = @page_dir.expand_path.relative_path_from @root
503
+
504
+ @page_dir = page_dir
505
+ end
506
+
484
507
  ##
485
508
  # Returns a properly-space list of generators and their descriptions.
486
509
 
@@ -665,7 +688,7 @@ Usage: #{opt.program_name} [options] [names...]
665
688
 
666
689
  opt.separator nil
667
690
 
668
- opt.on("--pipe",
691
+ opt.on("--pipe", "-p",
669
692
  "Convert RDoc on stdin to HTML") do
670
693
  @pipe = true
671
694
  end
@@ -708,6 +731,18 @@ Usage: #{opt.program_name} [options] [names...]
708
731
  @root = Pathname(root)
709
732
  end
710
733
 
734
+ opt.separator nil
735
+
736
+ opt.on("--page-dir=DIR", Directory,
737
+ "Directory where guides, your FAQ or",
738
+ "other pages not associated with a class",
739
+ "live. Set this when you don't store",
740
+ "such files at your project root.",
741
+ "NOTE: Do not use the same file name in",
742
+ "the page dir and the root of your project") do |page_dir|
743
+ @page_dir = Pathname(page_dir)
744
+ end
745
+
711
746
  opt.separator nil
712
747
  opt.separator "Common generator options:"
713
748
  opt.separator nil
@@ -1,3 +1,5 @@
1
+ # -*- coding: us-ascii -*-
2
+
1
3
  ##
2
4
  # A parser is simple a class that subclasses RDoc::Parser and implements #scan
3
5
  # to fill in an RDoc::TopLevel with parsed data.
@@ -138,12 +140,38 @@ class RDoc::Parser
138
140
  # The default parser must not parse binary files
139
141
  ext_name = File.extname file_name
140
142
  return parser if ext_name.empty?
141
- return if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/
143
+ if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ then
144
+ case check_modeline file_name
145
+ when 'rdoc' then # continue
146
+ else return nil
147
+ end
148
+ end
142
149
 
143
150
  parser
144
151
  rescue Errno::EACCES
145
152
  end
146
153
 
154
+ ##
155
+ # Returns the file type from the modeline in +file_name+
156
+
157
+ def self.check_modeline file_name
158
+ line = open file_name do |io|
159
+ io.gets
160
+ end
161
+
162
+ /-\*-\s*(.*?\S)\s*-\*-/ =~ line
163
+
164
+ return nil unless type = $1
165
+
166
+ if /;/ =~ type then
167
+ return nil unless /(?:\s|\A)mode:\s*([^\s;]+)/i =~ type
168
+ type = $1
169
+ end
170
+
171
+ type.downcase
172
+ rescue ArgumentError # invalid byte sequence, etc.
173
+ end
174
+
147
175
  ##
148
176
  # Finds and instantiates the correct parser for the given +file_name+ and
149
177
  # +content+.
@@ -240,6 +268,7 @@ end
240
268
  # simple must come first in order to show up last in the parsers list
241
269
  require 'rdoc/parser/simple'
242
270
  require 'rdoc/parser/c'
271
+ require 'rdoc/parser/changelog'
243
272
  require 'rdoc/parser/markdown'
244
273
  require 'rdoc/parser/rd'
245
274
  require 'rdoc/parser/ruby'