PageRenderTime 59ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/preinstalled-gems/data/gems/rdoc-2.5.1/lib/rdoc/parser/c.rb

http://github.com/rubinius/rubinius
Ruby | 708 lines | 453 code | 90 blank | 165 comment | 49 complexity | 3d640ee715f43e04f4c6b5c408d32827 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, 0BSD, GPL-2.0, LGPL-2.1
  1. require 'rdoc/parser'
  2. require 'rdoc/parser/ruby'
  3. require 'rdoc/known_classes'
  4. ##
  5. # We attempt to parse C extension files. Basically we look for
  6. # the standard patterns that you find in extensions: <tt>rb_define_class,
  7. # rb_define_method</tt> and so on. We also try to find the corresponding
  8. # C source for the methods and extract comments, but if we fail
  9. # we don't worry too much.
  10. #
  11. # The comments associated with a Ruby method are extracted from the C
  12. # comment block associated with the routine that _implements_ that
  13. # method, that is to say the method whose name is given in the
  14. # <tt>rb_define_method</tt> call. For example, you might write:
  15. #
  16. # /*
  17. # * Returns a new array that is a one-dimensional flattening of this
  18. # * array (recursively). That is, for every element that is an array,
  19. # * extract its elements into the new array.
  20. # *
  21. # * s = [ 1, 2, 3 ] #=> [1, 2, 3]
  22. # * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
  23. # * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
  24. # * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  25. # */
  26. # static VALUE
  27. # rb_ary_flatten(ary)
  28. # VALUE ary;
  29. # {
  30. # ary = rb_obj_dup(ary);
  31. # rb_ary_flatten_bang(ary);
  32. # return ary;
  33. # }
  34. #
  35. # ...
  36. #
  37. # void
  38. # Init_Array()
  39. # {
  40. # ...
  41. # rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
  42. #
  43. # Here RDoc will determine from the rb_define_method line that there's a
  44. # method called "flatten" in class Array, and will look for the implementation
  45. # in the method rb_ary_flatten. It will then use the comment from that
  46. # method in the HTML output. This method must be in the same source file
  47. # as the rb_define_method.
  48. #
  49. # The comment blocks may include special directives:
  50. #
  51. # [Document-class: <i>name</i>]
  52. # This comment block is documentation for the given class. Use this
  53. # when the <tt>Init_xxx</tt> method is not named after the class.
  54. #
  55. # [Document-method: <i>name</i>]
  56. # This comment documents the named method. Use when RDoc cannot
  57. # automatically find the method from it's declaration
  58. #
  59. # [call-seq: <i>text up to an empty line</i>]
  60. # Because C source doesn't give descripive names to Ruby-level parameters,
  61. # you need to document the calling sequence explicitly
  62. #
  63. # In addition, RDoc assumes by default that the C method implementing a
  64. # Ruby function is in the same source file as the rb_define_method call.
  65. # If this isn't the case, add the comment:
  66. #
  67. # rb_define_method(....); // in filename
  68. #
  69. # As an example, we might have an extension that defines multiple classes
  70. # in its Init_xxx method. We could document them using
  71. #
  72. # /*
  73. # * Document-class: MyClass
  74. # *
  75. # * Encapsulate the writing and reading of the configuration
  76. # * file. ...
  77. # */
  78. #
  79. # /*
  80. # * Document-method: read_value
  81. # *
  82. # * call-seq:
  83. # * cfg.read_value(key) -> value
  84. # * cfg.read_value(key} { |key| } -> value
  85. # *
  86. # * Return the value corresponding to +key+ from the configuration.
  87. # * In the second form, if the key isn't found, invoke the
  88. # * block and return its value.
  89. # */
  90. class RDoc::Parser::C < RDoc::Parser
  91. parse_files_matching(/\.(?:([CcHh])\1?|c([+xp])\2|y)\z/)
  92. include RDoc::Text
  93. ##
  94. # C file the parser is parsing
  95. attr_accessor :content
  96. ##
  97. # Resets cross-file state. Call when parsing different projects that need
  98. # separate documentation.
  99. def self.reset
  100. @@enclosure_classes = {}
  101. @@known_bodies = {}
  102. end
  103. reset
  104. ##
  105. # Prepare to parse a C file
  106. def initialize(top_level, file_name, content, options, stats)
  107. super
  108. @known_classes = RDoc::KNOWN_CLASSES.dup
  109. @content = handle_tab_width handle_ifdefs_in(@content)
  110. @classes = Hash.new
  111. @file_dir = File.dirname(@file_name)
  112. end
  113. def do_aliases
  114. @content.scan(%r{rb_define_alias\s*\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
  115. |var_name, new_name, old_name|
  116. class_name = @known_classes[var_name] || var_name
  117. class_obj = find_class(var_name, class_name)
  118. as = class_obj.add_alias RDoc::Alias.new("", old_name, new_name, "")
  119. @stats.add_alias as
  120. end
  121. end
  122. def do_classes
  123. @content.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
  124. |var_name, class_name|
  125. handle_class_module(var_name, "module", class_name, nil, nil)
  126. end
  127. # The '.' lets us handle SWIG-generated files
  128. @content.scan(/([\w\.]+)\s* = \s*rb_define_class\s*
  129. \(
  130. \s*"(\w+)",
  131. \s*(\w+)\s*
  132. \)/mx) do |var_name, class_name, parent|
  133. handle_class_module(var_name, "class", class_name, parent, nil)
  134. end
  135. @content.scan(/(\w+)\s*=\s*boot_defclass\s*\(\s*"(\w+?)",\s*(\w+?)\s*\)/) do
  136. |var_name, class_name, parent|
  137. parent = nil if parent == "0"
  138. handle_class_module(var_name, "class", class_name, parent, nil)
  139. end
  140. @content.scan(/(\w+)\s* = \s*rb_define_module_under\s*
  141. \(
  142. \s*(\w+),
  143. \s*"(\w+)"
  144. \s*\)/mx) do |var_name, in_module, class_name|
  145. handle_class_module(var_name, "module", class_name, nil, in_module)
  146. end
  147. @content.scan(/([\w\.]+)\s* = \s*rb_define_class_under\s*
  148. \(
  149. \s*(\w+),
  150. \s*"(\w+)",
  151. \s*([\w\*\s\(\)\.\->]+)\s* # for SWIG
  152. \s*\)/mx) do |var_name, in_module, class_name, parent|
  153. handle_class_module(var_name, "class", class_name, parent, in_module)
  154. end
  155. end
  156. def do_constants
  157. @content.scan(%r{\Wrb_define_
  158. ( variable |
  159. readonly_variable |
  160. const |
  161. global_const | )
  162. \s*\(
  163. (?:\s*(\w+),)?
  164. \s*"(\w+)",
  165. \s*(.*?)\s*\)\s*;
  166. }xm) do |type, var_name, const_name, definition|
  167. var_name = "rb_cObject" if !var_name or var_name == "rb_mKernel"
  168. handle_constants type, var_name, const_name, definition
  169. end
  170. end
  171. ##
  172. # Look for includes of the form:
  173. #
  174. # rb_include_module(rb_cArray, rb_mEnumerable);
  175. def do_includes
  176. @content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
  177. if cls = @classes[c]
  178. m = @known_classes[m] || m
  179. cls.add_include RDoc::Include.new(m, "")
  180. end
  181. end
  182. end
  183. def do_methods
  184. @content.scan(%r{rb_define_
  185. (
  186. singleton_method |
  187. method |
  188. module_function |
  189. private_method
  190. )
  191. \s*\(\s*([\w\.]+),
  192. \s*"([^"]+)",
  193. \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
  194. \s*(-?\w+)\s*\)
  195. (?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
  196. }xm) do
  197. |type, var_name, meth_name, meth_body, param_count, source_file|
  198. # Ignore top-object and weird struct.c dynamic stuff
  199. next if var_name == "ruby_top_self"
  200. next if var_name == "nstr"
  201. next if var_name == "envtbl"
  202. next if var_name == "argf" # it'd be nice to handle this one
  203. var_name = "rb_cObject" if var_name == "rb_mKernel"
  204. handle_method(type, var_name, meth_name, meth_body, param_count,
  205. source_file)
  206. end
  207. @content.scan(%r{rb_define_attr\(
  208. \s*([\w\.]+),
  209. \s*"([^"]+)",
  210. \s*(\d+),
  211. \s*(\d+)\s*\);
  212. }xm) do |var_name, attr_name, attr_reader, attr_writer|
  213. #var_name = "rb_cObject" if var_name == "rb_mKernel"
  214. handle_attr(var_name, attr_name,
  215. attr_reader.to_i != 0,
  216. attr_writer.to_i != 0)
  217. end
  218. @content.scan(%r{rb_define_global_function\s*\(
  219. \s*"([^"]+)",
  220. \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
  221. \s*(-?\w+)\s*\)
  222. (?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
  223. }xm) do |meth_name, meth_body, param_count, source_file|
  224. handle_method("method", "rb_mKernel", meth_name,
  225. meth_body, param_count, source_file)
  226. end
  227. @content.scan(/define_filetest_function\s*\(
  228. \s*"([^"]+)",
  229. \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
  230. \s*(-?\w+)\s*\)/xm) do
  231. |meth_name, meth_body, param_count|
  232. handle_method("method", "rb_mFileTest", meth_name, meth_body, param_count)
  233. handle_method("singleton_method", "rb_cFile", meth_name, meth_body, param_count)
  234. end
  235. end
  236. def find_attr_comment(attr_name)
  237. if @content =~ %r{((?>/\*.*?\*/\s+))
  238. rb_define_attr\((?:\s*(\w+),)?\s*"#{attr_name}"\s*,.*?\)\s*;}xmi
  239. $1
  240. elsif @content =~ %r{Document-attr:\s#{attr_name}\s*?\n((?>.*?\*/))}m
  241. $1
  242. else
  243. ''
  244. end
  245. end
  246. ##
  247. # Find the C code corresponding to a Ruby method
  248. def find_body(class_name, meth_name, meth_obj, body, quiet = false)
  249. case body
  250. when %r"((?>/\*.*?\*/\s*))((?:(?:static|SWIGINTERN)\s+)?(?:intern\s+)?VALUE\s+#{meth_name}
  251. \s*(\([^)]*\))([^;]|$))"xm
  252. comment = $1
  253. body_text = $2
  254. params = $3
  255. remove_private_comments comment if comment
  256. # see if we can find the whole body
  257. re = Regexp.escape(body_text) + '[^(]*^\{.*?^\}'
  258. body_text = $& if /#{re}/m =~ body
  259. # The comment block may have been overridden with a 'Document-method'
  260. # block. This happens in the interpreter when multiple methods are
  261. # vectored through to the same C method but those methods are logically
  262. # distinct (for example Kernel.hash and Kernel.object_id share the same
  263. # implementation
  264. override_comment = find_override_comment class_name, meth_obj.name
  265. comment = override_comment if override_comment
  266. find_modifiers comment, meth_obj if comment
  267. #meth_obj.params = params
  268. meth_obj.start_collecting_tokens
  269. tk = RDoc::RubyToken::Token.new nil, 1, 1
  270. tk.set_text body_text
  271. meth_obj.add_token tk
  272. meth_obj.comment = strip_stars comment
  273. when %r{((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+#{meth_name}\s+(\w+))}m
  274. comment = $1
  275. body_text = $2
  276. find_body class_name, $3, meth_obj, body, true
  277. find_modifiers comment, meth_obj
  278. meth_obj.start_collecting_tokens
  279. tk = RDoc::RubyToken::Token.new nil, 1, 1
  280. tk.set_text body_text
  281. meth_obj.add_token tk
  282. meth_obj.comment = strip_stars(comment) + meth_obj.comment.to_s
  283. when %r{^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m
  284. unless find_body(class_name, $1, meth_obj, body, true)
  285. warn "No definition for #{meth_name}" unless @options.quiet
  286. return false
  287. end
  288. else
  289. # No body, but might still have an override comment
  290. comment = find_override_comment(class_name, meth_obj.name)
  291. if comment
  292. find_modifiers(comment, meth_obj)
  293. meth_obj.comment = strip_stars comment
  294. else
  295. warn "No definition for #{meth_name}" unless @options.quiet
  296. return false
  297. end
  298. end
  299. true
  300. end
  301. def find_class(raw_name, name)
  302. unless @classes[raw_name]
  303. if raw_name =~ /^rb_m/
  304. container = @top_level.add_module RDoc::NormalModule, name
  305. else
  306. container = @top_level.add_class RDoc::NormalClass, name
  307. end
  308. container.record_location @top_level
  309. @classes[raw_name] = container
  310. end
  311. @classes[raw_name]
  312. end
  313. ##
  314. # Look for class or module documentation above Init_+class_name+(void),
  315. # in a Document-class +class_name+ (or module) comment or above an
  316. # rb_define_class (or module). If a comment is supplied above a matching
  317. # Init_ and a rb_define_class the Init_ comment is used.
  318. #
  319. # /*
  320. # * This is a comment for Foo
  321. # */
  322. # Init_Foo(void) {
  323. # VALUE cFoo = rb_define_class("Foo", rb_cObject);
  324. # }
  325. #
  326. # /*
  327. # * Document-class: Foo
  328. # * This is a comment for Foo
  329. # */
  330. # Init_foo(void) {
  331. # VALUE cFoo = rb_define_class("Foo", rb_cObject);
  332. # }
  333. #
  334. # /*
  335. # * This is a comment for Foo
  336. # */
  337. # VALUE cFoo = rb_define_class("Foo", rb_cObject);
  338. def find_class_comment(class_name, class_mod)
  339. comment = nil
  340. if @content =~ %r{
  341. ((?>/\*.*?\*/\s+))
  342. (static\s+)?
  343. void\s+
  344. Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)}xmi then # )
  345. comment = $1
  346. elsif @content =~ %r{Document-(?:class|module):\s+#{class_name}\s*?(?:<\s+[:,\w]+)?\n((?>.*?\*/))}m then # "
  347. comment = $1
  348. elsif @content =~ %r{((?>/\*.*?\*/\s+))
  349. ([\w\.\s]+\s* = \s+)?rb_define_(class|module).*?"(#{class_name})"}xm then
  350. comment = $1
  351. end
  352. return unless comment
  353. comment = strip_stars comment
  354. comment = look_for_directives_in class_mod, comment
  355. class_mod.comment = comment
  356. end
  357. ##
  358. # Finds a comment matching +type+ and +const_name+ either above the
  359. # comment or in the matching Document- section.
  360. def find_const_comment(type, const_name)
  361. if @content =~ %r{((?>^\s*/\*.*?\*/\s+))
  362. rb_define_#{type}\((?:\s*(\w+),)?\s*"#{const_name}"\s*,.*?\)\s*;}xmi
  363. $1
  364. elsif @content =~ %r{Document-(?:const|global|variable):\s#{const_name}\s*?\n((?>.*?\*/))}m
  365. $1
  366. else
  367. ''
  368. end
  369. end
  370. ##
  371. # If the comment block contains a section that looks like:
  372. #
  373. # call-seq:
  374. # Array.new
  375. # Array.new(10)
  376. #
  377. # use it for the parameters.
  378. def find_modifiers(comment, meth_obj)
  379. if comment.sub!(/:nodoc:\s*^\s*\*?\s*$/m, '') or
  380. comment.sub!(/\A\/\*\s*:nodoc:\s*\*\/\Z/, '')
  381. meth_obj.document_self = false
  382. end
  383. if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '') or
  384. comment.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '')
  385. seq = $1
  386. seq.gsub!(/^\s*\*\s*/, '')
  387. meth_obj.call_seq = seq
  388. end
  389. end
  390. def find_override_comment(class_name, meth_name)
  391. name = Regexp.escape(meth_name)
  392. if @content =~ %r{Document-method:\s+#{class_name}(?:\.|::|#)#{name}\s*?\n((?>.*?\*/))}m then
  393. $1
  394. elsif @content =~ %r{Document-method:\s#{name}\s*?\n((?>.*?\*/))}m then
  395. $1
  396. end
  397. end
  398. def handle_attr(var_name, attr_name, reader, writer)
  399. rw = ''
  400. rw << 'R' if reader
  401. rw << 'W' if writer
  402. class_name = @known_classes[var_name]
  403. return unless class_name
  404. class_obj = find_class(var_name, class_name)
  405. if class_obj
  406. comment = find_attr_comment(attr_name)
  407. comment = strip_stars comment
  408. att = RDoc::Attr.new '', attr_name, rw, comment
  409. @stats.add_method att
  410. class_obj.add_attribute(att)
  411. end
  412. end
  413. def handle_class_module(var_name, type, class_name, parent, in_module)
  414. parent_name = @known_classes[parent] || parent
  415. if in_module then
  416. enclosure = @classes[in_module] || @@enclosure_classes[in_module]
  417. if enclosure.nil? and enclosure = @known_classes[in_module] then
  418. type = /^rb_m/ =~ in_module ? "module" : "class"
  419. handle_class_module in_module, type, enclosure, nil, nil
  420. enclosure = @classes[in_module]
  421. end
  422. unless enclosure then
  423. warn "Enclosing class/module '#{in_module}' for #{type} #{class_name} not known"
  424. return
  425. end
  426. else
  427. enclosure = @top_level
  428. end
  429. if type == "class" then
  430. full_name = if RDoc::ClassModule === enclosure then
  431. enclosure.full_name + "::#{class_name}"
  432. else
  433. class_name
  434. end
  435. if @content =~ %r{Document-class:\s+#{full_name}\s*<\s+([:,\w]+)} then
  436. parent_name = $1
  437. end
  438. cm = enclosure.add_class RDoc::NormalClass, class_name, parent_name
  439. @stats.add_class cm
  440. else
  441. cm = enclosure.add_module RDoc::NormalModule, class_name
  442. @stats.add_module cm
  443. end
  444. cm.record_location enclosure.top_level
  445. find_class_comment cm.full_name, cm
  446. @classes[var_name] = cm
  447. @@enclosure_classes[var_name] = cm
  448. @known_classes[var_name] = cm.full_name
  449. end
  450. ##
  451. # Adds constant comments. By providing some_value: at the start ofthe
  452. # comment you can override the C value of the comment to give a friendly
  453. # definition.
  454. #
  455. # /* 300: The perfect score in bowling */
  456. # rb_define_const(cFoo, "PERFECT", INT2FIX(300);
  457. #
  458. # Will override +INT2FIX(300)+ with the value +300+ in the output RDoc.
  459. # Values may include quotes and escaped colons (\:).
  460. def handle_constants(type, var_name, const_name, definition)
  461. class_name = @known_classes[var_name]
  462. return unless class_name
  463. class_obj = find_class var_name, class_name
  464. unless class_obj then
  465. warn "Enclosing class/module #{const_name.inspect} not known"
  466. return
  467. end
  468. comment = find_const_comment type, const_name
  469. comment = strip_stars comment
  470. comment = normalize_comment comment
  471. # In the case of rb_define_const, the definition and comment are in
  472. # "/* definition: comment */" form. The literal ':' and '\' characters
  473. # can be escaped with a backslash.
  474. if type.downcase == 'const' then
  475. elements = comment.split ':'
  476. if elements.nil? or elements.empty? then
  477. con = RDoc::Constant.new const_name, definition, comment
  478. else
  479. new_definition = elements[0..-2].join(':')
  480. if new_definition.empty? then # Default to literal C definition
  481. new_definition = definition
  482. else
  483. new_definition.gsub!("\:", ":")
  484. new_definition.gsub!("\\", '\\')
  485. end
  486. new_definition.sub!(/\A(\s+)/, '')
  487. new_comment = if $1.nil? then
  488. elements.last.lstrip
  489. else
  490. "#{$1}#{elements.last.lstrip}"
  491. end
  492. con = RDoc::Constant.new const_name, new_definition, new_comment
  493. end
  494. else
  495. con = RDoc::Constant.new const_name, definition, comment
  496. end
  497. @stats.add_constant con
  498. class_obj.add_constant con
  499. end
  500. ##
  501. # Removes #ifdefs that would otherwise confuse us
  502. def handle_ifdefs_in(body)
  503. body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m, '\1')
  504. end
  505. def handle_method(type, var_name, meth_name, meth_body, param_count,
  506. source_file = nil)
  507. class_name = @known_classes[var_name]
  508. return unless class_name
  509. class_obj = find_class var_name, class_name
  510. if class_obj then
  511. if meth_name == "initialize" then
  512. meth_name = "new"
  513. type = "singleton_method"
  514. end
  515. meth_obj = RDoc::AnyMethod.new '', meth_name
  516. meth_obj.singleton = %w[singleton_method module_function].include? type
  517. p_count = Integer(param_count) rescue -1
  518. if p_count < 0 then
  519. meth_obj.params = "(...)"
  520. elsif p_count == 0
  521. meth_obj.params = "()"
  522. else
  523. meth_obj.params = "(" + (1..p_count).map{|i| "p#{i}"}.join(", ") + ")"
  524. end
  525. if source_file then
  526. file_name = File.join @file_dir, source_file
  527. if File.exist? file_name then
  528. body = (@@known_bodies[file_name] ||= File.read(file_name))
  529. else
  530. warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
  531. end
  532. else
  533. body = @content
  534. end
  535. if find_body(class_name, meth_body, meth_obj, body) and meth_obj.document_self then
  536. class_obj.add_method meth_obj
  537. @stats.add_method meth_obj
  538. meth_obj.visibility = :private if 'private_method' == type
  539. end
  540. end
  541. end
  542. def handle_tab_width(body)
  543. if /\t/ =~ body
  544. tab_width = @options.tab_width
  545. body.split(/\n/).map do |line|
  546. 1 while line.gsub!(/\t+/) { ' ' * (tab_width*$&.length - $`.length % tab_width)} && $~ #`
  547. line
  548. end .join("\n")
  549. else
  550. body
  551. end
  552. end
  553. ##
  554. # Look for directives in a normal comment block:
  555. #
  556. # /*
  557. # * :title: My Awesome Project
  558. # */
  559. #
  560. # This routine modifies it's parameter
  561. def look_for_directives_in(context, comment)
  562. preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
  563. preprocess.handle comment do |directive, param|
  564. case directive
  565. when 'main' then
  566. @options.main_page = param
  567. ''
  568. when 'title' then
  569. @options.title = param
  570. ''
  571. else
  572. warn "Unrecognized directive :#{directive}:"
  573. false
  574. end
  575. end
  576. comment
  577. end
  578. ##
  579. # Removes lines that are commented out that might otherwise get picked up
  580. # when scanning for classes and methods
  581. def remove_commented_out_lines
  582. @content.gsub!(%r{//.*rb_define_}, '//')
  583. end
  584. def remove_private_comments(comment)
  585. comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
  586. comment.sub!(/\/?\*--\n.*/m, '')
  587. end
  588. ##
  589. # Extract the classes/modules and methods from a C file and return the
  590. # corresponding top-level object
  591. def scan
  592. remove_commented_out_lines
  593. do_classes
  594. do_constants
  595. do_methods
  596. do_includes
  597. do_aliases
  598. @top_level
  599. end
  600. end