Skip to content

Context#each_section yields only #display? items #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2017
Merged
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
2 changes: 1 addition & 1 deletion lib/rdoc/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def each_section # :yields: section, constants, attributes
attributes.default = []

sort_sections.each do |section|
yield section, constants[section].sort, attributes[section].sort
yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
end
end

Expand Down
2 changes: 0 additions & 2 deletions lib/rdoc/generator/template/darkfish/class.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
</section>

<% klass.each_section do |section, constants, attributes| %>
<% constants = constants.select { |const| const.display? } %>
<% attributes = attributes.select { |attr| attr.display? } %>
<section id="<%= section.aref %>" class="documentation-section">
<% if section.title then %>
<header class="documentation-section-title">
Expand Down
26 changes: 26 additions & 0 deletions test/test_rdoc_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,32 @@ def test_each_section
assert_equal expected_attrs, attrs
end

def test_each_section_only_display
sects = []
consts = []
attrs = []

@c7.each_section do |section, constants, attributes|
sects << section
consts << constants
attrs << attributes
end

assert_equal [nil], sects.map { |section| section.title }

expected_consts = [
@c7.constants.select(&:display?).sort
]

assert_equal expected_consts, consts

expected_attrs = [
@c7.attributes.select(&:display?).sort
]

assert_equal expected_attrs, attrs
end

def test_each_section_enumerator
assert_kind_of Enumerator, @c1.each_section
end
Expand Down
4 changes: 2 additions & 2 deletions test/test_rdoc_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_add_file_relative

def test_all_classes_and_modules
expected = %w[
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7
Child
M1 M1::M2
Parent
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_class_path

def test_classes
expected = %w[
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7
Child
Parent
]
Expand Down
12 changes: 12 additions & 0 deletions test/xref_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ def prot5() end
def prot6() end
end

class C7
attr_reader :attr_reader
attr_reader :attr_reader_nodoc # :nodoc:
attr_writer :attr_writer
attr_writer :attr_writer_nodoc # :nodoc:
attr_accessor :attr_accessor
attr_accessor :attr_accessor_nodoc # :nodoc:

CONST = :const
CONST_NODOC = :const_nodoc # :nodoc:
end

module M1
def m
end
Expand Down
1 change: 1 addition & 0 deletions test/xref_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def generator.file_dir() nil end
@c3_h1 = @xref_data.find_module_named 'C3::H1'
@c3_h2 = @xref_data.find_module_named 'C3::H2'
@c6 = @xref_data.find_module_named 'C6'
@c7 = @xref_data.find_module_named 'C7'

@m1 = @xref_data.find_module_named 'M1'
@m1_m = @m1.method_list.first
Expand Down