Skip to content

Commit

Permalink
Test with js hack
Browse files Browse the repository at this point in the history
  • Loading branch information
araffin committed Sep 30, 2020
1 parent 194f3cc commit d091f43
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
9 changes: 3 additions & 6 deletions docs/_static/css/baselines_theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ a.icon.icon-home {
background: #f8f8f8;;
}

/* Change style of types in the docstrings .rst-content .field-list */
.field-list .xref.py.docutils, .field-list code.docutils, .field-list .docutils.literal.notranslate
/* Change style of types in the docstrings*/
.field-list em
{
border: None;
padding-left: 0;
padding-right: 0;
color: #404040;
font-size: 90%;
}
30 changes: 30 additions & 0 deletions docs/_static/js/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";

// copied from https://stackoverflow.com/questions/9899372
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}

docReady(function() {

// post-process autodoc type hints
var elements = document.querySelectorAll(".field-list p");

const regex = /([a-zA_z_0-9]*) \(([a-zA-Z_\[\]\s,\.0-9]+)\)(.*)/;

Array.prototype.forEach.call(elements, function(el, i){
// convert to text
let text = el.textContent;
// re-apply formatting
if (text.match(regex)){
text = text.replace(regex, "<strong>$1</strong> (<em>$2</em>)$3");
el.innerHTML = text;
}
});
});
11 changes: 10 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,18 @@ def __getattr__(cls, name):


def setup(app):
app.add_css_file("css/baselines_theme.css")
pass


html_css_files = [
"css/baselines_theme.css",
]

# Post-process autodoc signature
html_js_files = [
"js/custom.js",
]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
Expand Down

0 comments on commit d091f43

Please sign in to comment.