Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Add compatibility with RDoc 8
- Fix TypesExplainer parsing of types following Hash collections (#1688)
- Fix HTML generation for RBS constants without source values (#1686)

# [0.9.44] - May 25th, 2026

Expand Down
3 changes: 3 additions & 0 deletions lib/yard/templates/helpers/method_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ def format_code(object, _show_lines = false)
end.join("\n")
end

# @param [String, nil] value the source code of a constant value
# @return [String] formats source code of a constant value
def format_constant(value)
return "" if value.nil?

# last can return nil, so default to empty string
sp = value.split("\n").last || ""
sp = sp[/^(\s+)/, 1]
Expand Down
6 changes: 6 additions & 0 deletions spec/templates/helpers/method_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,11 @@ class TestFmtConst
expect(format_constant("")).to eq ""
end
end

context "when nil is passed as param" do
it "returns an empty string" do
expect(format_constant(nil)).to eq ""
end
end
end
end
13 changes: 13 additions & 0 deletions spec/templates/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ module A
html_equals(Registry.at('A').format(html_options), :module005)
end

it "renders RBS constants without source values in html" do
Registry.clear
YARD::Parser::SourceParser.parse_string <<-'RBS', :rbs
class Foo
BAR: untyped
end
RBS

html = Registry.at('Foo').format(html_options)
expect(html).to include('id="BAR-constant"')
expect(html).to include('<pre class="code"></pre>')
end

it "shows inherited methods from matching groups in the group section, not in flat inherited section" do
Registry.clear
YARD.parse_string <<-'eof'
Expand Down
Loading