Create index.html files in doc gen

This way, even when previewing them locally
you can see (for example) /Str instead of /Str.html
This commit is contained in:
Richard Feldman 2021-06-06 01:27:57 -04:00
parent 6ec8c7e944
commit 1a63bd570f
2 changed files with 5 additions and 16 deletions

View file

@ -63,9 +63,10 @@ pub fn generate(filenames: Vec<PathBuf>, std_lib: StdLib, build_dir: &Path) {
// Write each package's module docs html file // Write each package's module docs html file
for (docs_by_id, interns) in package.modules.iter_mut() { for (docs_by_id, interns) in package.modules.iter_mut() {
for module in docs_by_id.values_mut() { for module in docs_by_id.values_mut() {
let mut filename = String::new(); let module_dir = build_dir.join(module.name.as_str());
filename.push_str(module.name.as_str());
filename.push_str(".html"); fs::create_dir(&module_dir)
.expect("TODO gracefully handle not being able to create the module dir");
let rendered_module = template_html let rendered_module = template_html
.replace( .replace(
@ -78,7 +79,7 @@ pub fn generate(filenames: Vec<PathBuf>, std_lib: StdLib, build_dir: &Path) {
render_main_content(interns, module).as_str(), render_main_content(interns, module).as_str(),
); );
fs::write(build_dir.join(filename), rendered_module) fs::write(module_dir.join("index.html"), rendered_module)
.expect("TODO gracefully handle failing to write html"); .expect("TODO gracefully handle failing to write html");
} }
} }

View file

@ -16,17 +16,5 @@ echo 'Generating docs...'
# We run the CLI with --no-default-features because that way we don't have a LLVM # We run the CLI with --no-default-features because that way we don't have a LLVM
# dependency. (Netlify's build servers have Rust installed, but not LLVM.) # dependency. (Netlify's build servers have Rust installed, but not LLVM.)
cargo run -p roc_cli --no-default-features docs compiler/builtins/docs/Bool.roc cargo run -p roc_cli --no-default-features docs compiler/builtins/docs/Bool.roc
mv generated-docs/ www/build/builtins mv generated-docs/ www/build/builtins
pushd www/build/builtins
for f in ./*.html; do
DIRNAME=$(echo "$f" | sed s/.html//)
mkdir "$DIRNAME"
mv "$f" "$DIRNAME"/index.html
done
popd
popd popd