Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Patches to support --api

  • Loading branch information...
commit 4cb6f9873a0e76b1fcd08d9dbebd89a7142ff0c2 1 parent b11fdb5
@wycats authored
Showing with 35 additions and 5 deletions.
  1. +1 −1  lib/rdoc.rb
  2. +10 −0 lib/rdoc/options.rb
  3. +24 −4 lib/rdoc/parser/ruby.rb
View
2  lib/rdoc.rb
@@ -389,7 +389,7 @@ class Error < RuntimeError; end
CONSTANT_MODIFIERS = GENERAL_MODIFIERS
METHOD_MODIFIERS = GENERAL_MODIFIERS +
- %w[arg args yield yields notnew not-new not_new doc]
+ %w[arg args yield yields notnew not-new not_new doc api]
end
View
10 lib/rdoc/options.rb
@@ -7,6 +7,10 @@
class RDoc::Options
##
+ # The API level
+ attr_reader :api
+
+ ##
# Should the output be placed into a single file
attr_reader :all_one_file
@@ -155,6 +159,7 @@ class RDoc::Options
attr_reader :webcvs
def initialize(generators = {}) # :nodoc:
+ @api = "public"
@op_dir = "doc"
@op_name = nil
@show_all = false
@@ -228,6 +233,11 @@ def parse(argv)
opt.separator "Options:"
opt.separator nil
+ opt.on("--api=LEVEL", "The level of API to generate",
+ "docs for") do |level|
+ @api = level
+ end
+
opt.on("--accessor=ACCESSORS", "-A", Array,
"A comma separated list of additional class",
"methods that should be treated like",
View
28 lib/rdoc/parser/ruby.rb
@@ -1749,8 +1749,13 @@ def look_for_directives_in(context, comment)
@options.title = param
''
else
- warn "Unrecognized directive '#{directive}'"
- false
+ if !respond_to?("set_#{directive}_modifier")
+ warn "Unrecognized directive '#{directive}'"
+ false
+ else
+ send("set_#{directive}_modifier", context, param)
+ ''
+ end
end
end
@@ -2183,6 +2188,8 @@ def parse_method(container, single, tk, comment)
@scanner.instance_eval do @continue = false end
parse_method_parameters meth
+ meth.comment = comment
+
if meth.document_self then
container.add_method meth
elsif added_container then
@@ -2207,8 +2214,6 @@ def parse_method(container, single, tk, comment)
remove_token_listener(meth)
extract_call_seq comment, meth
-
- meth.comment = comment
end
def parse_method_or_yield_parameters(method = nil,
@@ -2679,9 +2684,24 @@ def read_documentation_modifiers(context, allow)
when "arg", "args" then
context.params = dir[1]
+
+ else
+ send("set_#{dir[0]}_modifier", context, dir[1])
end if dir
end
+ def set_api_modifier(context, level)
+ doc = case @options.api
+ when "private"
+ %w(private plugin public).include?(level)
+ when "plugin"
+ %w(plugin public).include?(level)
+ when "public"
+ %w(public).include?(level)
+ end
+ context.document_self = doc
+ end
+
def remove_private_comments(comment)
comment.gsub!(/^#--\n.*?^#\+\+/m, '')
comment.sub!(/^#--\n.*/m, '')
Please sign in to comment.
Something went wrong with that request. Please try again.