aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2022-03-10 09:02:10 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2022-03-23 19:37:10 +0100
commit07584691a8b2ff44776d22c9f9b2c4ec1b303948 (patch)
tree43549d7d414aad8c728b7f6b6e3c67c0b6004898 /askama_shared/src/lib.rs
parent4c0388d11e1bafb85250b649ff610d3f9c7f9452 (diff)
downloadaskama-07584691a8b2ff44776d22c9f9b2c4ec1b303948.tar.gz
askama-07584691a8b2ff44776d22c9f9b2c4ec1b303948.tar.bz2
askama-07584691a8b2ff44776d22c9f9b2c4ec1b303948.zip
Un-"pub" most of askama_shared's internals
Previously askama_shared exported most of it's internals, so askama_derive could use them. This is not needed anymore.
Diffstat (limited to '')
-rw-r--r--askama_shared/src/lib.rs50
1 files changed, 23 insertions, 27 deletions
diff --git a/askama_shared/src/lib.rs b/askama_shared/src/lib.rs
index 5a8facd..61ddb00 100644
--- a/askama_shared/src/lib.rs
+++ b/askama_shared/src/lib.rs
@@ -21,26 +21,22 @@ mod derive;
mod error;
pub use crate::error::{Error, Result};
pub mod filters;
-#[doc(hidden)]
-pub mod generator;
+mod generator;
pub mod helpers;
-#[doc(hidden)]
-pub mod heritage;
-#[doc(hidden)]
-pub mod input;
-#[doc(hidden)]
-pub mod parser;
+mod heritage;
+mod input;
+mod parser;
#[derive(Debug)]
-pub struct Config<'a> {
- pub dirs: Vec<PathBuf>,
- pub syntaxes: BTreeMap<String, Syntax<'a>>,
- pub default_syntax: &'a str,
- pub escapers: Vec<(HashSet<String>, String)>,
+struct Config<'a> {
+ dirs: Vec<PathBuf>,
+ syntaxes: BTreeMap<String, Syntax<'a>>,
+ default_syntax: &'a str,
+ escapers: Vec<(HashSet<String>, String)>,
}
impl Config<'_> {
- pub fn new(s: &str) -> std::result::Result<Config<'_>, CompileError> {
+ fn new(s: &str) -> std::result::Result<Config<'_>, CompileError> {
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let default_dirs = vec![root.join("templates")];
@@ -108,7 +104,7 @@ impl Config<'_> {
})
}
- pub fn find_template(
+ fn find_template(
&self,
path: &str,
start_at: Option<&Path>,
@@ -136,13 +132,13 @@ impl Config<'_> {
}
#[derive(Debug)]
-pub struct Syntax<'a> {
- pub block_start: &'a str,
- pub block_end: &'a str,
- pub expr_start: &'a str,
- pub expr_end: &'a str,
- pub comment_start: &'a str,
- pub comment_end: &'a str,
+struct Syntax<'a> {
+ block_start: &'a str,
+ block_end: &'a str,
+ expr_start: &'a str,
+ expr_end: &'a str,
+ comment_start: &'a str,
+ comment_end: &'a str,
}
impl Default for Syntax<'_> {
@@ -241,7 +237,7 @@ struct RawEscaper<'a> {
extensions: Vec<&'a str>,
}
-pub fn read_config_file() -> std::result::Result<String, CompileError> {
+fn read_config_file() -> std::result::Result<String, CompileError> {
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let filename = root.join(CONFIG_FILE_NAME);
if filename.exists() {
@@ -260,7 +256,7 @@ where
}
#[allow(clippy::match_wild_err_arm)]
-pub fn get_template_source(tpl_path: &Path) -> std::result::Result<String, CompileError> {
+fn get_template_source(tpl_path: &Path) -> std::result::Result<String, CompileError> {
match fs::read_to_string(tpl_path) {
Err(_) => Err(format!(
"unable to open template file '{}'",
@@ -285,20 +281,20 @@ static DEFAULT_ESCAPERS: &[(&[&str], &str)] = &[
];
#[derive(Debug, Clone)]
-pub struct CompileError {
+struct CompileError {
msg: Cow<'static, str>,
span: Span,
}
impl CompileError {
- pub fn new<S: Into<Cow<'static, str>>>(s: S, span: Span) -> Self {
+ fn new<S: Into<Cow<'static, str>>>(s: S, span: Span) -> Self {
Self {
msg: s.into(),
span,
}
}
- pub fn into_compile_error(self) -> TokenStream {
+ fn into_compile_error(self) -> TokenStream {
syn::Error::new(self.span, self.msg).to_compile_error()
}
}