Skip to content

Commit

Permalink
ENH: HTML: Collapse orig source docstring into <details><summary>
Browse files Browse the repository at this point in the history
Fixes #192
  • Loading branch information
kernc committed Dec 13, 2024
1 parent b7f7f6a commit d9c0c40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pdoc/templates/css.mako
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
background: inherit; /* Don't grey-back parameters */
}
.source summary,
.source > summary,
.git-link-div {
color: #666;
text-align: right;
Expand All @@ -243,6 +243,7 @@
.source pre code {
font-size: 12px;
overflow: visible;
min-width: max-content;
}
.hlist {
list-style: none;
Expand Down
11 changes: 11 additions & 0 deletions pdoc/templates/html.mako
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@
<script>window.addEventListener('DOMContentLoaded', () => {
hljs.configure({languages: ['bash', 'css', 'diff', 'graphql', 'ini', 'javascript', 'json', 'plaintext', 'python', 'python-repl', 'rust', 'shell', 'sql', 'typescript', 'xml', 'yaml']});
hljs.highlightAll();
/* Collapse source docstrings */
setTimeout(() => {
[...document.querySelectorAll('.hljs.language-python > .hljs-string')]
.filter(el => el.innerHTML.length > 200 && ['"""', "'''"].includes(el.innerHTML.substring(0, 3)))
.forEach(el => {
let d = document.createElement('details');
d.classList.add('hljs-string');
d.innerHTML = '<summary>"""</summary>' + el.innerHTML.substring(3);
el.replaceWith(d);
});
}, 100);
})</script>
% endif

Expand Down

0 comments on commit d9c0c40

Please sign in to comment.