Skip to content

Commit

Permalink
Add 2nd level namespaces to the left nav
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Dec 25, 2023
1 parent b6e1a37 commit d647a15
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions subdoc/gen_tests/nested-namespace/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@
<li>
<a class="sidebar-item" href="namespace.outer_namespace.html">outer_namespace</a>
</li>
<li>
<a class="sidebar-item nested" href="outer_namespace-namespace.inner_namespace.html">inner_namespace</a>
</li>
</ul>
</div>
</nav>
Expand Down
3 changes: 3 additions & 0 deletions subdoc/gen_tests/subdoc-test-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ nav.sidebar .sidebar-links li > a.sidebar-item {
color: rgb(250, 199, 121);
font-size: 1.0em;
}
nav.sidebar .sidebar-item.nested {
margin-left: 0.75rem;
}
@media (max-width: 700px) {
nav.sidebar {
display: none;
Expand Down
3 changes: 3 additions & 0 deletions subdoc/gen_tests/typenames-across-paths/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@
<li>
<a class="sidebar-item" href="namespace.other.html">other</a>
</li>
<li>
<a class="sidebar-item nested" href="other-namespace.subother.html">subother</a>
</li>
</ul>
</div>
</nav>
Expand Down
17 changes: 17 additions & 0 deletions subdoc/lib/gen/generate_namespace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,23 @@ sus::Result<void, MarkdownToHtmlError> generate_namespace(
namespace_element_from_sorted(element, sorted_ns);
sidebar_links.push(SidebarLink(SidebarLinkStyle::Item, ne.name,
construct_html_url_for_namespace(ne)));

Vec<SortedNamespaceByName> sorted;
for (const auto& [key, sub_element] : ne.namespaces) {
if (sub_element.hidden()) continue;
if (sub_element.is_empty()) continue;

sorted.push(sus::tuple(sub_element.name, sub_element.sort_key, key));
}
sorted.sort_unstable_by(cmp_namespaces_by_name);

for (const SortedNamespaceByName& sub_sorted_ns : sorted) {
const NamespaceElement& sub_ne =
namespace_element_from_sorted(ne, sub_sorted_ns);
sidebar_links.push(
SidebarLink(SidebarLinkStyle::NestedItem, sub_ne.name,
construct_html_url_for_namespace(sub_ne)));
}
}
}
if (!sorted_classes.is_empty()) {
Expand Down
4 changes: 4 additions & 0 deletions subdoc/lib/gen/generate_nav.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ void generate_nav(HtmlWriter::OpenBody& body, const Database& db,
a.add_class("sidebar-header");
break;
case SidebarLinkStyle::Item: a.add_class("sidebar-item"); break;
case SidebarLinkStyle::NestedItem:
a.add_class("sidebar-item");
a.add_class("nested");
break;
}
a.add_href(link.href);
a.write_text(link.text);
Expand Down
1 change: 1 addition & 0 deletions subdoc/lib/gen/generate_nav.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum class SidebarLinkStyle {
Parent,
GroupHeader,
Item,
NestedItem,
};

struct SidebarLink {
Expand Down

0 comments on commit d647a15

Please sign in to comment.