diff --git a/README.md b/README.md index c7649530..1889cf81 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ welcome! ```rust use codespan_reporting::diagnostic::{Diagnostic, Label}; use codespan_reporting::files::SimpleFiles; -use codespan_reporting::term::termcolor::{ColorChoice, StandardStream}; +use codespan_reporting::term::{self, termcolor::{ColorChoice, StandardStream}}; // `files::SimpleFile` and `files::SimpleFiles` help you get up and running with // `codespan-reporting` quickly! More complicated use cases can be supported @@ -93,7 +93,9 @@ let diagnostic = Diagnostic::error() let writer = StandardStream::stderr(ColorChoice::Always); let config = codespan_reporting::term::Config::default(); -term::emit(&mut writer.lock(), &config, &files, &diagnostic)?; +term::emit_to_write_style(&mut writer.lock(), &config, &files, &diagnostic)?; + +Ok::<(), codespan_reporting::files::Error>(()) ``` ## Running the CLI example diff --git a/codespan-reporting/src/lib.rs b/codespan-reporting/src/lib.rs index 08580a07..a5ead09a 100644 --- a/codespan-reporting/src/lib.rs +++ b/codespan-reporting/src/lib.rs @@ -1,5 +1,8 @@ -//! Diagnostic reporting support for the codespan crate. - +// README examples require `termcolor`, thus the guard here +#![cfg_attr( + feature = "termcolor", + doc = include_str!("../../README.md") +)] #![forbid(unsafe_code)] #![cfg_attr(not(feature = "std"), no_std)]