Home / Function/ normalizeComment() — supabase Function Reference

normalizeComment() — supabase Function Reference

Architecture documentation for the normalizeComment() function in Reference.typeSpec.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  95c1d699_db8a_dd96_1436_bf88ec23669b["normalizeComment()"]
  ba929624_b9f4_b767_ce03_d9523a729ce8["parseVariable()"]
  ba929624_b9f4_b767_ce03_d9523a729ce8 -->|calls| 95c1d699_db8a_dd96_1436_bf88ec23669b
  0ebbf781_9122_475b_4149_017f2ce9e2eb["parseSignature()"]
  0ebbf781_9122_475b_4149_017f2ce9e2eb -->|calls| 95c1d699_db8a_dd96_1436_bf88ec23669b
  a332c905_4ed4_b6ac_e01a_4884e6eb498f["delegateParsing()"]
  a332c905_4ed4_b6ac_e01a_4884e6eb498f -->|calls| 95c1d699_db8a_dd96_1436_bf88ec23669b
  a2ee5574_56fa_afb2_fc20_7c07cd7a7dba["parseTypeInternals()"]
  a2ee5574_56fa_afb2_fc20_7c07cd7a7dba -->|calls| 95c1d699_db8a_dd96_1436_bf88ec23669b
  36cc7948_235b_7eb1_80a2_01fd4cf266cf["parseInternalProperty()"]
  36cc7948_235b_7eb1_80a2_01fd4cf266cf -->|calls| 95c1d699_db8a_dd96_1436_bf88ec23669b
  style 95c1d699_db8a_dd96_1436_bf88ec23669b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/docs/Reference.typeSpec.ts lines 227–277

function normalizeComment(original: TypedocComment | Comment | undefined): Comment | undefined {
  if (!original) return

  if ('shortText' in original || 'text' in original) {
    // This is the old comment type, just return it
    return original
  }

  const comment: Comment = {}

  if ('summary' in original) {
    comment.shortText = original.summary.map((part) => part.text).join('')
  }

  if ('modifierTags' in original) {
    comment.tags = original.modifierTags.map((tag) => ({ tag: tag.replace(/^@/, ''), text: '' }))
  }

  // Extract @example tags from blockTags
  if ('blockTags' in original && Array.isArray(original.blockTags)) {
    const exampleTags = original.blockTags.filter((tag) => tag.tag === '@example')
    if (exampleTags.length > 0) {
      comment.examples = exampleTags.map((tag, index) => {
        // Use the name if provided, otherwise generate a default name
        const name = tag.name || `Example ${index + 1}`
        // Convert name to kebab-case for id
        const id = name
          .toLowerCase()
          .replace(/[^a-z0-9]+/g, '-')
          .replace(/^-|-$/g, '')
        // Join content to get the full text
        const fullText = tag.content.map((part) => part.text).join('')

        // Check if there's a "Response:" section and split it
        const responseMatch = fullText.match(/\n\s*Response:\s*\n/i)
        let code = fullText
        let response: string | undefined = undefined

        if (responseMatch) {
          const splitIndex = responseMatch.index! + responseMatch[0].length
          code = fullText.substring(0, responseMatch.index!).trim()
          response = fullText.substring(splitIndex).trim()
        }

        return { id, name, code, response }
      })
    }
  }

  return comment
}

Subdomains

Frequently Asked Questions

What does normalizeComment() do?
normalizeComment() is a function in the supabase codebase.
What calls normalizeComment()?
normalizeComment() is called by 5 function(s): delegateParsing, parseInternalProperty, parseSignature, parseTypeInternals, parseVariable.

Analyze Your Own Codebase

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

Try Supermodel Free