From 431de987828783eece7e29e0ccc2facd99910afd Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 12 Aug 2020 13:12:34 +0530 Subject: [PATCH 1/3] :ok_hand: IMPROVE: Rebuild all the pages in docs-live This seems to be the best way to ensure changes in layout.html are reflected correctly. --- docs/conf.py | 11 ----------- noxfile.py | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 2a8d2ad3..eb2c562b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -73,14 +73,3 @@ # "extra_navbar": "Test", } html_baseurl = "https://sphinx-book-theme.readthedocs.io/en/latest/" - -# -- Custom configuration --------------------------------------------------- - - -# Always regenerate the index page, to ensure assets are correctly copied. -def env_get_outdated(app, env, added, changed, removed): - return ["index"] - - -def setup(app): - app.connect("env-get-outdated", env_get_outdated) diff --git a/noxfile.py b/noxfile.py index 56e1e2f0..5028c0a8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -69,6 +69,6 @@ def docs_live(session): # open the browser after 5 seconds "--open-browser", # sphinx-build arguments - "-b", "html", "docs", "docs/_build/html", + "-a", "-b", "html", "docs", "docs/_build/html", ) # fmt: on From fbb8b18d03c95966639e3d3482c5a30d03684bd5 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 12 Aug 2020 16:03:47 +0530 Subject: [PATCH 2/3] :ok_hand: IMPROVE: Compile CSS file, if not already compiled This allows us to keep the generated CSS file out of version control, which would make it easier to deal with cherry-picking and merging. --- .gitignore | 4 ++-- .pre-commit-config.yaml | 10 ---------- sphinx_book_theme/__init__.py | 9 ++++++++- sphinx_book_theme/static/sphinx-book-theme.css | 1 - 4 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 sphinx_book_theme/static/sphinx-book-theme.css diff --git a/.gitignore b/.gitignore index ba18a1f2..2f231d11 100644 --- a/.gitignore +++ b/.gitignore @@ -135,5 +135,5 @@ dmypy.json # VS Code .vscode/ -# Auto-generated docs page -docs/contributing-ebp.md +# Auto-generated CSS +sphinx-book-theme.css diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c2283cf1..166b351c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,13 +25,3 @@ repos: rev: stable hooks: - id: black - - - repo: local - hooks: - - id: scss - name: boussole - types: [scss] - language: python - additional_dependencies: [boussole] - entry: boussole compile --config=.boussole.json - pass_filenames: false diff --git a/sphinx_book_theme/__init__.py b/sphinx_book_theme/__init__.py index 45743266..2b066f01 100644 --- a/sphinx_book_theme/__init__.py +++ b/sphinx_book_theme/__init__.py @@ -4,7 +4,7 @@ from docutils import nodes from sphinx.util import logging from bs4 import BeautifulSoup as bs - +from sass import compile as sass_compile from .launch import add_hub_urls @@ -22,6 +22,13 @@ def add_static_path(app): static_path = Path(__file__).parent.joinpath("static").absolute() app.config.html_static_path.append(str(static_path)) + # Compile the css file if it's not been compiled already + compiled_css_file = static_path / "sphinx-book-theme.css" + if not compiled_css_file.exists(): + source_dir = str(static_path.parent / "scss") + output_dir = str(static_path) + sass_compile(dirname=(source_dir, output_dir), output_style="compressed") + def find_url_relative_to_root(pagename, relative_page, path_docs_source): """Given the current page (pagename), a relative page to it (relative_page), diff --git a/sphinx_book_theme/static/sphinx-book-theme.css b/sphinx_book_theme/static/sphinx-book-theme.css deleted file mode 100644 index 6db3a762..00000000 --- a/sphinx_book_theme/static/sphinx-book-theme.css +++ /dev/null @@ -1 +0,0 @@ -body{padding-top:0px !important}body img{max-width:100%}code{font-size:87.5% !important}main.bd-content{padding-top:3em !important;padding-bottom:0px !important}main.bd-content #main-content a.headerlink{opacity:0;margin-left:.2em}main.bd-content #main-content a.headerlink:hover{background-color:transparent;color:#0071bc;opacity:1 !important}main.bd-content #main-content a,main.bd-content #main-content a:visited{color:#0071bc}main.bd-content #main-content h1,main.bd-content #main-content h2,main.bd-content #main-content h3,main.bd-content #main-content h4,main.bd-content #main-content h5{color:black}main.bd-content #main-content h1:hover a.headerlink,main.bd-content #main-content h2:hover a.headerlink,main.bd-content #main-content h3:hover a.headerlink,main.bd-content #main-content h4:hover a.headerlink,main.bd-content #main-content h5:hover a.headerlink{opacity:.5}main.bd-content #main-content h1 a.toc-backref,main.bd-content #main-content h2 a.toc-backref,main.bd-content #main-content h3 a.toc-backref,main.bd-content #main-content h4 a.toc-backref,main.bd-content #main-content h5 a.toc-backref{color:inherit}main.bd-content #main-content div.section{padding-right:1em;overflow:visible !important}main.bd-content #main-content div.section ul p,main.bd-content #main-content div.section ol p{margin-bottom:0}main.bd-content #main-content span.eqno{float:right;font-size:1.2em}main.bd-content #main-content div.figure{width:100%;margin-bottom:1em;text-align:center}main.bd-content #main-content div.figure.align-left{text-align:left}main.bd-content #main-content div.figure.align-left p.caption{margin-left:0}main.bd-content #main-content div.figure.align-right{text-align:right}main.bd-content #main-content div.figure.align-right p.caption{margin-right:0}main.bd-content #main-content div.figure p.caption{margin:.5em 10%}main.bd-content #main-content div.figure.margin p.caption,main.bd-content #main-content div.figure.margin-caption p.caption{margin:.5em 0}main.bd-content #main-content div.figure.margin-caption p.caption{text-align:left}main.bd-content #main-content div.figure span.caption-number{font-weight:bold}main.bd-content #main-content div.figure span{font-size:.9rem}main.bd-content #main-content dl.glossary dd{margin-left:1.5em}main.bd-content #main-content div.contents{padding:1em}main.bd-content #main-content div.contents p.topic-title{font-size:1.5em;padding:.5em 0 0 1em}main.bd-content #main-content p.centered{text-align:center}main.bd-content #main-content div.sphinx-tabs>div.sphinx-menu{padding:0}main.bd-content #main-content div.sphinx-tabs>div.sphinx-menu>a.item{width:auto;margin:0px 0px -1px 0px}main.bd-content #main-content span.brackets:before,main.bd-content #main-content a.brackets:before{content:"["}main.bd-content #main-content span.brackets:after,main.bd-content #main-content a.brackets:after{content:"]"}main.bd-content #main-content .footnote-reference,main.bd-content #main-content a.bibtex.internal{font-size:1em}main.bd-content #main-content dl.footnote span.fn-backref{font-size:1em;padding-left:.1em}main.bd-content #main-content dl.footnote dd{font-size:.9em;margin-left:3em}main.bd-content #main-content dl.citation{margin-left:3em}main.bd-content #main-content dl.footnote dt.label{float:left}main.bd-content #main-content dl.footnote dd p{padding-left:1.5em}div.cell div.cell_output{padding-right:0}div.cell.tag_output_scroll div.cell_output{max-height:24em;overflow-y:auto}.toggle.admonition button.toggle-button{top:0.5em !important}button.toggle-button-hidden:before{bottom:0.2em !important}div.sidebar,div.margin,div.margin-caption p.caption,.cell.tag_popout,.cell.tag_margin{width:40%;float:right;border-left:1px #a4a6a7 solid;margin-left:0.5em;padding:.2em 0 .2em 1em}div.sidebar p,div.margin p,div.margin-caption p.caption p,.cell.tag_popout p,.cell.tag_margin p{margin-bottom:0}div.sidebar p.sidebar-title,div.margin p.sidebar-title,div.margin-caption p.caption p.sidebar-title,.cell.tag_popout p.sidebar-title,.cell.tag_margin p.sidebar-title{font-weight:bold;font-size:1.2em}@media (min-width: 768px){div.cell.tag_popout,div.cell.tag_margin,div.margin,div.margin-caption p.caption{border:none;clear:right;width:31% !important;margin:0 -35% 0 0 !important;padding:0 !important;font-size:0.9rem;line-height:1.3;vertical-align:baseline;position:relative}div.cell.tag_popout p,div.cell.tag_margin p,div.margin p,div.margin-caption p.caption p{margin-bottom:.5em}div.cell.tag_popout p.sidebar-title,div.cell.tag_margin p.sidebar-title,div.margin p.sidebar-title,div.margin-caption p.caption p.sidebar-title{font-size:1em}div.cell.tag_margin .cell_output{padding-left:0}div.sidebar:not(.margin){width:60%;margin-left:1.5em;margin-right:-28%}}@media (min-width: 768px){div.cell.tag_full-width,div.cell.tag_full_width,div.full_width,div.full-width{width:136% !important}}blockquote{margin:1em;padding:.2em 1.5em;border-left:4px solid #ccc}blockquote.pull-quote,blockquote.epigraph,blockquote.highlights{font-size:1.25em;border-left:none}blockquote div>p{margin-bottom:.5em}blockquote div>p+p.attribution{font-style:normal;font-size:.9em;text-align:right;color:#6c757d;padding-right:2em}div.highlight{background:none}.thebelab-cell{border:none !important}button.thebe-launch-button{height:2.5em;font-size:1em}div.tableofcontents-wrapper p.caption{font-weight:600 !important;margin-bottom:0em !important}.topbar{margin:0em auto 1em auto !important;padding-top:.25em;padding-bottom:.25em;background-color:white;height:3em;transition:left .2s}.topbar>div{height:2.5em;top:0px}.topbar .topbar-main>button,.topbar .topbar-main>div,.topbar .topbar-main>a{float:left;height:100%}.topbar .topbar-main button.topbarbtn{margin:0 .1em;background-color:white;color:#5a5a5a;border:none;padding-top:.1rem;padding-bottom:.1rem;font-size:1.4em}.topbar .topbar-main button.topbarbtn i.fab{vertical-align:baseline;line-height:1}.topbar .topbar-main div.dropdown-buttons-trigger,.topbar .topbar-main a.edit-button,.topbar .topbar-main a.full-screen-button{float:right}.bd-topbar-whitespace{padding-right:none}@media (max-width: 768px){.bd-topbar-whitespace{display:none}}span.topbar-button-text{margin-left:0.4em}@media (max-width: 768px){span.topbar-button-text{display:none}}div.dropdown-buttons-trigger div.dropdown-buttons{display:none;position:absolute;max-width:130px;margin-top:.2em;z-index:1000}div.dropdown-buttons-trigger div.dropdown-buttons.sourcebuttons .topbarbtn i{padding-right:6px;margin-left:-5px;font-size:.9em !important}div.dropdown-buttons-trigger div.dropdown-buttons button.topbarbtn{padding-top:.35rem;padding-bottom:.35rem;min-width:120px !important;border:1px white solid !important;background-color:#5a5a5a;color:white;font-size:1em}div.dropdown-buttons-trigger:hover div.dropdown-buttons{display:block}a.dropdown-buttons i{margin-right:.5em}button.topbarbtn img{height:1.15em;padding-right:6px;margin-left:-5px}#navbar-toggler{position:relative;margin-right:1em;margin-left:.5em;color:#5a5a5a}#navbar-toggler i{transition:opacity .3s, transform .3s;position:absolute;top:16%;left:0;display:block;font-size:1.2em}#navbar-toggler i.fa-bars{opacity:0;transform:rotate(180deg) scale(0.5)}#navbar-toggler i.fa-arrow-left,#navbar-toggler i.fa-arrow-up{opacity:1}#navbar-toggler.collapsed i.fa-bars{opacity:1;transform:rotate(0) scale(1)}#navbar-toggler.collapsed i.fa-arrow-left,#navbar-toggler.collapsed i.fa-arrow-up{opacity:0;transform:rotate(-180deg) scale(0.5)}@media (max-width: 768px){#navbar-toggler i.fa-arrow-up{display:inherit}#navbar-toggler i.fa-arrow-left{display:none}}@media (min-width: 768px){#navbar-toggler i.fa-arrow-up{display:none}#navbar-toggler i.fa-arrow-left{display:inherit}}.bd-toc{padding:0px !important;overflow-y:visible;background:white;right:0;z-index:999;transition:height .35s ease}.bd-toc div.onthispage,.bd-toc .toc-entry a{color:#5a5a5a}.bd-toc nav{opacity:0;max-height:0;transition:opacity 0.2s ease, max-height .7s ease;overflow-y:hidden;background:white}.bd-toc nav a:hover,.bd-toc nav li.active>a.active{color:#0071bc}.bd-toc nav li.active>a.active{border-left:2px solid #0071bc}.bd-toc:hover nav,.bd-toc.show nav{max-height:100vh;opacity:1}.bd-toc:hover .tocsection:after,.bd-toc.show .tocsection:after{opacity:0}.bd-toc .tocsection{padding:.5rem 0 .5rem 1rem !important}.bd-toc .tocsection:after{content:"\f107";font-family:"Font Awesome 5 Free";font-weight:900;padding-left:.5em;transition:opacity .3s ease}.bd-toc .toc-entry a{padding:.125rem 1rem !important}.bd-toc div.editthispage{display:none}.bd-sidebar{top:0px !important;overflow-y:auto;height:100vh !important;scrollbar-width:thin}.bd-sidebar nav ul.nav li a,.bd-sidebar nav ul.nav ul li a{color:#5a5a5a}.bd-sidebar nav ul.nav a:hover,.bd-sidebar nav ul.nav li.active>a,.bd-sidebar nav ul.nav li.active>a:hover{color:#0071bc}.bd-sidebar::-webkit-scrollbar{width:5px}.bd-sidebar::-webkit-scrollbar{background:#f1f1f1}.bd-sidebar::-webkit-scrollbar-thumb{background:#c1c1c1}@media (min-width: 992px){.bd-sidebar:not(:hover){-ms-overflow-style:none}.bd-sidebar:not(:hover)::-webkit-scrollbar{background:#FFFFFF}.bd-sidebar:not(:hover)::-webkit-scrollbar-thumb{background:#FFFFFF}}.bd-sidebar h1.site-logo{margin:.5em 0 0 0;font-size:1.1em;color:black;text-align:center}.bd-sidebar div.navbar_extra_footer{text-align:center;font-size:.9em;color:#5a5a5a;margin-bottom:3em}.bd-sidebar.collapsing{border:none;overflow:hidden;position:relative;padding-top:0}.bd-sidebar p.caption{margin-top:1.25em;margin-bottom:0;font-size:1.2em}.bd-sidebar li>a>i{font-size:.8em;margin-left:0.3em}.toc-h1,.toc-h2,.toc-h3,.toc-h4{font-size:1em}.toc-h1>a,.toc-h2>a,.toc-h3>a,.toc-h4>a{font-size:0.9em}.site-navigation,.site-navigation.collapsing{transition:flex .2s ease 0s, height .35s ease, opacity 0.2s ease}@media (max-width: 768px){#site-navigation{position:fixed;margin-top:3em;z-index:2000;background:white}}@media (max-width: 768px){.bd-sidebar{height:60vh !important;border-bottom:3px solid #c3c3c3}.bd-sidebar.collapsing{height:0px !important}.bd-sidebar.single-page{display:none}}@media (min-width: 768px){.bd-sidebar{z-index:2000 !important}.site-navigation.collapsing{flex:0 0 0px;padding:0}}@media (min-width: 768px){div.navbar-brand-box{padding-top:2em}}div.navbar-brand-box a.navbar-brand{width:100%;height:auto}div.navbar-brand-box a.navbar-brand img{display:block;height:auto;width:auto;max-height:10vh;max-width:100%;margin:0 auto}@media (min-width: 768px){div.navbar-brand-box a.navbar-brand img{max-height:15vh !important}}nav.bd-links{margin-left:0px;max-height:none !important}nav.bd-links p.caption{font-size:0.9em;text-transform:uppercase;font-weight:bold}nav.bd-links p.caption:first-child{margin-top:0}nav.bd-links ul{list-style:none}nav.bd-links li{width:100%}nav.bd-links li.toctree-l1,nav.bd-links li.toctree-l2,nav.bd-links li.toctree-l3,nav.bd-links li.toctree-l4,nav.bd-links li.toctree-l5{font-size:1em}nav.bd-links li.toctree-l1>a,nav.bd-links li.toctree-l2>a,nav.bd-links li.toctree-l3>a,nav.bd-links li.toctree-l4>a,nav.bd-links li.toctree-l5>a{font-size:0.9em}nav.bd-links>ul.nav{padding-left:0}nav.bd-links>ul.nav ul{padding:0 0 0 1rem}nav.bd-links>ul.nav a{padding:.25rem 0 !important}@media (min-width: 768px){.bd-sidebar,.bd-topbar-whitespace{max-width:275px}}.prev-next-bottom{height:3em}@media print{.tag_popout,div.margin{float:right;clear:right;width:50%;margin-right:-56%;margin-top:0;margin-bottom:0;padding-right:1em;font-size:0.9rem;line-height:1.3;vertical-align:baseline;position:relative;border-left:none;padding-left:0}.bd-content div#main-content>div{flex:0 0 75%;max-width:75%}h1,h2,h3,h4{break-after:avoid}table{break-inside:avoid}pre{word-wrap:break-word}a.copybtn,a.headerlink{display:none}.tag-fullwidth{width:145%;clear:both}div.toggle-hidden{visibility:inherit;opacity:1;height:auto}button.toggle-button{display:none}blockquote.epigraph{border:none}div.container{min-width:50% !important}div.bd-sidebar,div.prev-next-bottom{display:none}div.topbar{height:0;padding:0;position:inherit}div.topbar div.topbar-main{opacity:0}div.topbar div.bd-toc{flex:0 0 25%;max-width:25%;height:auto !important}div.topbar div.bd-toc nav,div.topbar div.bd-toc nav>ul.nav,div.topbar div.bd-toc nav>ul.nav>li>ul.nav{opacity:1;display:block}div.topbar div.bd-toc .nav-link.active{font-weight:inherit;color:inherit;background-color:inherit;border-left:inherit}} From f4e8d1ed51c9823e6208a93505bd1e1f34f69e8a Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 12 Aug 2020 16:29:32 +0530 Subject: [PATCH 3/3] :ok_hand: IMPROVE: Add a MANIFEST.in Toward ensuring we don't mess up our source distributions. --- .pre-commit-config.yaml | 5 +++++ MANIFEST.in | 24 ++++++++++++++++++++++++ setup.py | 6 +++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 166b351c..ef7c08c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,3 +25,8 @@ repos: rev: stable hooks: - id: black + + - repo: https://github.com/mgedmin/check-manifest + rev: "0.39" + hooks: + - id: check-manifest diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..83a5dffa --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,24 @@ +exclude .binder +recursive-exclude .binder * +exclude docs +recursive-exclude docs * +exclude tests +recursive-exclude tests * + +exclude .flake8 +exclude .pre-commit-config.yaml +exclude .readthedocs.yml +exclude .boussole.json +exclude noxfile.py + +include CHANGELOG.md +include LICENSE +include MANIFEST.in +include README.md + +include sphinx_book_theme/theme.conf +recursive-include sphinx_book_theme *.html +recursive-include sphinx_book_theme *.js +recursive-include sphinx_book_theme *.png +recursive-include sphinx_book_theme *.scss +recursive-include sphinx_book_theme *.svg diff --git a/setup.py b/setup.py index a9aad592..41280316 100644 --- a/setup.py +++ b/setup.py @@ -66,10 +66,14 @@ package_data={ "sphinx_book_theme": [ "theme.conf", + # Templates "*.html", + "topbar/*.html", + # Stylesheets + "scss/*", + # Other static files "static/*", "static/images/*", - "topbar/*.html", ] }, include_package_data=True,