Home / File/ ruby.rs — tailwindcss Source File

ruby.rs — tailwindcss Source File

Architecture documentation for ruby.rs, a rust file in the tailwindcss codebase. 8 imports, 0 dependents.

File rust OxideEngine PreProcessors 8 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  de63b342_bc8b_68a8_063b_cc3f8524fd2c["ruby.rs"]
  6b2bb789_ddf0_a9e0_0d8f_6783947644a0["super::Ruby"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> 6b2bb789_ddf0_a9e0_0d8f_6783947644a0
  e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e["crate::cursor"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e
  152ed748_080f_19db_956e_a85efc0c6133["crate::extractor::bracket_stack"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> 152ed748_080f_19db_956e_a85efc0c6133
  a55fec3d_3fee_4b46_48f2_43f3844c61e4["crate::extractor::pre_processors::pre_processor::PreProcessor"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> a55fec3d_3fee_4b46_48f2_43f3844c61e4
  77ca3446_b0bf_af88_0e9b_c56988f2aef5["crate::scanner::pre_process_input"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> 77ca3446_b0bf_af88_0e9b_c56988f2aef5
  79ed493e_0b38_7678_1312_73cb98aa7983["bstr::ByteVec"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> 79ed493e_0b38_7678_1312_73cb98aa7983
  a33fe18e_cc02_1fad_3c7f_b113de5a6161["regex::"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> a33fe18e_cc02_1fad_3c7f_b113de5a6161
  29632a2a_88f2_f99f_6979_ae26cc6fa806["std::sync"]
  de63b342_bc8b_68a8_063b_cc3f8524fd2c --> 29632a2a_88f2_f99f_6979_ae26cc6fa806
  style de63b342_bc8b_68a8_063b_cc3f8524fd2c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// See: - https://docs.ruby-lang.org/en/3.4/syntax/literals_rdoc.html#label-Percent+Literals
//      - https://docs.ruby-lang.org/en/3.4/syntax/literals_rdoc.html#label-25w+and+-25W-3A+String-Array+Literals
use crate::cursor;
use crate::extractor::bracket_stack;
use crate::extractor::pre_processors::pre_processor::PreProcessor;
use crate::scanner::pre_process_input;
use bstr::ByteVec;
use regex::{Regex, RegexBuilder};
use std::sync;

static TEMPLATE_START_REGEX: sync::LazyLock<Regex> = sync::LazyLock::new(|| {
    RegexBuilder::new(r#"\s*([a-z0-9_-]+)_template\s*<<[-~]?([A-Z]+)$"#)
        .multi_line(true)
        .build()
        .unwrap()
});

static TEMPLATE_END_REGEX: sync::LazyLock<Regex> = sync::LazyLock::new(|| {
    RegexBuilder::new(r#"^\s*([A-Z]+)"#)
        .multi_line(true)
        .build()
        .unwrap()
});

#[derive(Debug, Default)]
pub struct Ruby;

impl PreProcessor for Ruby {
    fn process(&self, content: &[u8]) -> Vec<u8> {
        let len = content.len();
        let mut result = content.to_vec();
        let mut cursor = cursor::Cursor::new(content);
        let mut bracket_stack = bracket_stack::BracketStack::default();

        // Extract embedded template languages
        // https://viewcomponent.org/guide/templates.html#interpolations
        let content_as_str = std::str::from_utf8(content).unwrap();

        let starts = TEMPLATE_START_REGEX
            .captures_iter(content_as_str)
            .collect::<Vec<_>>();
        let ends = TEMPLATE_END_REGEX
            .captures_iter(content_as_str)
            .collect::<Vec<_>>();

        for start in starts.iter() {
            // The language for this block
            let lang = start.get(1).unwrap().as_str();

            // The HEREDOC delimiter
            let delimiter_start = start.get(2).unwrap().as_str();

            // Where the "body" starts for the HEREDOC block
            let body_start = start.get(0).unwrap().end();

            // Look through all of the ends to find a matching language
            for end in ends.iter() {
                // 1. This must appear after the start
                let body_end = end.get(0).unwrap().start();
                if body_end < body_start {
// ... (371 more lines)

Domain

Subdomains

Dependencies

  • bstr::ByteVec
  • crate::cursor
  • crate::extractor::bracket_stack
  • crate::extractor::pre_processors::pre_processor::PreProcessor
  • crate::scanner::pre_process_input
  • regex::
  • std::sync
  • super::Ruby

Frequently Asked Questions

What does ruby.rs do?
ruby.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the OxideEngine domain, PreProcessors subdomain.
What functions are defined in ruby.rs?
ruby.rs defines 7 function(s): RegexBuilder, process, test_embedded_slim_extraction, test_ruby_extraction, test_ruby_pre_processor, test_skip_comments, test_strict_locals.
What does ruby.rs depend on?
ruby.rs imports 8 module(s): bstr::ByteVec, crate::cursor, crate::extractor::bracket_stack, crate::extractor::pre_processors::pre_processor::PreProcessor, crate::scanner::pre_process_input, regex::, std::sync, super::Ruby.
Where is ruby.rs in the architecture?
ruby.rs is located at crates/oxide/src/extractor/pre_processors/ruby.rs (domain: OxideEngine, subdomain: PreProcessors, directory: crates/oxide/src/extractor/pre_processors).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free