rdoc icon indicating copy to clipboard operation
rdoc copied to clipboard

Add breadcrumb list

Open unasuke opened this issue 2 years ago • 6 comments

Motivation

When reading several modules has deeply nested namespaces like OpenSSL, the breadcrumb list is very useful. In Japanese document (called rurema) has breadcrumb like this.

image

So, I introduce breadcrumb into rdoc. I tested on ruby/rdoc and ruby/ruby.

ruby/rdoc

https://user-images.githubusercontent.com/4487291/217001797-6ace375e-b3a8-4e23-beab-081d561f68ae.mp4

ruby/ruby

https://user-images.githubusercontent.com/4487291/217002054-b9b632b3-7c81-4d52-ad83-a76e71dd9934.mp4

Changes

Add methods to RDoc::ClassModule to build breadcrumb metadata.

  • RDoc::ClassModule#nesting_namespaces
    • returns array of namespaces that splitted full_name by ::
  • RDoc::ClassModule#fully_qualified_nesting_namespaces
    • returns an array of fully qualified namespaces
    • To find RDoc::ClassModule instance from RDoc::Store#classes_hash and RDoc::Store#modules_hash

Add private methods to RDoc::Generator::Darkfish to build breadcrumb data for easy-to-use template erb.

  • namespaces_to_class_modules
    • generate hash e.g. { "RDoc" => `RDoc::NormalModule` instance, "ClassModule" => `RDoc::NormalModule` instance }
  • generate_namespaces_breadcrumb
    • generate array e.g. [{:name=>"RDoc", :path=>"../RDoc.html", :self=>false}, {:name=>"ClassModule", :path=>"../RDoc/ClassModule.html", :self=>true}]

Then, display the breadcrumb in the class template.

My concerns

  • Should be displayed breadcrumb on top-level module/class?
  • Should be escape class/module name?
  • Should be made configurable to enable or disable breadcrumb?

unasuke avatar Feb 06 '23 14:02 unasuke

In Japanese document (called rurema) has breadcrumb like this.

To be precise, what is displayed in "rurema" is not a breadcrumb list but an inherited list of classes/modules. And this change don't provide an inherited list.

unasuke avatar Feb 08 '23 16:02 unasuke

I'm a little concerned about whether the plural term "namespaces" is appropriate here.

nobu avatar Jul 05 '23 04:07 nobu

@nobu Is it better for rename to namespace?

unasuke avatar Jul 05 '23 04:07 unasuke

The word "namespaces" feels ambiguous; it doesn't represent that it contains what namespaces. What about "nesting namespaces" or something?

nobu avatar Jul 06 '23 07:07 nobu

@nobu Renamed at 11d3c95

unasuke avatar Jul 06 '23 09:07 unasuke