fixup styles for internal doc banner

This commit is contained in:
David Hewitt 2023-06-08 22:04:48 +01:00
parent 46942b9a14
commit 05af0b2f42
3 changed files with 49 additions and 3 deletions

View File

@ -60,9 +60,7 @@ echo "<meta http-equiv=refresh content=0;url=pyo3/>" > netlify_build/main/doc/in
## Build internal docs
echo "<div class='internal-banner' style='position:fixed; z-index: 99999; color:red;border:3px solid red;margin-left: auto; margin-right: auto; width: 430px;left:0;right: 0;'><div style='display: flex; align-items: center; justify-content: center;'> ⚠️ Internal Docs ⚠️ Not Public API 👉 <a href='https://pyo3.rs/main/doc/pyo3/index.html' style='color:red;text-decoration:underline;'>Official Docs Here</a></div></div>" > netlify_build/banner.html
RUSTDOCFLAGS="--html-before-content netlify_build/banner.html" nox -s docs -- nightly internal
rm netlify_build/banner.html
nox -s docs -- nightly internal
mkdir -p netlify_build/internal
mv target/doc netlify_build/internal/

View File

@ -0,0 +1,47 @@
<div id='pyo3-internal-banner'>
<div style="white-space: nowrap;">
⚠️ Internal Docs ⚠️ Not Public API 👉
<a href='https://pyo3.rs/main/doc/pyo3/index.html' style='color:red;text-decoration:underline;'>
Official Docs Here
</a>
</div>
<style id="pyo3-noscript-style">
body {
padding-top: 2em;
}
</style>
<style>
#pyo3-internal-banner {
position: fixed;
display: flex;
align-items: center;
justify-content:
center;
z-index: 99999;
color: red;
left: 0;
right: 0;
top: 0;
height: 2em;
border: 3px solid red;
width: 100%;
overflow-x: hidden;
background-color: var(--target-background-color);
}
@media (max-width: 700px) {
#pyo3-internal-banner {
top: 50px;
margin-bottom: 10px;
}
}
</style>
</div>
<script>
// when javascript is active, splice the banner into a "sticky" location
// inside the doc body for best appearance
banner = document.getElementById("pyo3-internal-banner")
banner.style.position = "sticky"
document.getElementsByTagName("main")[0].prepend(banner)
document.getElementById("pyo3-noscript-style").remove()
</script>

View File

@ -305,6 +305,7 @@ def docs(session: nox.Session) -> None:
if "nightly" in session.posargs and "internal" in session.posargs:
rustdoc_flags.append("--Z unstable-options")
rustdoc_flags.append("--document-hidden-items")
rustdoc_flags.extend(("--html-after-content", ".netlify/internal_banner.html"))
cargo_flags.append("--document-private-items")
else:
cargo_flags.extend(["--exclude=pyo3-macros", "--exclude=pyo3-macros-backend"])