Skip to content

Commit b2ad389

Browse files
Wrap full_name in <code>
1 parent c34fab9 commit b2ad389

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/sdoc/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def link_to_external(text, url, html_attributes = {})
3232

3333
def full_name(named)
3434
named = named.full_name if named.is_a?(RDoc::CodeObject)
35-
named.split(%r"(?<=./|.::)").map { |part| h part }.join("<wbr>")
35+
"<code>#{named.split(%r"(?<=./|.::)").map { |part| h part }.join("<wbr>")}</code>"
3636
end
3737

3838
def base_tag_for_context(context)

spec/helpers_spec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,30 @@ module Foo; class Bar; end; end
172172
end
173173

174174
describe "#full_name" do
175+
it "wraps name in <code>" do
176+
_(@helpers.full_name("Foo")).must_equal "<code>Foo</code>"
177+
end
178+
175179
it "inserts word-break opportunities into module names" do
176-
_(@helpers.full_name("Foo::Bar::Qux")).must_equal "Foo::<wbr>Bar::<wbr>Qux"
177-
_(@helpers.full_name("::Foo::Bar::Qux")).must_equal "::Foo::<wbr>Bar::<wbr>Qux"
180+
_(@helpers.full_name("Foo::Bar::Qux")).must_equal "<code>Foo::<wbr>Bar::<wbr>Qux</code>"
181+
_(@helpers.full_name("::Foo::Bar::Qux")).must_equal "<code>::Foo::<wbr>Bar::<wbr>Qux</code>"
178182
end
179183

180184
it "inserts word-break opportunities into file paths" do
181-
_(@helpers.full_name("path/to/file.rb")).must_equal "path/<wbr>to/<wbr>file.rb"
182-
_(@helpers.full_name("/path/to/file.rb")).must_equal "/path/<wbr>to/<wbr>file.rb"
185+
_(@helpers.full_name("path/to/file.rb")).must_equal "<code>path/<wbr>to/<wbr>file.rb</code>"
186+
_(@helpers.full_name("/path/to/file.rb")).must_equal "<code>/path/<wbr>to/<wbr>file.rb</code>"
183187
end
184188

185189
it "escapes name parts" do
186-
_(@helpers.full_name("ruby & rails/file.rb")).must_equal "ruby &amp; rails/<wbr>file.rb"
190+
_(@helpers.full_name("ruby&rails/file.rb")).must_equal "<code>ruby&amp;rails/<wbr>file.rb</code>"
187191
end
188192

189193
it "uses RDoc::CodeObject#full_name when argument is an RDoc::CodeObject" do
190194
rdoc_module = rdoc_top_level_for(<<~RUBY).find_module_named("Foo::Bar::Qux")
191195
module Foo; module Bar; class Qux; end; end; end
192196
RUBY
193197

194-
_(@helpers.full_name(rdoc_module)).must_equal "Foo::<wbr>Bar::<wbr>Qux"
198+
_(@helpers.full_name(rdoc_module)).must_equal "<code>Foo::<wbr>Bar::<wbr>Qux</code>"
195199
end
196200
end
197201

0 commit comments

Comments
 (0)