Skip to content

Commit

Permalink
chore: Merge branch 'refactor/revamp-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 14, 2021
2 parents d3ddcbb + ed2760a commit d705d87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
8 changes: 3 additions & 5 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@
<option value="">Select version...</option>
<option value="latest">latest</option>
<option value="stable">stable</option>
{%- if versions %}
{%- for tag in versions.tags %}
<option value="{{ tag.name }}">{{ tag.name }}</option>
{%- endfor %}
{%- endif %}
{%- for tag in get_versions() %}
<option value="{{ tag }}">{{ tag }}</option>
{%- endfor %}
</select>
</div>

Expand Down
20 changes: 17 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import re
import os
import sys
from pathlib import Path
from typing import List

sys.path.insert(0, os.path.abspath(".."))
Expand Down Expand Up @@ -55,7 +57,7 @@
html_theme = "sphinx_rtd_theme"
html_favicon = "favicon.ico"
html_logo = "logo.jpg"
html_baseurl = '/ape/'
html_baseurl = "/ape/"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -67,11 +69,11 @@
html_css_files = ["custom.css"]


def fixpath(p):
def fixpath(path: str) -> str:
"""
Change paths to reference the resources from 'latest/' to save room.
"""
suffix = p.split("_static")[1]
suffix = path.split("_static")[1]
new = f"/{project}/latest/_static"

if suffix:
Expand All @@ -80,6 +82,18 @@ def fixpath(p):
return new


def get_versions() -> List[str]:
build_dir = Path(__file__).parent / "_build" / "ape"
if not build_dir.exists():
return []

versions = [
d.name for d in build_dir.iterdir() if d.is_dir and re.match(r"v\d+.?\d?.?\d?", d.stem)
]
return versions


html_context = {
"fixpath": fixpath,
"get_versions": get_versions,
}

0 comments on commit d705d87

Please sign in to comment.