rdoc
rdoc copied to clipboard
Add breadcrumb list
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.

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_nameby::
- returns array of namespaces that splitted
RDoc::ClassModule#fully_qualified_nesting_namespaces- returns an array of fully qualified namespaces
- To find
RDoc::ClassModuleinstance fromRDoc::Store#classes_hashandRDoc::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 hash e.g.
generate_namespaces_breadcrumb- generate array e.g.
[{:name=>"RDoc", :path=>"../RDoc.html", :self=>false}, {:name=>"ClassModule", :path=>"../RDoc/ClassModule.html", :self=>true}]
- generate array e.g.
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?
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.
I'm a little concerned about whether the plural term "namespaces" is appropriate here.
@nobu Is it better for rename to namespace?
The word "namespaces" feels ambiguous; it doesn't represent that it contains what namespaces. What about "nesting namespaces" or something?
@nobu Renamed at 11d3c95