Skip to content

Conversation

@TheKrol
Copy link
Contributor

@TheKrol TheKrol commented Dec 20, 2025

This should allow you to add more than one folder from root, in case you have multiple doc paths, such as we do for the wiki.

@TheKrol TheKrol requested a review from zleyyij December 20, 2025 19:16
@TheKrol TheKrol linked an issue Dec 20, 2025 that may be closed by this pull request
Copy link
Contributor

@zleyyij zleyyij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work, a little bit confused as to why a whole bunch of typescript was commented out, if intentional plz leave comment explaining why

None => continue,
};

// Use map_or_else instead of if let/else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is a little bit confusing, it doesn't really explain why


let candidate = doc_root.join(candidate_rel);

tracing::debug!("Trying candidate path: {:?}", candidate.display());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention with the rest of the project I would import tracing::debug and shorten this line to debug!(...)

tracing::debug!("Trying candidate path: {:?}", candidate.display());

if let Some(bytes) = Self::get_file(&candidate)? {
let doc = String::from_utf8(bytes).unwrap(); // assuming valid UTF-8 files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to unwrap where the function returns a Result, I'd .wrap_err and propagate with ?.

If you do prefer that this is more of a strict assertion, use .expect("file must be valid utf 8")

}
}
if children.is_empty() {
Err("No doc tree found in any doc root".to_owned())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idiomatic way to do this with color_eyre is with the bail! macro, see https://docs.rs/eyre/latest/eyre/macro.bail.html

///
/// EG: `./repo/docs`
doc_path: PathBuf,
doc_path: Vec<PathBuf>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was pluralized but the docstring was not, you might want to explain what multiple paths does and how it works/why you'd want multiple

return Ok(());
}
}
Err(format!("Document {:?} not found in any doc root", path.as_ref()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assets_path: String,
) -> Result<Self> {
let doc_path = PathBuf::from(docs_path);
let doc_path: Vec<PathBuf> = docs_path.into_iter().collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure this line does nothing, you're iterating over a vector of pathbufs and collecting it into a vector of pathbufs. It was previously needed because the function took a string and converted it into a pathbuf but now it's just a pathbuf.

Also unsure of why the function takes Strings instead of &str, I don't remember if/why that decision was made. You typically want functions to take &str as an argument because it's cheap and ergonomic to have a reference to a string, but relatively expensive and unergonomic to heap allocate, i.e &v is coercible from &String to &str vs v.to_string()

* If the toast is not displayed, this is set to zero. If it *is* displayed, this is the ID of the toast being rendered.
*/
let toastId = -1;
//let toastId = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

export async function renderMarkdown(input: string, output: HTMLElement): Promise<void> {
// Parse front matter and get title, description, and markdown content
getFrontMatterType(input);
// getFrontMatterType(input);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the includes and embed folder with the wiki

3 participants