Home / Function/ analyze() — tailwindcss Function Reference

analyze() — tailwindcss Function Reference

Architecture documentation for the analyze() function in translation-map.test.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  5898a47f_729b_b30c_bf7b_865876b2750a["analyze()"]
  253418a1_4f08_cf0e_5b8e_c6392b9959eb["parse()"]
  5898a47f_729b_b30c_bf7b_865876b2750a -->|calls| 253418a1_4f08_cf0e_5b8e_c6392b9959eb
  e7a34553_0273_6202_4792_07409e33d8f0["toCss()"]
  5898a47f_729b_b30c_bf7b_865876b2750a -->|calls| e7a34553_0273_6202_4792_07409e33d8f0
  bb31abbc_7fee_b057_cbe4_7ee1725378c5["createTranslationMap()"]
  5898a47f_729b_b30c_bf7b_865876b2750a -->|calls| bb31abbc_7fee_b057_cbe4_7ee1725378c5
  style 5898a47f_729b_b30c_bf7b_865876b2750a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/source-maps/translation-map.test.ts lines 7–34

async function analyze(input: string) {
  let ast = CSS.parse(input, { from: 'input.css' })
  let css = toCss(ast, true)
  let translate = createTranslationMap({
    original: input,
    generated: css,
  })

  function format(node: AstNode) {
    let lines: string[] = []

    for (let [oStart, oEnd, gStart, gEnd] of translate(node)) {
      let src = `${oStart.line}:${oStart.column}-${oEnd.line}:${oEnd.column}`

      let dst = '(none)'

      if (gStart && gEnd) {
        dst = `${gStart.line}:${gStart.column}-${gEnd.line}:${gEnd.column}`
      }

      lines.push(`${dst} <- ${src}`)
    }

    return lines
  }

  return { ast, css, format }
}

Domain

Subdomains

Frequently Asked Questions

What does analyze() do?
analyze() is a function in the tailwindcss codebase.
What does analyze() call?
analyze() calls 3 function(s): createTranslationMap, parse, toCss.

Analyze Your Own Codebase

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

Try Supermodel Free