@@ -160,6 +160,8 @@ pub struct Chapter {
160
160
pub sub_items : Vec < BookItem > ,
161
161
/// The chapter's location, relative to the `SUMMARY.md` file.
162
162
pub path : Option < PathBuf > ,
163
+ /// The chapter's source file, relative to the `SUMMARY.md` file.
164
+ pub source_path : Option < PathBuf > ,
163
165
/// An ordered list of the names of each chapter above this one in the hierarchy.
164
166
pub parent_names : Vec < String > ,
165
167
}
@@ -169,13 +171,15 @@ impl Chapter {
169
171
pub fn new < P : Into < PathBuf > > (
170
172
name : & str ,
171
173
content : String ,
172
- path : P ,
174
+ p : P ,
173
175
parent_names : Vec < String > ,
174
176
) -> Chapter {
177
+ let path: PathBuf = p. into ( ) ;
175
178
Chapter {
176
179
name : name. to_string ( ) ,
177
180
content,
178
- path : Some ( path. into ( ) ) ,
181
+ path : Some ( path. clone ( ) ) ,
182
+ source_path : Some ( path) ,
179
183
parent_names,
180
184
..Default :: default ( )
181
185
}
@@ -188,6 +192,7 @@ impl Chapter {
188
192
name : name. to_string ( ) ,
189
193
content : String :: new ( ) ,
190
194
path : None ,
195
+ source_path : None ,
191
196
parent_names,
192
197
..Default :: default ( )
193
198
}
@@ -438,6 +443,7 @@ And here is some \
438
443
content : String :: from ( "Hello World!" ) ,
439
444
number : Some ( SectionNumber ( vec ! [ 1 , 2 ] ) ) ,
440
445
path : Some ( PathBuf :: from ( "second.md" ) ) ,
446
+ source_path : Some ( PathBuf :: from ( "second.md" ) ) ,
441
447
parent_names : vec ! [ String :: from( "Chapter 1" ) ] ,
442
448
sub_items : Vec :: new ( ) ,
443
449
} ;
@@ -446,6 +452,7 @@ And here is some \
446
452
content : String :: from ( DUMMY_SRC ) ,
447
453
number : None ,
448
454
path : Some ( PathBuf :: from ( "chapter_1.md" ) ) ,
455
+ source_path : Some ( PathBuf :: from ( "chapter_1.md" ) ) ,
449
456
parent_names : Vec :: new ( ) ,
450
457
sub_items : vec ! [
451
458
BookItem :: Chapter ( nested. clone( ) ) ,
@@ -470,6 +477,7 @@ And here is some \
470
477
name: String :: from( "Chapter 1" ) ,
471
478
content: String :: from( DUMMY_SRC ) ,
472
479
path: Some ( PathBuf :: from( "chapter_1.md" ) ) ,
480
+ source_path: Some ( PathBuf :: from( "chapter_1.md" ) ) ,
473
481
..Default :: default ( )
474
482
} ) ] ,
475
483
..Default :: default ( )
@@ -510,6 +518,7 @@ And here is some \
510
518
content: String :: from( DUMMY_SRC ) ,
511
519
number: None ,
512
520
path: Some ( PathBuf :: from( "Chapter_1/index.md" ) ) ,
521
+ source_path: Some ( PathBuf :: from( "Chapter_1/index.md" ) ) ,
513
522
parent_names: Vec :: new( ) ,
514
523
sub_items: vec![
515
524
BookItem :: Chapter ( Chapter :: new(
@@ -562,6 +571,7 @@ And here is some \
562
571
content: String :: from( DUMMY_SRC ) ,
563
572
number: None ,
564
573
path: Some ( PathBuf :: from( "Chapter_1/index.md" ) ) ,
574
+ source_path: Some ( PathBuf :: from( "Chapter_1/index.md" ) ) ,
565
575
parent_names: Vec :: new( ) ,
566
576
sub_items: vec![
567
577
BookItem :: Chapter ( Chapter :: new(
0 commit comments