rdoc.rb 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. $DEBUG_RDOC = nil
  2. # :main: README.rdoc
  3. ##
  4. # RDoc is a Ruby documentation system which contains RDoc::RDoc for generating
  5. # documentation, RDoc::RI for interactive documentation and RDoc::Markup for
  6. # text markup.
  7. #
  8. # RDoc::RDoc produces documentation for Ruby source files. It works similarly
  9. # to JavaDoc, parsing the source and extracting the definition for classes,
  10. # modules, methods, includes and requires. It associates these with optional
  11. # documentation contained in an immediately preceding comment block then
  12. # renders the result using an output formatter.
  13. #
  14. # RDoc::Markup that converts plain text into various output formats. The
  15. # markup library is used to interpret the comment blocks that RDoc uses to
  16. # document methods, classes, and so on.
  17. #
  18. # RDoc::RI implements the +ri+ command-line tool which displays on-line
  19. # documentation for ruby classes, methods, etc. +ri+ features several output
  20. # formats and an interactive mode (<tt>ri -i</tt>). See <tt>ri --help</tt>
  21. # for further details.
  22. #
  23. # == Roadmap
  24. #
  25. # * If you think you found a bug in RDoc see DEVELOPERS@Bugs
  26. # * If you want to use RDoc to create documentation for your Ruby source files,
  27. # see RDoc::Markup and refer to <tt>rdoc --help</tt> for command line
  28. # usage.
  29. # * If you want to store rdoc configuration in your gem see
  30. # RDoc::Options@Saved+Options
  31. # * If you want to write documentation for Ruby files see RDoc::Parser::Ruby
  32. # * If you want to write documentation for extensions written in C see
  33. # RDoc::Parser::C
  34. # * If you want to generate documentation using <tt>rake</tt> see RDoc::Task.
  35. # * If you want to drive RDoc programmatically, see RDoc::RDoc.
  36. # * If you want to use the library to format text blocks into HTML or other
  37. # formats, look at RDoc::Markup.
  38. # * If you want to make an RDoc plugin such as a generator or directive
  39. # handler see RDoc::RDoc.
  40. # * If you want to write your own output generator see RDoc::Generator.
  41. # * If you want an overview of how RDoc works see DEVELOPERS
  42. #
  43. # == Summary
  44. #
  45. # Once installed, you can create documentation using the +rdoc+ command
  46. #
  47. # % rdoc [options] [names...]
  48. #
  49. # For an up-to-date option summary, type
  50. #
  51. # % rdoc --help
  52. #
  53. # A typical use might be to generate documentation for a package of Ruby
  54. # source (such as RDoc itself).
  55. #
  56. # % rdoc
  57. #
  58. # This command generates documentation for all the Ruby and C source
  59. # files in and below the current directory. These will be stored in a
  60. # documentation tree starting in the subdirectory +doc+.
  61. #
  62. # You can make this slightly more useful for your readers by having the
  63. # index page contain the documentation for the primary file. In our
  64. # case, we could type
  65. #
  66. # % rdoc --main README.rdoc
  67. #
  68. # You'll find information on the various formatting tricks you can use
  69. # in comment blocks in the documentation this generates.
  70. #
  71. # RDoc uses file extensions to determine how to process each file. File names
  72. # ending +.rb+ and +.rbw+ are assumed to be Ruby source. Files
  73. # ending +.c+ are parsed as C files. All other files are assumed to
  74. # contain just Markup-style markup (with or without leading '#' comment
  75. # markers). If directory names are passed to RDoc, they are scanned
  76. # recursively for C and Ruby source files only.
  77. #
  78. # == Other stuff
  79. #
  80. # RDoc is currently being maintained by Eric Hodel <drbrain@segment7.net>.
  81. #
  82. # Dave Thomas <dave@pragmaticprogrammer.com> is the original author of RDoc.
  83. #
  84. # == Credits
  85. #
  86. # * The Ruby parser in rdoc/parse.rb is based heavily on the outstanding
  87. # work of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby
  88. # parser for irb and the rtags package.
  89. module RDoc
  90. ##
  91. # Exception thrown by any rdoc error.
  92. class Error < RuntimeError; end
  93. def self.const_missing const_name # :nodoc:
  94. if const_name.to_s == 'RDocError' then
  95. warn "RDoc::RDocError is deprecated and will be removed in RDoc 4"
  96. return Error
  97. end
  98. super
  99. end
  100. ##
  101. # RDoc version you are using
  102. VERSION = '3.12'
  103. ##
  104. # Method visibilities
  105. VISIBILITIES = [:public, :protected, :private]
  106. ##
  107. # Name of the dotfile that contains the description of files to be processed
  108. # in the current directory
  109. DOT_DOC_FILENAME = ".document"
  110. ##
  111. # General RDoc modifiers
  112. GENERAL_MODIFIERS = %w[nodoc].freeze
  113. ##
  114. # RDoc modifiers for classes
  115. CLASS_MODIFIERS = GENERAL_MODIFIERS
  116. ##
  117. # RDoc modifiers for attributes
  118. ATTR_MODIFIERS = GENERAL_MODIFIERS
  119. ##
  120. # RDoc modifiers for constants
  121. CONSTANT_MODIFIERS = GENERAL_MODIFIERS
  122. ##
  123. # RDoc modifiers for methods
  124. METHOD_MODIFIERS = GENERAL_MODIFIERS +
  125. %w[arg args yield yields notnew not-new not_new doc]
  126. ##
  127. # Loads the best available YAML library.
  128. def self.load_yaml
  129. begin
  130. gem 'psych'
  131. rescue Gem::LoadError
  132. end
  133. begin
  134. require 'psych'
  135. rescue ::LoadError
  136. ensure
  137. require 'yaml'
  138. end
  139. end
  140. autoload :RDoc, 'rdoc/rdoc'
  141. autoload :TestCase, 'rdoc/test_case'
  142. autoload :CrossReference, 'rdoc/cross_reference'
  143. autoload :ERBIO, 'rdoc/erbio'
  144. autoload :Encoding, 'rdoc/encoding'
  145. autoload :Generator, 'rdoc/generator'
  146. autoload :Options, 'rdoc/options'
  147. autoload :Parser, 'rdoc/parser'
  148. autoload :RI, 'rdoc/ri'
  149. autoload :Stats, 'rdoc/stats'
  150. autoload :Task, 'rdoc/task'
  151. autoload :Text, 'rdoc/text'
  152. autoload :Markup, 'rdoc/markup'
  153. autoload :RD, 'rdoc/rd'
  154. autoload :TomDoc, 'rdoc/tom_doc'
  155. autoload :KNOWN_CLASSES, 'rdoc/known_classes'
  156. autoload :RubyLex, 'rdoc/ruby_lex'
  157. autoload :RubyToken, 'rdoc/ruby_token'
  158. autoload :TokenStream, 'rdoc/token_stream'
  159. autoload :Comment, 'rdoc/comment'
  160. # code objects
  161. #
  162. # We represent the various high-level code constructs that appear in Ruby
  163. # programs: classes, modules, methods, and so on.
  164. autoload :CodeObject, 'rdoc/code_object'
  165. autoload :Context, 'rdoc/context'
  166. autoload :TopLevel, 'rdoc/top_level'
  167. autoload :AnonClass, 'rdoc/anon_class'
  168. autoload :ClassModule, 'rdoc/class_module'
  169. autoload :NormalClass, 'rdoc/normal_class'
  170. autoload :NormalModule, 'rdoc/normal_module'
  171. autoload :SingleClass, 'rdoc/single_class'
  172. autoload :Alias, 'rdoc/alias'
  173. autoload :AnyMethod, 'rdoc/any_method'
  174. autoload :MethodAttr, 'rdoc/method_attr'
  175. autoload :GhostMethod, 'rdoc/ghost_method'
  176. autoload :MetaMethod, 'rdoc/meta_method'
  177. autoload :Attr, 'rdoc/attr'
  178. autoload :Constant, 'rdoc/constant'
  179. autoload :Include, 'rdoc/include'
  180. autoload :Require, 'rdoc/require'
  181. end