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

Fixed zero exit code when plugin not found #1122

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update docs and tweak error messages.
  • Loading branch information
ehuss committed Apr 21, 2020
commit 2732c5e8f77c32254778fa192fb247248ebfaa67
2 changes: 1 addition & 1 deletion book-example/src/for_developers/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ the usual `RUST_LOG` to control logging verbosity.

## Handling missing backends

If you should enable a backend that isn't installed, the default behavior is to throw an error:
If you enable a backend that isn't installed, the default behavior is to throw an error:

```text
The command wasn't found, is the "wordcount" backend installed?
Expand Down
14 changes: 10 additions & 4 deletions book-example/src/format/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,17 @@ specify which preprocessors should run before the Markdown renderer.
A custom renderer can be enabled by adding a `[output.foo]` table to your
`book.toml`. Similar to [preprocessors](#configuring-preprocessors) this will
instruct `mdbook` to pass a representation of the book to `mdbook-foo` for
rendering.
rendering. See the [alternative backends] chapter for more detail.

Custom renderers will have access to all configuration within their table
(i.e. anything under `[output.foo]`), and the command to be invoked can be
manually specified with the `command` field.
The custom renderer has access to all the fields within its table (i.e.
anything under `[output.foo]`). mdBook checks for two common fields:

- **command:** The command to execute for this custom renderer. Defaults to
the name of the renderer with the `mdbook-` prefix (such as `mdbook-foo`).
- **optional:** If `true`, then the command will be ignored if it is not
installed, otherwise mdBook will fail with an error. Defaults to `false`.

[alternative backends]: ../for_developers/backends.md

## Environment Variables

Expand Down
12 changes: 7 additions & 5 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,17 @@ impl CmdRenderer {
};

if is_optional {
warn!("The command was not found, but was marked as optional.");
warn!("\tCommand: {}", self.cmd);
warn!(
"The command `{}` for backend `{}` was not found, \
but was marked as optional.",
self.cmd, self.name
);
return Ok(());
} else {
error!(
"The command wasn't found, is the \"{}\" backend installed?",
self.name
"The command `{}` wasn't found, is the `{}` backend installed?",
self.cmd, self.name
);
error!("\tCommand: {}", self.cmd);
}
}
_ => {}
Expand Down