Skip to content

Commit

Permalink
fix: proper single file mode handling
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Nov 29, 2023
1 parent b672348 commit 8fe223a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub fn generate(
Some(doc_nodes_by_url.keys().next().unwrap().clone());
}

let common_ancestor = find_common_ancestor(doc_nodes_by_url, false);
let common_ancestor = find_common_ancestor(doc_nodes_by_url, true);
let tt = setup_tt()?;
let ctx = GenerateCtx {
package_name: options.package_name,
Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn generate(
all_symbols.clone(),
None,
)?;
files.insert("index.html".to_string(), index);
files.insert("./index.html".to_string(), index);
}

// All symbols (list of all symbols in all files)
Expand All @@ -257,7 +257,7 @@ pub fn generate(

let all_symbols_render =
render_all_symbols(&ctx, &partitions_by_kind, all_symbols.clone())?;
files.insert("all_symbols.html".to_string(), all_symbols_render);
files.insert("./all_symbols.html".to_string(), all_symbols_render);
}

// Pages for all discovered symbols
Expand All @@ -279,7 +279,17 @@ pub fn generate(
Some(short_path.clone()),
)?;

files.insert(format!("{short_path}/~/index.html"), index);
files.insert(
format!(
"{}/~/index.html",
if short_path.is_empty() {
"."
} else {
&short_path
}
),
index,
);

files.extend(generate_pages_for_file(
&ctx,
Expand Down Expand Up @@ -378,10 +388,11 @@ fn generate_pages_inner(
Vec::with_capacity(name_partitions.values().len() * 2);

for (name, doc_nodes) in name_partitions.iter() {
let file_name = if file.is_empty() { "." } else { file };
let file_name = if namespace_paths.is_empty() {
format!("{file}/~/{}.html", name)
format!("{file_name}/~/{}.html", name)
} else {
format!("{file}/~/{}.{name}.html", namespace_paths.join("."))
format!("{file_name}/~/{}.{name}.html", namespace_paths.join("."))
};

let page = render_page(
Expand Down
2 changes: 1 addition & 1 deletion src/html/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn render_params(

let content = items.join("");

format!(r#"<div class="ident">{content}</div>"#)
format!(r#"<div style="margin-left: 1rem;">{content}</div>"#)
}
}

Expand Down

0 comments on commit 8fe223a

Please sign in to comment.