Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for the index.html file before trying to opener::open it #1714

Merged
merged 8 commits into from
May 16, 2022

Conversation

joshrotenberg
Copy link
Contributor

@joshrotenberg joshrotenberg commented Dec 29, 2021

Add a function to find the first displayable chapter, and use it when attempting to open the browser in the build, watch and serve command line commands.

Fixes #1713.

@ehuss
Copy link
Contributor

ehuss commented Dec 31, 2021

I think an error would be fine, but if you want to try opening the first non-draft chapter, I think something like the following could work:

if let Some(first) = book.iter().filter_map(|item| match item {
    BookItem::Chapter(Chapter{path: Some(path), ..}) => Some(path),
    _ => None
}).next() {
    let path = book.build_dir_for("html").join(first).with_extension("html");
    dbg!(path);
}

Just keep in mind that the open option is used in multiple commands (build, serve, watch).

@ehuss
Copy link
Contributor

ehuss commented Mar 27, 2022

Just checking in to see if you are still interested in completing this?

@joshrotenberg
Copy link
Contributor Author

Sorry, it fell off my list. I'll pick it back up this week.

@joshrotenberg joshrotenberg marked this pull request as ready for review May 11, 2022 20:18
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Thanks!

@ehuss ehuss merged commit f878266 into rust-lang:master May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants