sunbeam_ir/lib.rs
1//! An intermediate representation of a css!(...) invocation.
2//!
3//! `css!(...)` macro calls get parsed into this IR.
4//!
5//! This IR is then used when validating and generating CSS files.
6
7#![deny(missing_docs)]
8
9pub use self::{class::*, sunbeam_config::*};
10use std::ops::Deref;
11
12mod parse;
13#[cfg(test)]
14mod parser_and_generator_tests;
15
16mod class;
17mod class_dictionary;
18mod color;
19mod font;
20mod generate_css_file;
21mod sunbeam_config;
22
23/// The data structure that a `css!(...)` invocation gets parsed into.
24#[derive(Debug)]
25pub struct Classes {
26 classes: Vec<RetrievedClassDefinition>,
27}
28
29impl Classes {
30 /// Create a new Classes
31 pub fn new() -> Self {
32 Self {
33 classes: Vec::new(),
34 }
35 }
36
37 /// Add more parsed classes to this set of classes.
38 pub fn extend(&mut self, other: Classes) {
39 self.classes.extend(other.classes.into_iter())
40 }
41}
42
43impl Deref for Classes {
44 type Target = Vec<RetrievedClassDefinition>;
45
46 fn deref(&self) -> &Self::Target {
47 &self.classes
48 }
49}
50
51#[cfg(test)]
52mod intentionally_here {
53 //! Keeping this here makes it easy to run all of the crate's tests from within the IDE.
54 //! You can call run tests in your IDE from the lib.rs file
55 //! (as long as your cursor is outside of this test module), which will then run all
56 //! of the tests in the crate (since every module is a descendent of lib.rs.)
57
58 #[test]
59 fn intentionally_here() {}
60}