kit-doc edge
Sidebar
module
Kit::Doc::Services::Sidebar
View Source
Kit::Doc::Services::Sidebar
Data transformation logic for the documentation Sidebar content.
Link to this section Summary ⚠️ Private APIs are currently hidden.
Modules 2
Link to this section Class methods 3
Check if an element (module / extra) should be part of a group, based on its name, given groups conditions.
An element be in multiple groups if it matches inclusion conditions.
Also generate the display name && css classes.
If no group is specified, we default to the empty group (first to be displayed) rather than hidding the element.
Generate the group container needed in sidebar_items.
This maintain the group order defined in the initial config.
Transform the group matcher input format to allow Callables & Regexps.
The following is valid input:
groups_for_modules: {
# List of regexps
'My group' => [
# Regexp
%r{^ClassA$},
# Callable
->(name) { name.start_with?('ModuleB'),
# Hash with the following keys:
{
# Inclusion needs to be either a Regexp or a Callable
inclusion: %r{^ModuleB.*},
# A callable that returns an array of css classes
css_classes: ->(name) do
['text-left', name.start_with?('Module') ? 'module' : 'class'],
end,
# A callable that return the name that will be displayed in the sidebar
display_title: ->(name) { name.split('::')[-1] },
},
],
}