Skip to content

Commit

Permalink
[skip ci] updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vi Eng (CI) committed Sep 13, 2023
1 parent aa3e77f commit eccf661
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 4,218 deletions.
213 changes: 5 additions & 208 deletions gcloud.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@
<input id="togglestate" type="checkbox" aria-hidden="true" tabindex="-1">
<div>

<input type="search" placeholder="Search..." role="searchbox" aria-label="search"
pattern=".+" required>


<h2>Submodules</h2>
<ul>
<li><a href="gcloud/aio.html">aio</a></li>
<li><a href="gcloud/rest.html">rest</a></li>
</ul>



Expand All @@ -42,207 +35,11 @@ <h2>Submodules</h2>
<h1 class="modulename">
gcloud </h1>

<div class="docstring"><p></p>
</div>

<input id="mod-gcloud-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">

<label class="view-source-button" for="mod-gcloud-view-source"><span>View Source</span></label>

<div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos">1</span></a><span class="sd">&quot;&quot;&quot;</span>
</span><span id="L-2"><a href="#L-2"><span class="linenos">2</span></a><span class="sd">.. include:: ../../docs/gcloud.md</span>
</span><span id="L-3"><a href="#L-3"><span class="linenos">3</span></a><span class="sd">&quot;&quot;&quot;</span>
</span><span id="L-4"><a href="#L-4"><span class="linenos">4</span></a><span class="k">try</span><span class="p">:</span>
</span><span id="L-5"><a href="#L-5"><span class="linenos">5</span></a> <span class="kn">import</span> <span class="nn">pkg_resources</span>
</span><span id="L-6"><a href="#L-6"><span class="linenos">6</span></a> <span class="n">pkg_resources</span><span class="o">.</span><span class="n">declare_namespace</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
</span><span id="L-7"><a href="#L-7"><span class="linenos">7</span></a><span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
</span><span id="L-8"><a href="#L-8"><span class="linenos">8</span></a> <span class="kn">import</span> <span class="nn">pkgutil</span>
</span><span id="L-9"><a href="#L-9"><span class="linenos">9</span></a> <span class="n">__path__</span> <span class="o">=</span> <span class="n">pkgutil</span><span class="o">.</span><span class="n">extend_path</span><span class="p">(</span><span class="n">__path__</span><span class="p">,</span> <span class="vm">__name__</span><span class="p">)</span>
</span></pre></div>






</section>
</main>
<script>
function escapeHTML(html) {
return document.createElement('div').appendChild(document.createTextNode(html)).parentNode.innerHTML;
}

const originalContent = document.querySelector("main.pdoc");
let currentContent = originalContent;

function setContent(innerHTML) {
let elem;
if (innerHTML) {
elem = document.createElement("main");
elem.classList.add("pdoc");
elem.innerHTML = innerHTML;
} else {
elem = originalContent;
}
if (currentContent !== elem) {
currentContent.replaceWith(elem);
currentContent = elem;
}
}

function getSearchTerm() {
return (new URL(window.location)).searchParams.get("search");
}

const searchBox = document.querySelector(".pdoc input[type=search]");
searchBox.addEventListener("input", function () {
let url = new URL(window.location);
if (searchBox.value.trim()) {
url.hash = "";
url.searchParams.set("search", searchBox.value);
} else {
url.searchParams.delete("search");
}
history.replaceState("", "", url.toString());
onInput();
});
window.addEventListener("popstate", onInput);


let search, searchErr;

async function initialize() {
try {
search = await new Promise((resolve, reject) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
script.onload = () => resolve(window.pdocSearch);
script.onerror = (e) => reject(e);
script.src = "search.js";
document.getElementsByTagName("head")[0].appendChild(script);
});
} catch (e) {
console.error("Cannot fetch pdoc search index");
searchErr = "Cannot fetch search index.";
}
onInput();

document.querySelector("nav.pdoc").addEventListener("click", e => {
if (e.target.hash) {
searchBox.value = "";
searchBox.dispatchEvent(new Event("input"));
}
});
}

function onInput() {
setContent((() => {
const term = getSearchTerm();
if (!term) {
return null
}
if (searchErr) {
return `<h3>Error: ${searchErr}</h3>`
}
if (!search) {
return "<h3>Searching...</h3>"
}

window.scrollTo({top: 0, left: 0, behavior: 'auto'});

const results = search(term);

let html;
if (results.length === 0) {
html = `No search results for '${escapeHTML(term)}'.`
} else {
html = `<h4>${results.length} search result${results.length > 1 ? "s" : ""} for '${escapeHTML(term)}'.</h4>`;
}
for (let result of results.slice(0, 10)) {
let doc = result.doc;
let url = `${doc.modulename.replaceAll(".", "/")}.html`;
if (doc.qualname) {
url += `#${doc.qualname}`;
}

let heading;
switch (result.doc.kind) {
case "function":
if (doc.fullname.endsWith(".__init__")) {
heading = `<span class="name">${doc.fullname.replace(/\.__init__$/, "")}</span>${doc.signature}`;
} else {
heading = `<span class="def">${doc.funcdef}</span> <span class="name">${doc.fullname}</span>${doc.signature}`;
}
break;
case "class":
heading = `<span class="def">class</span> <span class="name">${doc.fullname}</span>`;
if (doc.bases)
heading += `<wbr>(<span class="base">${doc.bases}</span>)`;
heading += `:`;
break;
case "variable":
heading = `<span class="name">${doc.fullname}</span>`;
if (doc.annotation)
heading += `<span class="annotation">${doc.annotation}</span>`;
if (doc.default_value)
heading += `<span class="default_value"> = ${doc.default_value}</span>`;
break;
default:
heading = `<span class="name">${doc.fullname}</span>`;
break;
}
html += `
<section class="search-result">
<a href="${url}" class="attr ${doc.kind}">${heading}</a>
<div class="docstring">${doc.doc}</div>
</section>
`;

}
return html;
})());
}

if (getSearchTerm()) {
initialize();
searchBox.value = getSearchTerm();
onInput();
} else {
searchBox.addEventListener("focus", initialize, {once: true});
}

searchBox.addEventListener("keydown", e => {
if (["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) {
let focused = currentContent.querySelector(".search-result.focused");
if (!focused) {
currentContent.querySelector(".search-result").classList.add("focused");
} else if (
e.key === "ArrowDown"
&& focused.nextElementSibling
&& focused.nextElementSibling.classList.contains("search-result")
) {
focused.classList.remove("focused");
focused.nextElementSibling.classList.add("focused");
focused.nextElementSibling.scrollIntoView({
behavior: "smooth",
block: "nearest",
inline: "nearest"
});
} else if (
e.key === "ArrowUp"
&& focused.previousElementSibling
&& focused.previousElementSibling.classList.contains("search-result")
) {
focused.classList.remove("focused");
focused.previousElementSibling.classList.add("focused");
focused.previousElementSibling.scrollIntoView({
behavior: "smooth",
block: "nearest",
inline: "nearest"
});
} else if (
e.key === "Enter"
) {
focused.querySelector("a").click();
}
}
});
</script></body>
</body>
</html>
Loading

0 comments on commit eccf661

Please sign in to comment.