Merge pull request #5420 from roc-lang/docs-index-html

fixed docs index.html overwrite
This commit is contained in:
Anton-4 2023-05-17 20:37:20 +02:00 committed by GitHub
commit b43b12a939
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 9 deletions

View file

@ -135,7 +135,7 @@ pub fn generate_docs_html(root_file: PathBuf) {
// TODO fix: as is, this overrides an existing index.html // TODO fix: as is, this overrides an existing index.html
// Write index.html for package (/index.html) // Write index.html for package (/index.html)
/*{ {
let rendered_package = template_html let rendered_package = template_html
.replace( .replace(
"<!-- Page title -->", "<!-- Page title -->",
@ -156,7 +156,7 @@ pub fn generate_docs_html(root_file: PathBuf) {
error error
) )
}); });
}*/ }
// Write each package module's index.html file // Write each package module's index.html file
for module_docs in loaded_module.docs_by_module.values() { for module_docs in loaded_module.docs_by_module.values() {
@ -196,8 +196,7 @@ fn page_title(package_name: &str, module_name: &str) -> String {
format!("<title>{module_name} - {package_name}</title>") format!("<title>{module_name} - {package_name}</title>")
} }
// TODO re-enable with let rendered_package = template_html... fn render_package_index(root_module: &LoadedModule) -> String {
/*fn render_package_index(root_module: &LoadedModule) -> String {
// The list items containing module links // The list items containing module links
let mut module_list_buf = String::new(); let mut module_list_buf = String::new();
@ -228,7 +227,7 @@ fn page_title(package_name: &str, module_name: &str) -> String {
); );
index_buf index_buf
}*/ }
fn render_module_documentation( fn render_module_documentation(
module: &ModuleDocumentation, module: &ModuleDocumentation,

View file

@ -42,7 +42,7 @@
</main> </main>
<footer> <footer>
<p>Made by people who like to make nice things.</p> <p>Made by people who like to make nice things.</p>
<p>© 2021</p> <p>© 2023</p>
</footer> </footer>
</body> </body>

View file

@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# run from root of repo with `./www/build.sh`
# check www/README.md to run a test server
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail set -euxo pipefail
@ -48,8 +51,11 @@ cargo --version
export ROC_DOCS_URL_ROOT=/builtins export ROC_DOCS_URL_ROOT=/builtins
cargo run --release --bin roc-docs crates/compiler/builtins/roc/main.roc cargo run --release --bin roc-docs crates/compiler/builtins/roc/main.roc
mv generated-docs/*.* www/build # move all the .js, .css, etc. files to build/ mv generated-docs/*.js www/build # move all .js files to build/
mv generated-docs/ www/build/builtins # move all the folders to build/builtins/ mv generated-docs/*.css www/build
mv generated-docs/*.svg www/build
mv generated-docs/ www/build/builtins # move all the rest to build/builtins/
# Manually add this tip to all the builtin docs. # Manually add this tip to all the builtin docs.
find www/build/builtins -type f -name 'index.html' -exec sed -i 's!</nav>!<div class="builtins-tip"><b>Tip:</b> <a href="/different-names">Some names</a> differ from other languages.</div></nav>!' {} \; find www/build/builtins -type f -name 'index.html' -exec sed -i 's!</nav>!<div class="builtins-tip"><b>Tip:</b> <a href="/different-names">Some names</a> differ from other languages.</div></nav>!' {} \;
@ -58,7 +64,7 @@ find www/build/builtins -type f -name 'index.html' -exec sed -i 's!</nav>!<div c
# cleanup files that could have stayed behind if the script failed # cleanup files that could have stayed behind if the script failed
rm -rf roc_nightly roc_releases.json rm -rf roc_nightly roc_releases.json
# to prevent GitHub from rate limiting netlify servers # we use `! [ -v GITHUB_TOKEN_READ_ONLY ];` to check if we're on a netlify server
if ! [ -v GITHUB_TOKEN_READ_ONLY ]; then if ! [ -v GITHUB_TOKEN_READ_ONLY ]; then
echo 'Building tutorial.html from tutorial.md...' echo 'Building tutorial.html from tutorial.md...'
mkdir www/build/tutorial mkdir www/build/tutorial