Created
October 19, 2008 08:57
-
-
Save wycats/17798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/rdoc.rb b/lib/rdoc.rb | |
index 797b119..98d6af1 100644 | |
--- a/lib/rdoc.rb | |
+++ b/lib/rdoc.rb | |
@@ -389,7 +389,7 @@ module RDoc | |
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 | |
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb | |
index 1d92bd4..87467a3 100644 | |
--- a/lib/rdoc/options.rb | |
+++ b/lib/rdoc/options.rb | |
@@ -7,6 +7,10 @@ require 'optparse' | |
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 @@ Usage: #{opt.program_name} [options] [names...] | |
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", | |
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb | |
index 865cb79..6e3d03b 100644 | |
--- a/lib/rdoc/parser/ruby.rb | |
+++ b/lib/rdoc/parser/ruby.rb | |
@@ -1749,8 +1749,13 @@ class RDoc::Parser::Ruby < RDoc::Parser | |
@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 @@ class RDoc::Parser::Ruby < RDoc::Parser | |
@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 @@ class RDoc::Parser::Ruby < RDoc::Parser | |
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 @@ class RDoc::Parser::Ruby < RDoc::Parser | |
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, '') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment