-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add breadcrumb list #973
base: master
Are you sure you want to change the base?
Add breadcrumb list #973
Conversation
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. |
lib/rdoc/class_module.rb
Outdated
return namespaces if namespaces.length < 2 | ||
@fqns ||= namespaces.map.with_index do |_, i| | ||
namespaces[0..i].join("::") | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
return namespaces if namespaces.length < 2 | |
@fqns ||= namespaces.map.with_index do |_, i| | |
namespaces[0..i].join("::") | |
end | |
@fqns ||= namespaces.inject([]) do |list, n| | |
list << (list.empty? ? n : "#{list.last}::#{n}") | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed at 0e05c99
I'm a little concerned about whether the plural term "namespaces" is appropriate here. |
@nobu Is it better for rename to |
The word "namespaces" feels ambiguous; it doesn't represent that it contains what namespaces. |
I love this feature 👍 Are you ok with rebasing the PR? |
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
andruby/ruby
.ruby/rdoc
3f19b7a572b883291b7e8f66ec1726fd.mp4
ruby/ruby
26e76f9e48ba1567d606c2efa9001ee7.mp4
Changes
Add methods to
RDoc::ClassModule
to build breadcrumb metadata.RDoc::ClassModule#nesting_namespaces
full_name
by::
RDoc::ClassModule#fully_qualified_nesting_namespaces
RDoc::ClassModule
instance fromRDoc::Store#classes_hash
andRDoc::Store#modules_hash
Add private methods to
RDoc::Generator::Darkfish
to build breadcrumb data for easy-to-use template erb.namespaces_to_class_modules
{ "RDoc" => `RDoc::NormalModule` instance, "ClassModule" => `RDoc::NormalModule` instance }
generate_namespaces_breadcrumb
[{: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