Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(templ): add csssyntaxraw #92

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
settle for raw
fiji-flo committed Jan 22, 2025

Verified

This commit was signed with the committer’s verified signature.
fiji-flo Florian Dieminger
commit a9e0697f2c84f32da9fd2df65728afda5e8bd76b
17 changes: 3 additions & 14 deletions crates/rari-doc/src/templ/templs/csssyntax.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::LazyLock;

use css_syntax::syntax::{
write_formal_syntax, write_formal_syntax_from_syntax, CssType, LinkedToken,
};
use css_syntax::syntax::{write_formal_syntax, CssType, LinkedToken};
use rari_templ_func::rari_f;
use rari_types::fm_types::PageType;
use tracing::{error, warn};

use crate::error::DocError;
@@ -25,15 +21,8 @@ static TOOLTIPS: LazyLock<HashMap<LinkedToken, String>> = LazyLock::new(|| {
});

#[rari_f]
pub fn csssyntax(name: Option<String>, page_type: Option<String>) -> Result<String, DocError> {
let page_type = if let Some(page_type) = page_type {
PageType::from_str(&page_type).map_err(|_| {
tracing::warn!(source = "invalid_templ_arg");
DocError::ArgError(rari_types::ArgError::MustBeX("valid css page type"))
})?
} else {
env.page_type
};
pub fn csssyntax(name: Option<String>) -> Result<String, DocError> {
let page_type = env.page_type;
let mut slug_rev_iter = env.slug.rsplitn(3, '/');
let slug_name = slug_rev_iter.next().unwrap();
let name = name.as_deref().unwrap_or(slug_name);
2 changes: 0 additions & 2 deletions crates/rari-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -24,8 +24,6 @@ pub enum ArgError {
MustBeBool,
#[error("must be provided")]
MustBeProvided,
#[error("must be {0}")]
MustBeX(&'static str),
}

#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]