gitlab-rdoc 6.3.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.
Files changed (196) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +220 -0
  3. data/CVE-2013-0256.rdoc +49 -0
  4. data/ExampleMarkdown.md +37 -0
  5. data/ExampleRDoc.rdoc +208 -0
  6. data/Gemfile +12 -0
  7. data/History.rdoc +1666 -0
  8. data/LEGAL.rdoc +50 -0
  9. data/LICENSE.rdoc +57 -0
  10. data/README.rdoc +133 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +101 -0
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/exe/rdoc +44 -0
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +112 -0
  19. data/lib/rdoc/anon_class.rb +11 -0
  20. data/lib/rdoc/any_method.rb +361 -0
  21. data/lib/rdoc/attr.rb +176 -0
  22. data/lib/rdoc/class_module.rb +802 -0
  23. data/lib/rdoc/code_object.rb +421 -0
  24. data/lib/rdoc/code_objects.rb +6 -0
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +187 -0
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +1266 -0
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +136 -0
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +42 -0
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +790 -0
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +160 -0
  37. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  38. data/lib/rdoc/generator/pot/po.rb +84 -0
  39. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  40. data/lib/rdoc/generator/pot.rb +98 -0
  41. data/lib/rdoc/generator/ri.rb +31 -0
  42. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  44. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  57. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  58. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  59. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  60. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  72. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  73. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  74. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  75. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  76. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  77. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  78. data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  79. data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  80. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  81. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  82. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  83. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  84. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  85. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  86. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  87. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  88. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  89. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  90. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  91. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  92. data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
  93. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
  94. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  95. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  96. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  97. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  98. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  99. data/lib/rdoc/generator/template/json_index/.document +1 -0
  100. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  101. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  102. data/lib/rdoc/generator.rb +51 -0
  103. data/lib/rdoc/ghost_method.rb +7 -0
  104. data/lib/rdoc/i18n/locale.rb +102 -0
  105. data/lib/rdoc/i18n/text.rb +126 -0
  106. data/lib/rdoc/i18n.rb +10 -0
  107. data/lib/rdoc/include.rb +10 -0
  108. data/lib/rdoc/known_classes.rb +73 -0
  109. data/lib/rdoc/markdown/entities.rb +2132 -0
  110. data/lib/rdoc/markdown/literals.kpeg +23 -0
  111. data/lib/rdoc/markdown/literals.rb +417 -0
  112. data/lib/rdoc/markdown.kpeg +1237 -0
  113. data/lib/rdoc/markdown.rb +16685 -0
  114. data/lib/rdoc/markup/attr_changer.rb +23 -0
  115. data/lib/rdoc/markup/attr_span.rb +36 -0
  116. data/lib/rdoc/markup/attribute_manager.rb +409 -0
  117. data/lib/rdoc/markup/attributes.rb +71 -0
  118. data/lib/rdoc/markup/blank_line.rb +28 -0
  119. data/lib/rdoc/markup/block_quote.rb +15 -0
  120. data/lib/rdoc/markup/document.rb +165 -0
  121. data/lib/rdoc/markup/formatter.rb +266 -0
  122. data/lib/rdoc/markup/hard_break.rb +32 -0
  123. data/lib/rdoc/markup/heading.rb +79 -0
  124. data/lib/rdoc/markup/include.rb +43 -0
  125. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  126. data/lib/rdoc/markup/list.rb +102 -0
  127. data/lib/rdoc/markup/list_item.rb +100 -0
  128. data/lib/rdoc/markup/paragraph.rb +29 -0
  129. data/lib/rdoc/markup/parser.rb +575 -0
  130. data/lib/rdoc/markup/pre_process.rb +296 -0
  131. data/lib/rdoc/markup/raw.rb +70 -0
  132. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  133. data/lib/rdoc/markup/rule.rb +21 -0
  134. data/lib/rdoc/markup/table.rb +47 -0
  135. data/lib/rdoc/markup/to_ansi.rb +94 -0
  136. data/lib/rdoc/markup/to_bs.rb +77 -0
  137. data/lib/rdoc/markup/to_html.rb +444 -0
  138. data/lib/rdoc/markup/to_html_crossref.rb +176 -0
  139. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  140. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  141. data/lib/rdoc/markup/to_label.rb +75 -0
  142. data/lib/rdoc/markup/to_markdown.rb +192 -0
  143. data/lib/rdoc/markup/to_rdoc.rb +362 -0
  144. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  145. data/lib/rdoc/markup/to_test.rb +70 -0
  146. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  147. data/lib/rdoc/markup/verbatim.rb +84 -0
  148. data/lib/rdoc/markup.rb +867 -0
  149. data/lib/rdoc/meta_method.rb +7 -0
  150. data/lib/rdoc/method_attr.rb +419 -0
  151. data/lib/rdoc/mixin.rb +121 -0
  152. data/lib/rdoc/normal_class.rb +93 -0
  153. data/lib/rdoc/normal_module.rb +74 -0
  154. data/lib/rdoc/options.rb +1285 -0
  155. data/lib/rdoc/parser/c.rb +1225 -0
  156. data/lib/rdoc/parser/changelog.rb +335 -0
  157. data/lib/rdoc/parser/markdown.rb +24 -0
  158. data/lib/rdoc/parser/rd.rb +23 -0
  159. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  160. data/lib/rdoc/parser/ruby.rb +2327 -0
  161. data/lib/rdoc/parser/ruby_tools.rb +167 -0
  162. data/lib/rdoc/parser/simple.rb +61 -0
  163. data/lib/rdoc/parser/text.rb +12 -0
  164. data/lib/rdoc/parser.rb +277 -0
  165. data/lib/rdoc/rd/block_parser.rb +1056 -0
  166. data/lib/rdoc/rd/block_parser.ry +639 -0
  167. data/lib/rdoc/rd/inline.rb +72 -0
  168. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  169. data/lib/rdoc/rd/inline_parser.ry +593 -0
  170. data/lib/rdoc/rd.rb +100 -0
  171. data/lib/rdoc/rdoc.rb +579 -0
  172. data/lib/rdoc/require.rb +52 -0
  173. data/lib/rdoc/ri/driver.rb +1572 -0
  174. data/lib/rdoc/ri/formatter.rb +6 -0
  175. data/lib/rdoc/ri/paths.rb +171 -0
  176. data/lib/rdoc/ri/store.rb +7 -0
  177. data/lib/rdoc/ri/task.rb +71 -0
  178. data/lib/rdoc/ri.rb +21 -0
  179. data/lib/rdoc/rubygems_hook.rb +246 -0
  180. data/lib/rdoc/servlet.rb +451 -0
  181. data/lib/rdoc/single_class.rb +26 -0
  182. data/lib/rdoc/stats/normal.rb +58 -0
  183. data/lib/rdoc/stats/quiet.rb +60 -0
  184. data/lib/rdoc/stats/verbose.rb +46 -0
  185. data/lib/rdoc/stats.rb +462 -0
  186. data/lib/rdoc/store.rb +979 -0
  187. data/lib/rdoc/task.rb +329 -0
  188. data/lib/rdoc/text.rb +304 -0
  189. data/lib/rdoc/token_stream.rb +119 -0
  190. data/lib/rdoc/tom_doc.rb +263 -0
  191. data/lib/rdoc/top_level.rb +289 -0
  192. data/lib/rdoc/version.rb +8 -0
  193. data/lib/rdoc.rb +201 -0
  194. data/man/ri.1 +247 -0
  195. data/rdoc.gemspec +249 -0
  196. metadata +279 -0
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # For RubyGems backwards compatibility
4
+
5
+ module RDoc::RI::Formatter # :nodoc:
6
+ end
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../rdoc'
3
+
4
+ ##
5
+ # The directories where ri data lives. Paths can be enumerated via ::each, or
6
+ # queried individually via ::system_dir, ::site_dir, ::home_dir and ::gem_dir.
7
+
8
+ module RDoc::RI::Paths
9
+
10
+ #:stopdoc:
11
+ require 'rbconfig'
12
+
13
+ version = RbConfig::CONFIG['ruby_version']
14
+
15
+ BASE = File.join RbConfig::CONFIG['ridir'], version
16
+
17
+ HOMEDIR = RDoc.home
18
+ #:startdoc:
19
+
20
+ ##
21
+ # Iterates over each selected path yielding the directory and type.
22
+ #
23
+ # Yielded types:
24
+ # :system:: Where Ruby's ri data is stored. Yielded when +system+ is
25
+ # true
26
+ # :site:: Where ri for installed libraries are stored. Yielded when
27
+ # +site+ is true. Normally no ri data is stored here.
28
+ # :home:: ~/.rdoc. Yielded when +home+ is true.
29
+ # :gem:: ri data for an installed gem. Yielded when +gems+ is true.
30
+ # :extra:: ri data directory from the command line. Yielded for each
31
+ # entry in +extra_dirs+
32
+
33
+ def self.each system = true, site = true, home = true, gems = :latest, *extra_dirs # :yields: directory, type
34
+ return enum_for __method__, system, site, home, gems, *extra_dirs unless
35
+ block_given?
36
+
37
+ extra_dirs.each do |dir|
38
+ yield dir, :extra
39
+ end
40
+
41
+ yield system_dir, :system if system
42
+ yield site_dir, :site if site
43
+ yield home_dir, :home if home and HOMEDIR
44
+
45
+ gemdirs(gems).each do |dir|
46
+ yield dir, :gem
47
+ end if gems
48
+
49
+ nil
50
+ end
51
+
52
+ ##
53
+ # The ri directory for the gem with +gem_name+.
54
+
55
+ def self.gem_dir name, version
56
+ req = Gem::Requirement.new "= #{version}"
57
+
58
+ spec = Gem::Specification.find_by_name name, req
59
+
60
+ File.join spec.doc_dir, 'ri'
61
+ end
62
+
63
+ ##
64
+ # The latest installed gems' ri directories. +filter+ can be :all or
65
+ # :latest.
66
+ #
67
+ # A +filter+ :all includes all versions of gems and includes gems without
68
+ # ri documentation.
69
+
70
+ def self.gemdirs filter = :latest
71
+ ri_paths = {}
72
+
73
+ all = Gem::Specification.map do |spec|
74
+ [File.join(spec.doc_dir, 'ri'), spec.name, spec.version]
75
+ end
76
+
77
+ if filter == :all then
78
+ gemdirs = []
79
+
80
+ all.group_by do |_, name, _|
81
+ name
82
+ end.sort_by do |group, _|
83
+ group
84
+ end.map do |group, items|
85
+ items.sort_by do |_, _, version|
86
+ version
87
+ end.reverse_each do |dir,|
88
+ gemdirs << dir
89
+ end
90
+ end
91
+
92
+ return gemdirs
93
+ end
94
+
95
+ all.each do |dir, name, ver|
96
+ next unless File.exist? dir
97
+
98
+ if ri_paths[name].nil? or ver > ri_paths[name].first then
99
+ ri_paths[name] = [ver, name, dir]
100
+ end
101
+ end
102
+
103
+ ri_paths.sort_by { |_, (_, name, _)| name }.map { |k, v| v.last }
104
+ rescue LoadError
105
+ []
106
+ end
107
+
108
+ ##
109
+ # The location of the rdoc data in the user's home directory.
110
+ #
111
+ # Like ::system, ri data in the user's home directory is rare and predates
112
+ # libraries distributed via RubyGems. ri data is rarely generated into this
113
+ # directory.
114
+
115
+ def self.home_dir
116
+ HOMEDIR
117
+ end
118
+
119
+ ##
120
+ # Returns existing directories from the selected documentation directories
121
+ # as an Array.
122
+ #
123
+ # See also ::each
124
+
125
+ def self.path(system = true, site = true, home = true, gems = :latest, *extra_dirs)
126
+ path = raw_path system, site, home, gems, *extra_dirs
127
+
128
+ path.select { |directory| File.directory? directory }
129
+ end
130
+
131
+ ##
132
+ # Returns selected documentation directories including nonexistent
133
+ # directories.
134
+ #
135
+ # See also ::each
136
+
137
+ def self.raw_path(system, site, home, gems, *extra_dirs)
138
+ path = []
139
+
140
+ each(system, site, home, gems, *extra_dirs) do |dir, type|
141
+ path << dir
142
+ end
143
+
144
+ path.compact
145
+ end
146
+
147
+ ##
148
+ # The location of ri data installed into the site dir.
149
+ #
150
+ # Historically this was available for documentation installed by Ruby
151
+ # libraries predating RubyGems. It is unlikely to contain any content for
152
+ # modern Ruby installations.
153
+
154
+ def self.site_dir
155
+ File.join BASE, 'site'
156
+ end
157
+
158
+ ##
159
+ # The location of the built-in ri data.
160
+ #
161
+ # This data is built automatically when `make` is run when Ruby is
162
+ # installed. If you did not install Ruby by hand you may need to install
163
+ # the documentation yourself. Please consult the documentation for your
164
+ # package manager or Ruby installer for details. You can also use the
165
+ # rdoc-data gem to install system ri data for common versions of Ruby.
166
+
167
+ def self.system_dir
168
+ File.join BASE, 'system'
169
+ end
170
+
171
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ module RDoc::RI
3
+
4
+ Store = RDoc::Store # :nodoc:
5
+
6
+ end
7
+
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+ begin
3
+ gem 'rdoc'
4
+ rescue Gem::LoadError
5
+ end unless defined?(RDoc)
6
+
7
+ require_relative '../task'
8
+
9
+ ##
10
+ # RDoc::RI::Task creates ri data in <code>./.rdoc</code> for your project.
11
+ #
12
+ # It contains the following tasks:
13
+ #
14
+ # [ri]
15
+ # Build ri data
16
+ #
17
+ # [clobber_ri]
18
+ # Delete ri data files. This target is automatically added to the main
19
+ # clobber target.
20
+ #
21
+ # [reri]
22
+ # Rebuild the ri data from scratch even if they are not out of date.
23
+ #
24
+ # Simple example:
25
+ #
26
+ # require 'rdoc/ri/task'
27
+ #
28
+ # RDoc::RI::Task.new do |ri|
29
+ # ri.main = 'README.rdoc'
30
+ # ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
31
+ # end
32
+ #
33
+ # For further configuration details see RDoc::Task.
34
+
35
+ class RDoc::RI::Task < RDoc::Task
36
+
37
+ DEFAULT_NAMES = { # :nodoc:
38
+ :clobber_rdoc => :clobber_ri,
39
+ :rdoc => :ri,
40
+ :rerdoc => :reri,
41
+ }
42
+
43
+ ##
44
+ # Create an ri task with the given name. See RDoc::Task for documentation on
45
+ # setting names.
46
+
47
+ def initialize name = DEFAULT_NAMES # :yield: self
48
+ super
49
+ end
50
+
51
+ def clobber_task_description # :nodoc:
52
+ "Remove RI data files"
53
+ end
54
+
55
+ ##
56
+ # Sets default task values
57
+
58
+ def defaults
59
+ super
60
+
61
+ @rdoc_dir = '.rdoc'
62
+ end
63
+
64
+ def rdoc_task_description # :nodoc:
65
+ 'Build RI data files'
66
+ end
67
+
68
+ def rerdoc_task_description # :nodoc:
69
+ 'Rebuild RI data files'
70
+ end
71
+ end
data/lib/rdoc/ri.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require 'rdoc'
3
+
4
+ ##
5
+ # Namespace for the ri command line tool's implementation.
6
+ #
7
+ # See <tt>ri --help</tt> for details.
8
+
9
+ module RDoc::RI
10
+
11
+ ##
12
+ # Base RI error class
13
+
14
+ class Error < RDoc::Error; end
15
+
16
+ autoload :Driver, 'rdoc/ri/driver'
17
+ autoload :Paths, 'rdoc/ri/paths'
18
+ autoload :Store, 'rdoc/ri/store'
19
+
20
+ end
21
+
@@ -0,0 +1,246 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/user_interaction'
3
+ require 'fileutils'
4
+ require 'rdoc'
5
+
6
+ ##
7
+ # Gem::RDoc provides methods to generate RDoc and ri data for installed gems
8
+ # upon gem installation.
9
+ #
10
+ # This file is automatically required by RubyGems 1.9 and newer.
11
+
12
+ class RDoc::RubygemsHook
13
+
14
+ include Gem::UserInteraction
15
+ extend Gem::UserInteraction
16
+
17
+ @rdoc_version = nil
18
+ @specs = []
19
+
20
+ ##
21
+ # Force installation of documentation?
22
+
23
+ attr_accessor :force
24
+
25
+ ##
26
+ # Generate rdoc?
27
+
28
+ attr_accessor :generate_rdoc
29
+
30
+ ##
31
+ # Generate ri data?
32
+
33
+ attr_accessor :generate_ri
34
+
35
+ class << self
36
+
37
+ ##
38
+ # Loaded version of RDoc. Set by ::load_rdoc
39
+
40
+ attr_reader :rdoc_version
41
+
42
+ end
43
+
44
+ ##
45
+ # Post installs hook that generates documentation for each specification in
46
+ # +specs+
47
+
48
+ def self.generation_hook installer, specs
49
+ start = Time.now
50
+ types = installer.document
51
+
52
+ generate_rdoc = types.include? 'rdoc'
53
+ generate_ri = types.include? 'ri'
54
+
55
+ specs.each do |spec|
56
+ new(spec, generate_rdoc, generate_ri).generate
57
+ end
58
+
59
+ return unless generate_rdoc or generate_ri
60
+
61
+ duration = (Time.now - start).to_i
62
+ names = specs.map(&:name).join ', '
63
+
64
+ say "Done installing documentation for #{names} after #{duration} seconds"
65
+ end
66
+
67
+ ##
68
+ # Loads the RDoc generator
69
+
70
+ def self.load_rdoc
71
+ return if @rdoc_version
72
+
73
+ require_relative 'rdoc'
74
+
75
+ @rdoc_version = Gem::Version.new ::RDoc::VERSION
76
+ end
77
+
78
+ ##
79
+ # Creates a new documentation generator for +spec+. RDoc and ri data
80
+ # generation can be enabled or disabled through +generate_rdoc+ and
81
+ # +generate_ri+ respectively.
82
+ #
83
+ # Only +generate_ri+ is enabled by default.
84
+
85
+ def initialize spec, generate_rdoc = false, generate_ri = true
86
+ @doc_dir = spec.doc_dir
87
+ @force = false
88
+ @rdoc = nil
89
+ @spec = spec
90
+
91
+ @generate_rdoc = generate_rdoc
92
+ @generate_ri = generate_ri
93
+
94
+ @rdoc_dir = spec.doc_dir 'rdoc'
95
+ @ri_dir = spec.doc_dir 'ri'
96
+ end
97
+
98
+ ##
99
+ # Removes legacy rdoc arguments from +args+
100
+ #--
101
+ # TODO move to RDoc::Options
102
+
103
+ def delete_legacy_args args
104
+ args.delete '--inline-source'
105
+ args.delete '--promiscuous'
106
+ args.delete '-p'
107
+ args.delete '--one-file'
108
+ end
109
+
110
+ ##
111
+ # Generates documentation using the named +generator+ ("darkfish" or "ri")
112
+ # and following the given +options+.
113
+ #
114
+ # Documentation will be generated into +destination+
115
+
116
+ def document generator, options, destination
117
+ generator_name = generator
118
+
119
+ options = options.dup
120
+ options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
121
+ options.setup_generator generator
122
+ options.op_dir = destination
123
+ options.finish
124
+
125
+ generator = options.generator.new @rdoc.store, options
126
+
127
+ @rdoc.options = options
128
+ @rdoc.generator = generator
129
+
130
+ say "Installing #{generator_name} documentation for #{@spec.full_name}"
131
+
132
+ FileUtils.mkdir_p options.op_dir
133
+
134
+ Dir.chdir options.op_dir do
135
+ begin
136
+ @rdoc.class.current = @rdoc
137
+ @rdoc.generator.generate
138
+ ensure
139
+ @rdoc.class.current = nil
140
+ end
141
+ end
142
+ end
143
+
144
+ ##
145
+ # Generates RDoc and ri data
146
+
147
+ def generate
148
+ return if @spec.default_gem?
149
+ return unless @generate_ri or @generate_rdoc
150
+
151
+ setup
152
+
153
+ options = nil
154
+
155
+ args = @spec.rdoc_options
156
+ args.concat @spec.source_paths
157
+ args.concat @spec.extra_rdoc_files
158
+
159
+ case config_args = Gem.configuration[:rdoc]
160
+ when String then
161
+ args = args.concat config_args.split(' ')
162
+ when Array then
163
+ args = args.concat config_args
164
+ end
165
+
166
+ delete_legacy_args args
167
+
168
+ Dir.chdir @spec.full_gem_path do
169
+ options = ::RDoc::Options.new
170
+ options.default_title = "#{@spec.full_name} Documentation"
171
+ options.parse args
172
+ end
173
+
174
+ options.quiet = !Gem.configuration.really_verbose
175
+
176
+ @rdoc = new_rdoc
177
+ @rdoc.options = options
178
+
179
+ store = RDoc::Store.new
180
+ store.encoding = options.encoding
181
+ store.dry_run = options.dry_run
182
+ store.main = options.main_page
183
+ store.title = options.title
184
+
185
+ @rdoc.store = store
186
+
187
+ say "Parsing documentation for #{@spec.full_name}"
188
+
189
+ Dir.chdir @spec.full_gem_path do
190
+ @rdoc.parse_files options.files
191
+ end
192
+
193
+ document 'ri', options, @ri_dir if
194
+ @generate_ri and (@force or not File.exist? @ri_dir)
195
+
196
+ document 'darkfish', options, @rdoc_dir if
197
+ @generate_rdoc and (@force or not File.exist? @rdoc_dir)
198
+ end
199
+
200
+ ##
201
+ # #new_rdoc creates a new RDoc instance. This method is provided only to
202
+ # make testing easier.
203
+
204
+ def new_rdoc # :nodoc:
205
+ ::RDoc::RDoc.new
206
+ end
207
+
208
+ ##
209
+ # Is rdoc documentation installed?
210
+
211
+ def rdoc_installed?
212
+ File.exist? @rdoc_dir
213
+ end
214
+
215
+ ##
216
+ # Removes generated RDoc and ri data
217
+
218
+ def remove
219
+ base_dir = @spec.base_dir
220
+
221
+ raise Gem::FilePermissionError, base_dir unless File.writable? base_dir
222
+
223
+ FileUtils.rm_rf @rdoc_dir
224
+ FileUtils.rm_rf @ri_dir
225
+ end
226
+
227
+ ##
228
+ # Is ri data installed?
229
+
230
+ def ri_installed?
231
+ File.exist? @ri_dir
232
+ end
233
+
234
+ ##
235
+ # Prepares the spec for documentation generation
236
+
237
+ def setup
238
+ self.class.load_rdoc
239
+
240
+ raise Gem::FilePermissionError, @doc_dir if
241
+ File.exist?(@doc_dir) and not File.writable?(@doc_dir)
242
+
243
+ FileUtils.mkdir_p @doc_dir unless File.exist? @doc_dir
244
+ end
245
+
246
+ end