Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add breadcrumb list #973

wants to merge 6 commits into from

Conversation

unasuke
Copy link

@unasuke unasuke commented Feb 6, 2023

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

3f19b7a572b883291b7e8f66ec1726fd.mp4

ruby/ruby

26e76f9e48ba1567d606c2efa9001ee7.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 unasuke changed the title Add breadcrumb Add breadcrumb list Feb 6, 2023
@unasuke
Copy link
Author

unasuke commented Feb 8, 2023

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.

lib/rdoc/class_module.rb Outdated Show resolved Hide resolved
@nobu
Copy link
Member

nobu commented Jul 5, 2023

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

@unasuke
Copy link
Author

unasuke commented Jul 5, 2023

@nobu Is it better for rename to namespace?

@nobu
Copy link
Member

nobu commented Jul 6, 2023

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

@unasuke
Copy link
Author

unasuke commented Jul 6, 2023

@nobu Renamed at 11d3c95

@st0012 st0012 added this to the v6.8.0 milestone Oct 17, 2024
@st0012
Copy link
Member

st0012 commented Oct 19, 2024

I love this feature 👍 Are you ok with rebasing the PR?

@st0012 st0012 modified the milestones: v6.8.0, v7.0.0 Nov 12, 2024
@unasuke
Copy link
Author

unasuke commented Nov 25, 2024

@st0012 Sorry for late, rebased!

@st0012
Copy link
Member

st0012 commented Nov 27, 2024

Because RDoc's default theme got a big styling improvement this year, the breadcrumbs are now pushed out of the main section, to the top of the navbar:

Screenshot 2024-11-27 at 18 11 32

Also, the default theme now supports very basic responsive design on mobile. So I think you'll need to update CSS to make it work in both desktop and mobile environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants