{name}
"
"Saved result: 42 cells.
"
"def count():\n return 42\n\nprint(count())\n42
"
@@ -757,7 +759,9 @@ def rendered_discovery_files(
"# CyteType class\n\n```{autoclass} cytetype.CyteType\n:members:\n```\n"
)
(html / "api" / "cytetype.html").write_text(
- 'CyteType class"
+ ''
+ ''
"CyteType(adata, group_key, rank_key='rank_genes_groups')"
)
@@ -1437,3 +1441,256 @@ def test_staged_config_paths_are_relative_to_the_site(executable_docs: Any) -> N
for path, original in zip(paths, originals, strict=True):
assert not Path(path).is_absolute(), path
assert (site / path).resolve() == (build_docs.SOURCE / original).resolve()
+
+
+@pytest.mark.parametrize("base_url", ["", "/CyteType"])
+def test_api_pages_join_the_staged_guide_navigation(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, base_url: str
+) -> None:
+ pytest.importorskip("jupytext")
+ pytest.importorskip("nbformat")
+ yaml = pytest.importorskip("yaml")
+ from docs import build_docs
+
+ api = tmp_path / "docs" / "build" / "api"
+ api.mkdir(parents=True)
+ (api / "index.html").write_text(
+ '"
+ )
+ site = tmp_path / "site"
+ site.mkdir()
+ config = {
+ "project": {
+ "toc": [
+ {"file": "index.md"},
+ {
+ "title": "Reference",
+ "children": [
+ {"url": f"{base_url}/api/index.html", "title": "API reference"}
+ ],
+ },
+ ]
+ }
+ }
+ (site / "myst.yml").write_text(yaml.safe_dump(config))
+ monkeypatch.setattr(build_docs, "DOCS", api.parents[1])
+ monkeypatch.setenv("BASE_URL", base_url)
+
+ build_docs.include_api_navigation(site)
+
+ toc = yaml.safe_load((site / "myst.yml").read_text())["project"]["toc"]
+ assert toc[0] == {"file": "index.md"}
+ assert toc[1]["children"][0]["children"] == [
+ {
+ "title": "CyteType class",
+ "url": f"{base_url}/api/cytetype.html",
+ "open_in_same_tab": True,
+ },
+ {
+ "title": "Helpers & utilities",
+ "url": f"{base_url}/api/helpers.html",
+ "open_in_same_tab": True,
+ },
+ ]
+
+
+@pytest.mark.parametrize("base_url", ["", "/CyteType"])
+def test_api_pages_keep_the_guide_header_navigation_and_existing_content(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, base_url: str
+) -> None:
+ pytest.importorskip("jupytext")
+ pytest.importorskip("nbformat")
+ pytest.importorskip("yaml")
+ from docs import build_docs
+
+ monkeypatch.setenv("BASE_URL", base_url)
+ html = tmp_path / "html"
+ api = html / "api"
+ api.mkdir(parents=True)
+ header = (
+ ''
+ )
+ navigation = (
+ '"
+ )
+ (html / "index.html").write_text(
+ f"{header}{navigation}"
+ )
+ article = 'CyteType
Method'
+ for name in ("index.html", "cytetype.html", "search.html", "genindex.html"):
+ (api / name).write_text(
+ ''
+ '{article}"
+ )
+ (api / "objects.inv").write_bytes(b"existing Sphinx inventory")
+ static = api / "_static"
+ static.mkdir()
+ (static / "webpack-macros.html").write_text("{% macro assets() %}{% endmacro %}")
+
+ build_docs.integrate_api_navigation(html)
+
+ for page in api.glob("*.html"):
+ contents = page.read_text()
+ copied_header = build_docs.html_fragment(contents, "myst-top-nav-bar")
+ copied_navigation = build_docs.html_fragment(
+ contents, "myst-primary-sidebar-toc"
+ )
+ assert 'class="myst-search-bar search-button__button"' in copied_header
+ assert (
+ 'class="myst-top-nav-menu-button sidebar-toggle primary-toggle"'
+ in copied_header
+ )
+ assert "myst-search-bar-disabled" not in copied_header
+ assert 'aria-label="Search documentation"' in copied_header
+ assert 'aria-controls="pst-search-dialog"' in copied_header
+ assert "aria-expanded" not in copied_header
+ assert "data-state" not in copied_header
+ assert "