summaryrefslogtreecommitdiff
path: root/lib/rdoc/options.rb
diff options
context:
space:
mode:
authorMike Dalessio <[email protected]>2024-10-17 16:40:30 -0400
committergit <[email protected]>2024-10-17 20:40:34 +0000
commit0b38e184881839d347a777e82ad1b037a1aeca6e (patch)
tree8b71f0e8b97983d5b97c5772032adfd1c05250b6 /lib/rdoc/options.rb
parent48899d56a9c61d4a3e5fe822ed7c16a1f2868bd4 (diff)
[ruby/rdoc] feature: Render mixed-in methods and constants with
`--embed-mixins` (https://github.com/ruby/rdoc/pull/842) * Embed mixed-in methods and constants with `--embed-mixins` When `--embed-mixins` option is set: - methods from an `extend`ed module are documented as singleton methods - attrs from an `extend`ed module are documented as class attributes - methods from an `include`ed module are documented as instance methods - attrs from an `include`ed module are documented as instance attributes - constants from an `include`ed module are documented Sections are created when needed, and Darkfish's template annotates each of these mixed-in CodeObjects. We also respect the mixin methods' visibility. This feature is inspired by Yard's option of the same name. * Add comment to document why we set object visibility Co-authored-by: Stan Lo <[email protected]> * Add the mixin_from attribute to CodeObject's initializer * Add test coverage for private mixed-in attributes. --------- https://github.com/ruby/rdoc/commit/481c2ce660 Co-authored-by: Stan Lo <[email protected]>
Diffstat (limited to 'lib/rdoc/options.rb')
-rw-r--r--lib/rdoc/options.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 2631d57364..a607a76d56 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -344,6 +344,11 @@ class RDoc::Options
# Indicates if files of test suites should be skipped
attr_accessor :skip_tests
+ ##
+ # Embed mixin methods, attributes, and constants into class documentation. Set via
+ # +--[no-]embed-mixins+ (Default is +false+.)
+ attr_accessor :embed_mixins
+
def initialize loaded_options = nil # :nodoc:
init_ivars
override loaded_options if loaded_options
@@ -351,6 +356,7 @@ class RDoc::Options
def init_ivars # :nodoc:
@dry_run = false
+ @embed_mixins = false
@exclude = %w[
~\z \.orig\z \.rej\z \.bak\z
\.gemspec\z
@@ -401,6 +407,7 @@ class RDoc::Options
@encoding = encoding ? Encoding.find(encoding) : encoding
@charset = map['charset']
+ @embed_mixins = map['embed_mixins']
@exclude = map['exclude']
@generator_name = map['generator_name']
@hyperlink_all = map['hyperlink_all']
@@ -432,6 +439,7 @@ class RDoc::Options
end
@charset = map['charset'] if map.has_key?('charset')
+ @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
@exclude = map['exclude'] if map.has_key?('exclude')
@generator_name = map['generator_name'] if map.has_key?('generator_name')
@hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
@@ -460,11 +468,12 @@ class RDoc::Options
def == other # :nodoc:
self.class === other and
@encoding == other.encoding and
+ @embed_mixins == other.embed_mixins and
@generator_name == other.generator_name and
@hyperlink_all == other.hyperlink_all and
@line_numbers == other.line_numbers and
@locale == other.locale and
- @locale_dir == other.locale_dir and
+ @locale_dir == other.locale_dir and
@main_page == other.main_page and
@markup == other.markup and
@op_dir == other.op_dir and
@@ -842,6 +851,14 @@ Usage: #{opt.program_name} [options] [names...]
opt.separator nil
+ opt.on("--[no-]embed-mixins",
+ "Embed mixin methods, attributes, and constants",
+ "into class documentation. (default false)") do |value|
+ @embed_mixins = value
+ end
+
+ opt.separator nil
+
markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
opt.on("--markup=MARKUP", markup_formats,