File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed
rdoc/generator/template/rails Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 2121 < main id ="content ">
2222 < div class ="content__full-name ">
2323 < span class ="qualifier "> <%= klass . type %> </ span >
24- <%= full_name klass %>
24+ <%= module_breadcrumbs klass %>
2525 <% if !klass . module? && superclass = klass . superclass %>
2626 < span class ="qualifier "> <</ span >
2727 <%= superclass . is_a? ( String ) ? full_name ( superclass ) : link_to ( superclass ) %>
Original file line number Diff line number Diff line change 5555a : has (> code : only-child ) {
5656 text-decoration : none;
5757}
58+ code a {
59+ text-decoration : none;
60+ }
5861
5962/* TODO: Remove this hack when Firefox supports `:has()` */
6063a code {
Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ def more_less_ul(items, limit)
116116 end
117117 end
118118
119+ def module_breadcrumbs ( rdoc_module )
120+ crumbs = [ h ( rdoc_module . name ) ]
121+
122+ rdoc_module . each_parent do |parent |
123+ break if parent . is_a? ( RDoc ::TopLevel )
124+ crumbs . unshift ( link_to ( h ( parent . name ) , parent ) )
125+ end
126+
127+ "<code>#{ crumbs . join ( "::<wbr>" ) } </code>"
128+ end
129+
119130 def method_signature ( rdoc_method )
120131 if rdoc_method . call_seq
121132 rdoc_method . call_seq . split ( /\n +/ ) . map do |line |
Original file line number Diff line number Diff line change @@ -502,6 +502,27 @@ def ul(items)
502502 end
503503 end
504504
505+ describe "#module_breadcrumbs" do
506+ it "renders links for each of the module's parents" do
507+ top_level = rdoc_top_level_for <<~RUBY
508+ module Foo; module Bar; module Qux; end; end; end
509+ RUBY
510+
511+ foo = top_level . find_module_named ( "Foo" )
512+ bar = top_level . find_module_named ( "Foo::Bar" )
513+ qux = top_level . find_module_named ( "Foo::Bar::Qux" )
514+
515+ _ ( @helpers . module_breadcrumbs ( foo ) ) .
516+ must_equal "<code>Foo</code>"
517+
518+ _ ( @helpers . module_breadcrumbs ( bar ) ) .
519+ must_equal "<code>#{ @helpers . link_to "Foo" , foo } ::<wbr>Bar</code>"
520+
521+ _ ( @helpers . module_breadcrumbs ( qux ) ) .
522+ must_equal "<code>#{ @helpers . link_to "Foo" , foo } ::<wbr>#{ @helpers . link_to "Bar" , bar } ::<wbr>Qux</code>"
523+ end
524+ end
525+
505526 describe "#method_signature" do
506527 it "returns the method signature wrapped in <code>" do
507528 method = rdoc_top_level_for ( <<~RUBY ) . find_module_named ( "Foo" ) . find_method ( "bar" , false )
You can’t perform that action at this time.
0 commit comments