rustyphoenixlecture 1.1.0

This project aims to provide a simple a powerfull lecture compilation to generate html web sites
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

use crate::phighlighter::PLocation;
use crate::plectureparser::PReferenceUrl;
use crate::plectureparser::plabeler::PLabelId;

///Trait of a Lecture Backend
pub trait PAbstractLectureBackend{
	///Create a new file
	/// # Parameters
	/// - `output_filename` : name of the file to write
	/// - `title` : title of the section
	/// - `location` : location of the current source file where this section was defined
	/// - `prev_page` : previous page to visit
	/// - `next_page` : next page to visit
	fn create_file(&mut self, output_filename: &String, title: &String,
		location: &PLocation,
		prev_page: &String, next_page: &String);
	///Write text in the current file
	/// # Parameters
	/// - `text` : text to write in the current file
	fn write(&mut self, text: &String);
	///Write a formula in html
	/// # Parameters
	/// - `formula` : formula to write in html
	/// # Errors
	/// This function will panic if there is a problem during the formula generation
	fn write_formula(&mut self, formula: &String);
	///Close the current file
	fn close(&mut self);
}

///Definition of the trait for all lecture content
pub trait PAbstractContent{
	///Say if the PContent has an embeded label
	/// # Returns
	/// True if the PContent has an embeded label, false otherwise
	fn has_embeded_label(&self) -> bool;
	///Get the reference url of the current PContent
	/// # Parameters
	/// - `current_file` : current output file of the PContent
	/// - `id` : id of the current PContent
	/// # Returns
	/// Corresponding PReferenceUrl
	fn get_reference_url(&self, current_file: &String, id: usize) -> PReferenceUrl;
	///Convert the current struct into html
	/// # Parameters
	/// - `backend` : backend which write a lecture in files
	/// - `id` : id and label of the current PContent
	fn to_html<TLectureBackend>(&self, backend: &mut TLectureBackend, id: &PLabelId)
		where TLectureBackend: PAbstractLectureBackend;
}

//We can improve the to_html speed by using a stream (so no more copy between all content to be added)
//But the question is : does the fmt::Formatter a stream ?
//With the : fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result

//We need a :
// use std::io::prelude::Write;
// use std::io::BufWriter;

// pub fn save_gnuplot(&self, filename: &Path) -> std::io::Result<()> {
	// let mut file = BufWriter::new(std::fs::File::create(filename).unwrap());
	// file.write(&format!("# PFunctionTimer : save performance of function '{}'\n", self.p_function_name).into_bytes())?;
	// Ok(())
// }