Skip to content

Commit

Permalink
docs: Move to furo theme, add pytest-watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Mar 2, 2022
1 parent 9719299 commit 07dd3e0
Show file tree
Hide file tree
Showing 9 changed files with 419 additions and 59 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.1 3.9.9 3.8.11 3.7.12
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
poetry 1.1.12
python 3.10.1 3.9.9 3.8.11 3.7.12
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ black:
test:
poetry run py.test $(test)

start:
$(MAKE) test && poetry run ptw .

watch_test:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) test; else $(MAKE) test entr_warn; fi

Expand All @@ -39,6 +42,12 @@ serve_docs:
dev_docs:
$(MAKE) -j watch_docs serve_docs

start_docs:
$(MAKE) -C docs start

design_docs:
$(MAKE) -C docs design

flake8:
poetry run flake8

Expand Down
7 changes: 7 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,10 @@ serve_py3:

dev:
$(MAKE) -j watch serve

start:
poetry run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} $(O)

design:
# This adds additional watch directories (for _static file changes) and disable incremental builds
poetry run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} --watch "." -a $(O)
40 changes: 40 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
h2 {
font-size: 2rem;
margin-bottom: 1.25rem;
margin-top: 1.25rem;
scroll-margin-top: 0.5rem;
}

h3 {
font-size: 1.5rem;
margin-bottom: 1.25rem;
margin-top: 1.25rem;
scroll-margin-top: 0.5rem;
}

h4 {
font-size: 1.25rem;
margin-bottom: 1.25rem;
scroll-margin-top: 0.5rem;
}

.sidebar-tree p.indented-block {
padding: var(--sidebar-item-spacing-vertical) var(--sidebar-item-spacing-horizontal) 0 var(--sidebar-item-spacing-horizontal);
margin-bottom: 0;
}

.sidebar-tree p.indented-block span.indent {
margin-left: var(--sidebar-item-spacing-horizontal);
display: block;
}

.sidebar-tree p.indented-block > :not(.project-name) {
font-size: var(--toc-font-size);
}

.sidebar-tree p.indented-block .project-name {
font-size: var(--sidebar-item-font-size);
font-weight: bold;
margin-right: calc(var(--sidebar-item-spacing-horizontal) / 2.5);
}

31 changes: 31 additions & 0 deletions docs/_templates/sidebar/projects.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="sidebar-tree projects">
<p class="caption" role="heading">
<span class="caption-text"
>team git-pull / <a href="https://www.git-pull.com/">Tony Narlock</a></span
>:
</p>

<p class="indented-block">
<span class="project-name">vcs-python</span>
<a class="internal" href="https://vcspull.git-pull.com" class="current">vcspull</a>
(<a class="internal" href="https://libvcs.git-pull.com">libvcs</a>),
<a class="internal" href="https://g.git-pull.com">g</a>
</p>
<p class="indented-block">
<span class="project-name">tmux-python</span>
<a class="internal" href="https://tmuxp.git-pull.com" class="current">tmuxp</a>
(<a class="internal" href="https://libtmux.git-pull.com">libtmux</a>)
</p>

<p class="indented-block">
<span class="project-name">cihai</span>
<span class="indent">
<a class="internal" href="https://unihan-etl.git-pull.com" class="current">unihan-etl</a>
(<a class="internal" href="https://unihan-db.git-pull.com">db</a>)
</span>
<span class="indent">
<a class="internal" href="https://cihai.git-pull.com" class="current">cihai</a>
(<a class="internal" href="https://cihai-cli.git-pull.com">cli</a>)
</span>
</p>
</div>
67 changes: 38 additions & 29 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# flake8: NOQA E501
import os
import sys

import alagitpull
import unihan_db

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
Expand All @@ -15,16 +16,18 @@
with open("../unihan_db/__about__.py") as fp:
exec(fp.read(), about)


extensions = [
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.napoleon",
"alagitpull",
"sphinx_inline_tabs",
"sphinx_copybutton",
"sphinxext.opengraph",
"myst_parser",
]
myst_enable_extensions = ["colon_fence", "substitution", "replacements"]

templates_path = ["_templates"]

Expand All @@ -40,40 +43,46 @@

exclude_patterns = ["_build"]

pygments_style = "sphinx"
pygments_style = "monokai"
pygments_dark_style = "monokai"

html_theme_path = [alagitpull.get_path()]
html_static_path = ["_static"]
html_extra_path = ["manifest.json"]
html_theme = "alagitpull"
html_css_files = ["css/custom.css"]
html_theme = "furo"
html_theme_path = []
html_theme_options = {
"light_logo": "img/cihai.svg",
"dark_logo": "img/cihai.svg",
"footer_icons": [
{
"name": "GitHub",
"url": about["__github__"],
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
"class": "",
},
],
}
html_sidebars = {
"**": [
"about.html",
"navigation.html",
"relations.html",
"more.html",
"searchbox.html",
"sidebar/scroll-start.html",
"sidebar/brand.html",
"sidebar/search.html",
"sidebar/navigation.html",
"sidebar/projects.html",
"sidebar/scroll-end.html",
]
}

html_theme_options = {
"logo": "img/cihai.svg",
"github_user": "cihai",
"github_repo": "unihan-db",
"github_type": "star",
"github_banner": True,
"projects": alagitpull.projects,
"project_name": "db",
"project_title": about["__title__"],
"project_description": about["__description__"],
"project_url": about["__docs__"],
"show_meta_manifest_tag": True,
"show_meta_og_tags": True,
"show_meta_app_icon_tags": True,
}

alagitpull_internal_hosts = ["unihan-db.git-pull.com", "0.0.0.0"]
alagitpull_external_hosts_new_window = True
# sphinxext.opengraph
ogp_site_url = about["__docs__"]
ogp_image = "_static/img/icons/icon-192x192.png"
ogp_desscription_length = about["__description__"]
ogp_site_name = about["__title__"]

htmlhelp_basename = "%sdoc" % about["__title__"]

Expand Down

0 comments on commit 07dd3e0

Please sign in to comment.