diff --git a/src/color.rs b/src/color.rs index 13587cb..7e267b3 100644 --- a/src/color.rs +++ b/src/color.rs @@ -293,7 +293,7 @@ impl From for Error { /// /// Here is an example file: /// -/// ``` +/// ```text /// background = "#5555FF" /// shadow = "#000000" /// view = "#888888" diff --git a/src/lib.rs b/src/lib.rs index ad59b75..6d5c8f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ //! It allows to easily build layouts for text-based applications. //! //! ## Example -//! ``` +//! ```no_run //! extern crate cursive; //! //! use cursive::Cursive; @@ -15,7 +15,7 @@ //! //! siv.add_layer(TextView::new("Hello World!\nPress q to quit.")); //! -//! siv.add_global_callback('q' as i32, |s| s.quit()); +//! siv.add_global_callback('q', |s| s.quit()); //! //! siv.run(); //! } diff --git a/src/printer.rs b/src/printer.rs index fc8a7c9..0d36f7b 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -73,6 +73,9 @@ impl Printer { /// # Examples /// /// ``` + /// # use cursive::printer::Printer; + /// # use cursive::color; + /// # let printer = Printer::new((6,4)); /// printer.with_color(color::HIGHLIGHT, |printer| { /// printer.print((0,0), "This text is highlighted!"); /// }); @@ -103,6 +106,8 @@ impl Printer { /// # Examples /// /// ``` + /// # use cursive::printer::Printer; + /// # let printer = Printer::new((6,4)); /// printer.print_box((0,0), (6,4)); /// ``` pub fn print_box(&self, start: T, size: T) { diff --git a/src/view/box_view.rs b/src/view/box_view.rs index 7ee178c..3c42016 100644 --- a/src/view/box_view.rs +++ b/src/view/box_view.rs @@ -14,8 +14,9 @@ impl BoxView { /// # Example /// /// ``` + /// # use cursive::view::{BoxView,TextView}; /// // Creates a 20x4 BoxView with a TextView content. - /// let box = BoxView::new((20,4), TextView::new("Hello!")) + /// let view = BoxView::new((20,4), TextView::new("Hello!")); /// ``` pub fn new(size: S, view: V) -> Self { BoxView { diff --git a/src/view/dialog.rs b/src/view/dialog.rs index 3d0f5a9..d8119ec 100644 --- a/src/view/dialog.rs +++ b/src/view/dialog.rs @@ -21,7 +21,8 @@ enum Focus { /// # Examples /// /// ``` -/// let dialog = Dialog::new(TextView::new("Hello!")).button("Ok", |s,_| s.quit()); +/// # use cursive::view::{Dialog,TextView}; +/// let dialog = Dialog::new(TextView::new("Hello!")).button("Ok", |s| s.quit()); /// ``` pub struct Dialog { title: String, diff --git a/src/view/mod.rs b/src/view/mod.rs index cbc4995..dcb02eb 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -33,6 +33,7 @@ pub use self::id_view::IdView; pub use self::shadow_view::ShadowView; pub use self::edit_view::EditView; pub use self::select_view::SelectView; +pub use self::scroll::ScrollBase; use event::{Event,EventResult}; use vec::{Vec2,ToVec2}; diff --git a/src/view/scroll.rs b/src/view/scroll.rs index c881122..bc1ca85 100644 --- a/src/view/scroll.rs +++ b/src/view/scroll.rs @@ -86,6 +86,12 @@ impl ScrollBase { /// # Examples /// /// ``` + /// # use cursive::view::ScrollBase; + /// # use cursive::printer::Printer; + /// # let scrollbase = ScrollBase::new(); + /// # let printer = Printer::new((5,1)); + /// # let printer = &printer; + /// let lines = ["Line 1", "Line number 2"]; /// scrollbase.draw(printer, |printer, i| { /// printer.print((0,0), lines[i]); /// }); diff --git a/src/view/view_wrapper.rs b/src/view/view_wrapper.rs index 814f084..f70e585 100644 --- a/src/view/view_wrapper.rs +++ b/src/view/view_wrapper.rs @@ -77,26 +77,33 @@ impl View for T { /// /// If the wrapped view is in a box, just name it in the macro: /// -/// ``` +/// ```rust +/// # #[macro_use] extern crate cursive; +/// # use cursive::view::{View,ViewWrapper}; /// struct BoxFooView { /// content: Box, /// } /// -/// impl ViewWrapper for FooView { +/// impl ViewWrapper for BoxFooView { /// wrap_impl!(self.content); /// } +/// +/// # fn main() { } /// ``` /// /// If the content is directly a view, reference it: /// /// ``` +/// # #[macro_use] extern crate cursive; +/// # use cursive::view::{View,ViewWrapper}; /// struct FooView { /// view: T, /// } /// -/// impl ViewWrapper for FooView { +/// impl ViewWrapper for FooView { /// wrap_impl!(&self.view); /// } +/// # fn main() { } /// ``` #[macro_export] macro_rules! wrap_impl { @@ -121,3 +128,4 @@ macro_rules! wrap_impl { } }; } +