<style>
.sidebar-elems ul.block.crate,
.sidebar-elems h3:has(+ ul.block.crate) {
display: none;
}
.sidebar h3.techy-nav-h {
font-size: 0.8125rem;
text-transform: uppercase;
letter-spacing: 0.09em;
margin: 1.1rem 0 0.35rem;
padding-top: 0.7rem;
border-top: 1px solid var(--sidebar-border-color);
}
.sidebar .techy-guide-nav h3.techy-nav-h {
border-top: none;
padding-top: 0;
margin-top: 0.5rem;
}
.sidebar .techy-api-nav h3,
.sidebar .techy-guide-nav h3:not(.techy-nav-h) {
font-size: 1rem;
}
.sidebar .techy-guide-nav li.current a,
.sidebar ul.techy-crates li.current a {
background-color: var(--sidebar-current-link-background-color);
}
</style>
<script>
document.addEventListener("DOMContentLoaded", () => {
"use strict";
const GUIDE_PAGES = [
["", "Overview"],
["introduction/", "Introduction"],
["language_syntax/", "Language syntax"],
["node_trees/", "Node trees"],
["specs/", "Defining macros, environments, and specials"],
["parsing/", "Running the parser"],
["learn_by_example/", "Learn techy by example"],
["concepts_overview/", "Concepts overview"],
["parsing_model/", "The parsing model"],
["construct_parsers/", "Custom construct parsers"],
["custom_lang/", "Defining a custom language"],
["integration/", "Integration: tooling, embedding, and bindings"],
["serialize/", "Serializing parses"],
["panics/", "List of panicking items"],
["pylatexenc_migration/", "Migrating from pylatexenc"],
["ai_guide/", "AI guide"],
["ai_guide_definitions/", "AI guide: definitions"],
["ai_guide_trees/", "AI guide: node trees"],
["ai_guide_custom_lang/", "AI guide: custom languages"],
["ai_guide_embedding/", "AI guide: embedding"],
["ai_guide_serialize/", "AI guide: serialization"],
["ai_guide_pylatexenc/", "AI guide: pylatexenc migration"],
];
const CRATES = [["techy", "techy"], ["techy_derive", "techy-derive"]];
const vars = document.querySelector("meta[name='rustdoc-vars']");
const elems = document.querySelector("nav.sidebar .sidebar-elems");
if (!vars || !elems) {
return;
}
const rootPath = vars.getAttribute("data-root-path") || "./";
const currentCrate = vars.getAttribute("data-current-crate");
const docsRsVersion = window.location.hostname === "docs.rs"
? window.location.pathname.split("/")[2]
: null;
const href = (name, path) => {
if (docsRsVersion && name !== currentCrate) {
const entry = CRATES.find(([crate]) => crate === name);
const pkg = entry ? entry[1] : name;
return "https://docs.rs/" + pkg + "/" + docsRsVersion + "/" +
name + "/" + path;
}
return new URL(rootPath + name + "/" + path, window.location.href).href;
};
const sectionHeader = text => {
const h = document.createElement("h3");
h.className = "techy-nav-h";
h.textContent = text;
return h;
};
const linkItem = (url, text) => {
const a = document.createElement("a");
a.href = url;
a.textContent = text;
const item = document.createElement("li");
item.appendChild(a);
return item;
};
for (const crateList of elems.querySelectorAll("ul.block.crate")) {
const heading = crateList.previousElementSibling;
if (heading && heading.tagName === "H3") {
heading.remove();
}
crateList.remove();
}
const api = document.createElement("section");
api.className = "techy-api-nav";
while (elems.firstChild) {
api.appendChild(elems.firstChild);
}
const guide = document.createElement("section");
guide.className = "techy-guide-nav";
guide.appendChild(sectionHeader("Guide"));
const chapters = document.createElement("ul");
chapters.className = "block";
let onGuidePage = false;
for (const [sub, title] of GUIDE_PAGES) {
const url = href("techy", "guide/" + sub + "index.html");
const item = linkItem(url, title);
if (new URL(url).pathname === window.location.pathname) {
item.className = "current";
onGuidePage = true;
}
chapters.appendChild(item);
}
guide.appendChild(chapters);
const crates = document.createElement("ul");
crates.className = "block techy-crates";
for (const [name] of CRATES) {
const item = linkItem(href(name, "index.html"), name);
if (name === currentCrate) {
item.className = "current";
}
crates.appendChild(item);
}
if (onGuidePage) {
const toc = api.querySelector("#rustdoc-toc");
if (toc) {
for (const child of Array.from(toc.children)) {
const keep = child.classList.contains("top-toc") ||
(child.nextElementSibling !== null &&
child.nextElementSibling.classList.contains("top-toc"));
if (!keep) {
child.remove();
}
}
guide.appendChild(toc);
}
api.textContent = "";
}
elems.appendChild(guide);
elems.appendChild(sectionHeader("API"));
elems.appendChild(crates);
elems.appendChild(api);
});
</script>