diff --git a/.github/workflows/ruby-core.yml b/.github/workflows/ruby-core.yml index 57093a11b0..6c7b7f0133 100644 --- a/.github/workflows/ruby-core.yml +++ b/.github/workflows/ruby-core.yml @@ -69,6 +69,14 @@ jobs: - name: Generate Documentation with RDoc run: make html working-directory: ruby/ruby + - name: Core docs coverage + # Exclusions match RDOC_COVERAGE_EXCLUDES in ruby/ruby's common.mk. + # Run after make html so the build environment is fully set up + # (rbconfig.rb, generated files, etc.), matching ruby/ruby's CI. + run: > + make XRUBY=ruby RDOC_DEPENDS= RBCONFIG=update-rbconfig + rdoc-coverage + working-directory: ruby/ruby # We need to clear the generated documentation to generate them again # with the Ripper parser. - name: Clear Generated Documentation diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index c15c0129f5..a47c99fe68 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -125,6 +125,7 @@ def initialize_visibility # :nodoc: @received_nodoc = false @ignored = false @suppressed = false + @stopped_doc = false @track_visibility = true end @@ -205,7 +206,7 @@ def documented? def done_documenting=(value) return unless @track_visibility @done_documenting = value - @document_self = !value + @document_self = !value unless @stopped_doc @document_children = @document_self end @@ -343,6 +344,7 @@ def start_doc @document_children = true @ignored = false @suppressed = false + @stopped_doc = false end ## diff --git a/lib/rdoc/markup/pre_process.rb b/lib/rdoc/markup/pre_process.rb index db42e36b1c..d447ffd466 100644 --- a/lib/rdoc/markup/pre_process.rb +++ b/lib/rdoc/markup/pre_process.rb @@ -232,6 +232,7 @@ def handle_directive(prefix, directive, param, code_object = nil, return blankline unless code_object code_object.stop_doc + code_object.instance_variable_set(:@stopped_doc, true) blankline when 'yield', 'yields' then diff --git a/test/rdoc/rdoc_rdoc_test.rb b/test/rdoc/rdoc_rdoc_test.rb index f75939cb2d..69e6785618 100644 --- a/test/rdoc/rdoc_rdoc_test.rb +++ b/test/rdoc/rdoc_rdoc_test.rb @@ -358,6 +358,30 @@ def test_parse_file_encoding tf.close! end + def test_parse_file_stopdoc_in_c + @rdoc.store = RDoc::Store.new(@options) + + temp_dir do |dir| + @rdoc.options.root = Pathname(Dir.pwd) + + File.write 'test.c', <<~C + void Init_test(void) { + VALUE rb_cParent = rb_define_class("Parent", rb_cObject); + + /* :stopdoc: */ + VALUE cInternal = rb_define_class_under(rb_cParent, "Internal", rb_cObject); + /* :startdoc: */ + } + C + + top_level = @rdoc.parse_file 'test.c' + + internal = @rdoc.store.find_class_named 'Parent::Internal' + assert internal, 'Parent::Internal should exist' + refute internal.document_self, 'Parent::Internal should have document_self=false after :stopdoc:' + end + end + def test_parse_file_forbidden omit 'chmod not supported' if Gem.win_platform? omit "assumes that euid is not root" if Process.euid == 0