Skip to content

Commit

Permalink
[documentation] Add support for multiple sources when parsing librari…
Browse files Browse the repository at this point in the history
…es object model [#95]
  • Loading branch information
cipriancraciun committed Jul 19, 2018
1 parent 2d4df69 commit f898bbe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
15 changes: 11 additions & 4 deletions sources/documentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2888,9 +2888,13 @@ impl Appendix {


#[ cfg_attr ( feature = "vonuvoli_inline", inline ) ]
pub fn parse_library_specifications (input : &str) -> (Outcome<Libraries>) {
pub fn parse_library_specifications <'a> (sources : impl iter::Iterator<Item = &'a str>) -> (Outcome<Libraries>) {

let inputs = try! (parse_values (input, None));
let mut inputs = StdVec::new ();
for source in sources {
let inputs_0 = try! (parse_values (source, None));
inputs.extend (inputs_0);
}

let libraries = try_vec_map_into! (inputs, input, parse_library (input));
let libraries = try! (EntitiesOwned::new_from_rc (libraries));
Expand Down Expand Up @@ -4334,11 +4338,14 @@ fn parse_list_of <T> (input : StdVec<Value>, parser : impl Fn (Value) -> (Outcom
#[ cfg ( feature = "vonuvoli_documentation_sources" ) ]
#[ cfg_attr ( feature = "vonuvoli_inline", inline ) ]
pub fn parse_library_specifications_for_builtins () -> (Outcome<Libraries>) {
return parse_library_specifications (LIBRARY_SPECIFICATIONS_SOURCES);
return parse_library_specifications (LIBRARY_SPECIFICATIONS_SOURCES.iter () .map (ops::Deref::deref));
}

#[ cfg ( feature = "vonuvoli_documentation_sources" ) ]
static LIBRARY_SPECIFICATIONS_SOURCES : &'static str = include_str! ("../documentation/libraries.ss");
static LIBRARY_SPECIFICATIONS_SOURCES : &'static [&'static str] = &[
include_str! ("../documentation/libraries-r7rs.ss"),
include_str! ("../documentation/libraries-vs.ss"),
];



Expand Down
25 changes: 13 additions & 12 deletions sources/tools_documentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,21 @@ pub fn main (inputs : ToolInputs) -> (Outcome<u32>) {
fail! (0x3b57eb47),
};

let source = match inputs.rest_arguments.as_slice () {
[] =>
None,
[ref source] =>
Some (fs_path::Path::new (source)),
_ =>
fail! (0xf4938c6d),
let sources = if ! inputs.rest_arguments.is_empty () {
Some (vec_map! (inputs.rest_arguments.iter (), source, fs_path::Path::new (source)))
} else {
None
};

let libraries = if let Some (source_path) = source {
let mut source_buffer = StdString::new ();
let mut source_stream = try_or_fail! (fs::File::open (source_path), 0x463c39f9);
try_or_fail! (source_stream.read_to_string (&mut source_buffer), 0x4025f07b);
try! (parse_library_specifications (&source_buffer))
let libraries = if let Some (sources_path) = sources {
let mut source_buffers = StdVec::with_capacity (sources_path.len ());
for source_path in &sources_path {
let mut source_buffer = StdString::new ();
let mut source_stream = try_or_fail! (fs::File::open (source_path), 0x463c39f9);
try_or_fail! (source_stream.read_to_string (&mut source_buffer), 0x4025f07b);
source_buffers.push (source_buffer);
}
try! (parse_library_specifications (source_buffers.iter () .map (StdString::deref)))
} else {
#[ cfg ( not ( feature = "vonuvoli_documentation_sources" ) ) ]
fail! (0x834807b9);
Expand Down

0 comments on commit f898bbe

Please sign in to comment.