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

21434: Adjusted the on page table of contents to show only the final segment for classes and methods at each level #87

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
/* Limit height of brand logo */
.navbar-brand .logo__image {
height: 32px;
height: 32px;
}

/** Correct API Reference styles where signatures are very long **/
/* Newlines (\a) and spaces (\20) before each parameter */
.sig.sig-wrap .sig-param::before {
content: "\a\20\20\20";
white-space: pre;
content: "\a\20\20\20";
white-space: pre;
}
/* Newline after the last parameter (so the closing parenthesis is on a new line) */
.sig.sig-wrap .sig-param:last-of-type::after {
content: "\a";
white-space: pre;
content: "\a";
white-space: pre;
}
/* Break up signatures where the package path is very long */
.sig.sig-wrap .sig-prename {
word-break: break-word;
overflow-wrap: break-word;
word-break: break-word;
overflow-wrap: break-word;
}
.sig.sig-wrap .sig-prename span.pre {
white-space: normal;
white-space: normal;
}

/* page-sidebar-secondary.js support */
html.js .sidebar-secondary-items {
opacity: 0;
}

html.js .sidebar-secondary-items.opacity-100 {
opacity: 100;
}
4 changes: 4 additions & 0 deletions source/_static/js/html-js-class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"use strict";
(function () {
document.querySelector("html").classList.add("js");
})();
39 changes: 39 additions & 0 deletions source/_static/js/page-sidebar-secondary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use strict";

document.addEventListener("DOMContentLoaded", () => {
const sidebarSecondaryItems = document.querySelector(
".sidebar-secondary-items"
);
if (!sidebarSecondaryItems) {
return;
}

// Format Table Of Contents
(() => {
const tableOfContents = sidebarSecondaryItems.querySelector("nav.page-toc");
if (!tableOfContents) {
return;
}

// Truncate table of content's that have '.' notations to their final entry
const internalLinks =
tableOfContents.querySelectorAll(".internal.nav-link");
internalLinks.forEach((link) => {
const pre = link.querySelector(".pre");
if (
!pre ||
!pre.textContent ||
// Avoid adjusting any items that are language like
!pre.textContent.match(/^[\w\d-.\(\)]*$/)
) {
return;
}
const parts = pre.textContent.split(".");
if (parts.length > 1) {
pre.innerHTML = "." + parts.pop();
}
});
})();

sidebarSecondaryItems.classList.add("opacity-100");
});
19 changes: 13 additions & 6 deletions source/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{% extends "!layout.html" %}
{% block extrahead %}
<link rel="icon" type="image/svg+xml" href="/_static/favicon.svg">
<link rel="mask-icon" href="/_static/favicon.svg">
<link rel="stylesheet" href="https://cdn.howso.com/fonts/inter/3.19/typeface.css">
<script src="https://cdn.usefathom.com/script.js" data-site="IXEHVNCB" data-honor-dnt="true" defer></script>
{% extends "!layout.html" %} {% block extrahead %}
<link rel="icon" type="image/svg+xml" href="/_static/favicon.svg" />
<link rel="mask-icon" href="/_static/favicon.svg" />
<link
rel="stylesheet"
href="https://cdn.howso.com/fonts/inter/3.19/typeface.css"
/>
<script
src="https://cdn.usefathom.com/script.js"
data-site="IXEHVNCB"
data-honor-dnt="true"
defer
></script>
{% endblock %}
2 changes: 1 addition & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"css/theme.css",
"css/custom.css",
]
html_js_files = ["js/icon.js"]
html_js_files = ["js/html-js-class.js", "js/icon.js", "js/page-sidebar-secondary.js"]

master_doc = "index"

Expand Down