diff --git a/README.md b/README.md index 74960c6..0f714a4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ - -
CyteType
diff --git a/docs/build_docs.py b/docs/build_docs.py
index baf82ef..7b0abce 100644
--- a/docs/build_docs.py
+++ b/docs/build_docs.py
@@ -400,6 +400,9 @@ def write_discovery_files(
f''
f''
)
+ if route.endswith("/"):
+ script_url = "https://docs.nygen.io/assets/brand/docs.js"
+ links += f''
if not count:
links = canonical_tag + links
if contents.count("") != 1:
@@ -655,6 +658,77 @@ def staged_path(path: str) -> str:
return SITE
+def link_shared_brand_assets(html: Path) -> None:
+ source_options = yaml.safe_load((SOURCE / "myst.yml").read_text())["site"]["options"]
+ config = json.loads((html / "config.json").read_text())
+ urls = {
+ config["options"][key]: source_options[key]
+ for key in ("logo", "logo_dark", "favicon", "style")
+ }
+ nodes = [config["parts"]["navbar_end"]["mdast"]]
+ symbols = []
+ while nodes:
+ node = nodes.pop()
+ if node.get("type") == "image" and node.get("class") == "brand-symbol":
+ symbols.append(node["url"])
+ nodes.extend(node.get("children", []))
+ if len(symbols) != 1:
+ raise ValueError(f"Expected one Nygen symbol in {html / 'config.json'}")
+ urls[symbols[0]] = "https://docs.nygen.io/assets/brand/logo/nygen-symbol.svg"
+ base_url = os.environ.get("BASE_URL", "").rstrip("/")
+ for page in html.rglob("*"):
+ if page.suffix not in {".html", ".json"}:
+ continue
+ contents = page.read_text()
+ for local, public in urls.items():
+ contents = contents.replace(f"{base_url}/build{local}", public)
+ contents = contents.replace(local, public)
+ for name, public in (
+ ("favicon.ico", source_options["favicon"]),
+ ("myst-theme.css", source_options["style"]),
+ ):
+ contents = contents.replace(f"{base_url}/{name}", public)
+ page.write_text(contents)
+ roots = list((html / "build").glob("root-*.js"))
+ if len(roots) != 1:
+ raise ValueError(f"Expected one generated theme root in {html / 'build'}")
+ contents = roots[0].read_text()
+ for name, public in (
+ ("favicon.ico", source_options["favicon"]),
+ ("myst-theme.css", source_options["style"]),
+ ):
+ pattern = r'href:`\$\{[\w$]+\|\|""\}/' + re.escape(name) + r'`'
+ contents, count = re.subn(pattern, f"href:{json.dumps(public)}", contents)
+ if count != 1:
+ raise ValueError(f"Expected one {name} link in {roots[0]}")
+ roots[0].write_text(contents)
+ renames = {
+ roots[0].name: f"root-{hashlib.sha256(contents.encode()).hexdigest()[:12]}.js"
+ }
+ manifests = list((html / "build").glob("manifest-*.js"))
+ if len(manifests) != 1:
+ raise ValueError(f"Expected one generated manifest in {html / 'build'}")
+ contents = manifests[0].read_text().replace(roots[0].name, renames[roots[0].name])
+ renames[manifests[0].name] = (
+ f"manifest-{hashlib.sha256(contents.encode()).hexdigest()[:12]}.js"
+ )
+ for page in html.rglob("*"):
+ if page.suffix not in {".html", ".json", ".js"}:
+ continue
+ contents = page.read_text()
+ updated = contents
+ for old, new in renames.items():
+ updated = updated.replace(old, new)
+ if updated != contents:
+ page.write_text(updated)
+ for old, new in renames.items():
+ (html / "build" / old).rename(html / "build" / new)
+ for local in urls:
+ (html / "build" / local.lstrip("/")).unlink()
+ (html / "favicon.ico").unlink()
+ (html / "myst-theme.css").unlink()
+
+
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
@@ -683,6 +757,7 @@ def main() -> None:
SITE / "_build" / "html", DOCS / "build" / "api" / ".doctrees"
),
)
+ link_shared_brand_assets(SITE / "_build" / "html")
if __name__ == "__main__":
diff --git a/docs/source/myst.yml b/docs/source/myst.yml
index f945842..a40520f 100644
--- a/docs/source/myst.yml
+++ b/docs/source/myst.yml
@@ -1,6 +1,7 @@
version: 1
project:
title: CyteType
+ short_title: Overview
description: Annotate the clusters of single-cell RNA-seq data from Python (Scanpy and
AnnData) or R (Seurat) with CyteType, and read the evidence for each label.
github: https://github.com/NygenAnalytics/CyteType
@@ -88,10 +89,16 @@ project:
- url: https://github.com/NygenAnalytics/CyteTypeR/issues
title: Report an R issue
site:
- template: book-theme
+ template: https://github.com/myst-templates/book-theme/archive/23f2df5493e23dfb1d9433c8aa64c87beb4232a3.zip
parts:
primary_sidebar_footer:
+ navbar_end: ''
options:
folders: true
+ style: https://docs.nygen.io/assets/brand/myst.css
+ favicon: https://docs.nygen.io/assets/brand/logo/cytetype.ico
+ logo: https://docs.nygen.io/assets/brand/logo/cytetype.svg
+ logo_dark: https://docs.nygen.io/assets/brand/logo/cytetype.svg
+ logo_alt: CyteType
logo_text: CyteType
hide_authors: true
diff --git a/docs/source/reference/api/conf.py b/docs/source/reference/api/conf.py
index 94b25c8..cc41538 100644
--- a/docs/source/reference/api/conf.py
+++ b/docs/source/reference/api/conf.py
@@ -43,9 +43,13 @@
always_use_bars_union = True
html_theme = "sphinx_book_theme"
+html_css_files = ["https://docs.nygen.io/assets/brand/docs.css"]
+html_logo = "https://docs.nygen.io/assets/brand/logo/cytetype.svg"
+html_favicon = "https://docs.nygen.io/assets/brand/logo/cytetype.ico"
html_title = "CyteType API reference"
html_baseurl = "https://docs.nygen.io/CyteType/api/"
html_theme_options = {
+ "logo": {"text": "CyteType", "alt_text": "CyteType"},
"repository_url": "https://github.com/NygenAnalytics/CyteType",
"path_to_docs": "docs/source/reference/api",
"use_repository_button": True,
diff --git a/pyproject.toml b/pyproject.toml
index 5281d75..31abc2c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -43,7 +43,7 @@ dev = [
# Builds the MyST site and the Sphinx API reference (make -C docs html), and
# executes the documentation notebooks locally (make -C docs execute-docs).
docs = [
- "mystmd>=1.11.0",
+ "mystmd==1.11.0",
"jupytext>=1.19.6",
"nbclient>=0.10",
"nbformat>=5.10",
diff --git a/uv.lock b/uv.lock
index 0f6bf6c..4acc636 100644
--- a/uv.lock
+++ b/uv.lock
@@ -578,7 +578,7 @@ docs = [
{ name = "ipywidgets" },
{ name = "jupytext", specifier = ">=1.19.6" },
{ name = "myst-parser" },
- { name = "mystmd", specifier = ">=1.11.0" },
+ { name = "mystmd", specifier = "==1.11.0" },
{ name = "nbclient", specifier = ">=0.10" },
{ name = "nbformat", specifier = ">=5.10" },
{ name = "pyyaml" },