From c980be5b2e804fe43798b0c867185ecc85d78ab5 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 01:17:48 +0530 Subject: [PATCH 1/6] Modify extension to keep SVG output in HTML builds only --- docs/sphinxext/inheritance_diagram.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/sphinxext/inheritance_diagram.py b/docs/sphinxext/inheritance_diagram.py index 048921bffb..9bb1abd100 100644 --- a/docs/sphinxext/inheritance_diagram.py +++ b/docs/sphinxext/inheritance_diagram.py @@ -20,16 +20,21 @@ def add_diagram(app, what, name, obj, options, lines): # do nothing if it is not a derived class return - # Append the inheritance diagram to the docstring + # Append the inheritance diagram to the docstring. Note: we do this + # for HTML output only because SVG output creates multiple PDFs which + # are not supported by Read the Docs. + # https://github.com/readthedocs/readthedocs.org/issues/2045 lines.append("\n") - lines.append(".. dropdown:: View inheritance diagram for this model") - lines.append(" :animate: fade-in-slide-down") - lines.append(" :icon: eye\n") - lines.append(" :class-title: sd-align-major-center sd-fs-6 \n") - lines.append(" :class-container: sd-text-info \n") + lines.append(".. only:: html\n") lines.append("\n") - lines.append(" .. inheritance-diagram:: " + cls_name) - lines.append(" :parts: 2\n") + lines.append(" .. dropdown:: View inheritance diagram for this model") + lines.append(" :animate: fade-in-slide-down") + lines.append(" :icon: eye\n") + lines.append(" :class-title: sd-align-major-center sd-fs-6 \n") + lines.append(" :class-container: sd-text-info \n") + lines.append("\n") + lines.append(" .. inheritance-diagram:: " + cls_name) + lines.append(" :parts: 2\n") lines.append("\n") From b016e7f6b0a498785921bfe0e92fb476829e882e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 01:18:16 +0530 Subject: [PATCH 2/6] Remove unused CSS and add new CSS for dropdown --- docs/_static/pybamm.css | 53 +++++++---------------------------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/docs/_static/pybamm.css b/docs/_static/pybamm.css index 8a6c07887c..65f0dbab9d 100644 --- a/docs/_static/pybamm.css +++ b/docs/_static/pybamm.css @@ -1,41 +1,3 @@ -@import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&family=Open+Sans:ital,wght@0,400;0,600;1,400;1,600&display=swap"); - -.navbar-brand img { - height: 50px; -} - -.navbar-brand { - height: 50px; -} - -body { - font-family: "Open Sans", sans-serif; -} - -pre, -code { - font-size: 100%; - line-height: 155%; -} - -h1 { - font-family: "Lato", sans-serif; - color: #013243; - /* warm black */ -} - -h2 { - color: #4d77cf; - /* han blue */ - letter-spacing: -0.03em; -} - -h3 { - color: #013243; - /* warm black */ - letter-spacing: -0.03em; -} - /* Main page overview cards */ .sd-card { @@ -81,18 +43,18 @@ h3 { } /* Dark theme tweaking */ + html[data-theme="dark"] .sd-card img[src*=".svg"] { filter: invert(0.82) brightness(0.8) contrast(1.2); } /* Main index page overview cards */ + html[data-theme="dark"] .sd-card { background-color: var(--pst-color-background); } -html[data-theme="dark"] .sd-shadow-sm { - box-shadow: 0 0.1rem 1rem rgba(250, 250, 250, 0.6) !important; -} +/* Inheritance diagram dropdown options */ html[data-theme="dark"] .sd-card .sd-card-header { background-color: var(--pst-color-background); @@ -103,12 +65,12 @@ html[data-theme="dark"] .sd-card .sd-card-footer { background-color: var(--pst-color-background); } -html[data-theme="dark"] h1 { - color: var(--pst-color-primary); +details.sd-dropdown { + box-shadow: none !important; } -html[data-theme="dark"] h3 { - color: #0a6774; +.sd-summary-content blockquote { + border-left: 0 !important; } /* Overrides for sphinx-hoverxref since it does not support a native dark theme, see */ @@ -158,6 +120,7 @@ kbd.DocSearch-Commands-Key { .DocSearch-Button-Key { width: 24px; } + /* Do not add custom padding for keyboard buttons */ kbd:not(.compound) { From fa482dbbfa355f7365fe4757290446d1b92f7b86 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 01:22:45 +0530 Subject: [PATCH 3/6] Add PDF format output for Read the Docs --- .readthedocs.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 38cd1db957..d97966ee38 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,6 +12,7 @@ sphinx: fail_on_warning: false formats: + - pdf - epub - htmlzip From fe711b622db593d1d9828d102e580a371bf60857 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 01:35:11 +0530 Subject: [PATCH 4/6] Add Lato font --- docs/_static/pybamm.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/_static/pybamm.css b/docs/_static/pybamm.css index 65f0dbab9d..2a324d46d6 100644 --- a/docs/_static/pybamm.css +++ b/docs/_static/pybamm.css @@ -1,3 +1,11 @@ +/* Font */ + +@import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&family=Open+Sans:ital,wght@0,400;0,600;1,400;1,600&display=swap"); + +body { + font-family: "Open Sans", sans-serif; +} + /* Main page overview cards */ .sd-card { From 6f7b850ba8289a3b6fa92bb4061ed5239482f06b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 02:49:30 +0530 Subject: [PATCH 5/6] Use `not latex` role for conditional output --- docs/sphinxext/inheritance_diagram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinxext/inheritance_diagram.py b/docs/sphinxext/inheritance_diagram.py index 9bb1abd100..30a61aeba2 100644 --- a/docs/sphinxext/inheritance_diagram.py +++ b/docs/sphinxext/inheritance_diagram.py @@ -25,7 +25,7 @@ def add_diagram(app, what, name, obj, options, lines): # are not supported by Read the Docs. # https://github.com/readthedocs/readthedocs.org/issues/2045 lines.append("\n") - lines.append(".. only:: html\n") + lines.append(".. only:: not latex\n") lines.append("\n") lines.append(" .. dropdown:: View inheritance diagram for this model") lines.append(" :animate: fade-in-slide-down") From cac25b1bbca6f3f86dad17ea86d1d9ea541860d1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 04:07:57 +0530 Subject: [PATCH 6/6] Remove default search overlay --- docs/_static/pybamm.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/_static/pybamm.css b/docs/_static/pybamm.css index 2a324d46d6..a795e50f23 100644 --- a/docs/_static/pybamm.css +++ b/docs/_static/pybamm.css @@ -109,6 +109,12 @@ details.sd-dropdown { @import url("https://cdn.jsdelivr.net/npm/@docsearch/css@3"); +/* Remove the default PST search */ + +div.search-button__wrapper.show { + visibility: hidden; +} + .DocSearch-Modal { margin: 150px auto auto; background: var(--pst-color-background);