Skip to content

WIP: Add support for virtual chapters #592

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

Closed
wants to merge 18 commits into from
Closed
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
Next Next commit
Reduce technical depts
This includes:
    - Use 'Self' instead of '<type name>' where possible.
    - Match enums in order of their variants.
  • Loading branch information
teiesti authored and azerupi committed Apr 13, 2018
commit 598c8e36b0891f80eead3ca1336bc635f9f3b55c
9 changes: 5 additions & 4 deletions src/book/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ pub enum BookItem {
}

impl From<Chapter> for BookItem {
fn from(other: Chapter) -> BookItem {
fn from(other: Chapter) -> Self {
BookItem::Chapter(other)
}
}

impl From<VirtualChapter> for BookItem {
fn from(other: VirtualChapter) -> BookItem {
fn from(other: VirtualChapter) -> Self {
BookItem::VirtualChapter(other)
}
}
Expand Down Expand Up @@ -199,8 +199,8 @@ pub struct VirtualChapter {

impl VirtualChapter {
/// Create a new chapter with the provided content.
pub fn new(name: &str, content: String) -> VirtualChapter {
VirtualChapter {
pub fn new(name: &str, content: String) -> Self {
Self {
name: name.to_string(),
content: content,
..Default::default()
Expand Down Expand Up @@ -246,6 +246,7 @@ fn load_summary_item<P: AsRef<Path>>(
load_chapter(link, src_dir, parent_names).map(|c| BookItem::Chapter(c))
}
SummaryItem::VirtualLink(ref link) => unimplemented!(),
SummaryItem::Separator => Ok(BookItem::Separator),
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/book/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ pub struct Link {

impl Link {
/// Create a new link with no nested items.
pub fn new<S: Into<String>, P: AsRef<Path>>(name: S, location: P) -> Link {
Link {
pub fn new<S: Into<String>, P: AsRef<Path>>(name: S, location: P) -> Self {
Self {
name: name.into(),
location: location.as_ref().to_path_buf(),
number: None,
Expand All @@ -91,7 +91,7 @@ impl Link {

impl Default for Link {
fn default() -> Self {
Link {
Self {
name: String::new(),
location: PathBuf::new(),
number: None,
Expand All @@ -115,8 +115,8 @@ pub struct VirtualLink {

impl VirtualLink {
/// Create a new virtual link with no nested items.
pub fn new<S: Into<String>>(name: S) -> VirtualLink {
VirtualLink {
pub fn new<S: Into<String>>(name: S) -> Self {
Self {
name: name.into(),
number: None,
nested_items: Vec::new(),
Expand All @@ -126,7 +126,7 @@ impl VirtualLink {

impl Default for VirtualLink {
fn default() -> Self {
VirtualLink {
Self {
name: String::new(),
number: None,
nested_items: Vec::new(),
Expand Down Expand Up @@ -163,13 +163,13 @@ impl SummaryItem {
}

impl From<Link> for SummaryItem {
fn from(other: Link) -> SummaryItem {
fn from(other: Link) -> Self {
SummaryItem::Link(other)
}
}

impl From<VirtualLink> for SummaryItem {
fn from(other: VirtualLink) -> SummaryItem {
fn from(other: VirtualLink) -> Self {
SummaryItem::VirtualLink(other)
}
}
Expand Down