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
  5bda8ff2_4761_4c27_d724_a4e36f403452["analyze()"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd["translation-map.test.ts"]
  5bda8ff2_4761_4c27_d724_a4e36f403452 -->|defined in| 83f56732_94d8_aae2_694c_e38d0ec61bfd
  b8a15b09_3dfb_7181_b1f8_368422e178e4["parse()"]
  5bda8ff2_4761_4c27_d724_a4e36f403452 -->|calls| b8a15b09_3dfb_7181_b1f8_368422e178e4
  2da63033_d079_7b37_5cfb_3877674a70b9["toCss()"]
  5bda8ff2_4761_4c27_d724_a4e36f403452 -->|calls| 2da63033_d079_7b37_5cfb_3877674a70b9
  b8973deb_e07f_d1e1_e7f9_7a680d9120d4["createTranslationMap()"]
  5bda8ff2_4761_4c27_d724_a4e36f403452 -->|calls| b8973deb_e07f_d1e1_e7f9_7a680d9120d4
  style 5bda8ff2_4761_4c27_d724_a4e36f403452 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, defined in packages/tailwindcss/src/source-maps/translation-map.test.ts.
Where is analyze() defined?
analyze() is defined in packages/tailwindcss/src/source-maps/translation-map.test.ts at line 7.
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