Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/rdoc/code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def initialize_visibility # :nodoc:
@received_nodoc = false
@ignored = false
@suppressed = false
@stopped_doc = false
@track_visibility = true
end

Expand Down Expand Up @@ -205,8 +206,10 @@ def documented?
def done_documenting=(value)
return unless @track_visibility
@done_documenting = value
@document_self = !value
@document_children = @document_self
unless @stopped_doc
@document_self = !value
@document_children = @document_self
end
end

##
Expand Down Expand Up @@ -343,16 +346,18 @@ def start_doc
@document_children = true
@ignored = false
@suppressed = false
@stopped_doc = false
end

##
# Disable capture of documentation

def stop_doc
def stop_doc(from_directive: false)
return unless @track_visibility

@document_self = false
@document_children = false
@stopped_doc = true if from_directive
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/markup/pre_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def handle_directive(prefix, directive, param, code_object = nil,
when 'stopdoc' then
return blankline unless code_object

code_object.stop_doc
code_object.stop_doc(from_directive: true)

blankline
when 'yield', 'yields' then
Expand Down
26 changes: 26 additions & 0 deletions test/rdoc/parser/c_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,32 @@ def test_handle_method_source_file_with_non_ascii
File.delete source_path if source_path && File.exist?(source_path)
end

def test_stopdoc_class_display
content = <<~C
/* Document-class: Parent
* This is the Parent class
*/
VALUE rb_cParent = rb_define_class("Parent", rb_cObject);

/* :stopdoc: */
VALUE cInternal = rb_define_class_under(rb_cParent, "Internal", rb_cObject);
/* :startdoc: */
C

util_get_class content, 'cInternal'

# Simulate parse_file's done_documenting reset
@top_level.classes_or_modules.each do |cm|
cm.done_documenting = false
end

parent = @store.find_class_named 'Parent'
internal = @store.find_class_named 'Parent::Internal'

assert parent.display?, 'Parent should be displayed'
refute internal.display?, 'stopdoc class should not be displayed'
end

def util_get_class(content, name = nil)
@parser = util_parser content
@parser.scan
Expand Down