Home / Function/ showRemark() — supabase Function Reference

showRemark() — supabase Function Reference

Architecture documentation for the showRemark() function in Show.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  89322a95_cf3c_42c1_a11f_8d5fe57d59e7["showRemark()"]
  67a945e1_7550_1b68_2ba7_665ba0ff6278["preprocessMdxWithDefaults()"]
  67a945e1_7550_1b68_2ba7_665ba0ff6278 -->|calls| 89322a95_cf3c_42c1_a11f_8d5fe57d59e7
  790ab825_fd72_cafc_9ee2_d8f5b37c7cf2["getAttributeValue()"]
  89322a95_cf3c_42c1_a11f_8d5fe57d59e7 -->|calls| 790ab825_fd72_cafc_9ee2_d8f5b37c7cf2
  style 89322a95_cf3c_42c1_a11f_8d5fe57d59e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/directives/Show.ts lines 28–83

export function showRemark() {
  return function transform(tree: Root) {
    const nodesToProcess = [] as Array<{
      node: MdxJsxFlowElement
      parent: Parent
      shouldShow: boolean
    }>

    // Collect all $Show nodes and determine their visibility
    visitParents(tree, 'mdxJsxFlowElement', (node: MdxJsxFlowElement, ancestors) => {
      if (node.name !== '$Show') return

      const parent = ancestors[ancestors.length - 1]
      const rawFeatureName = getAttributeValue(node, 'if')

      if (typeof rawFeatureName !== 'string') {
        throw new Error('$Show directive requires a string value for the "if" attribute')
      }

      const trimmedFeatureName = rawFeatureName.trim()
      const isNegated = trimmedFeatureName.startsWith('!')
      const normalizedFeatureName = (
        isNegated ? trimmedFeatureName.slice(1) : trimmedFeatureName
      ).trim()

      if (!normalizedFeatureName) {
        throw new Error('$Show directive requires a non-empty feature name for the "if" attribute')
      }

      const isEnabled = isFeatureEnabled(normalizedFeatureName as Feature)
      const shouldShow = isNegated ? !isEnabled : isEnabled

      nodesToProcess.push({
        node,
        parent,
        shouldShow,
      })
    })

    // Process nodes in reverse order to avoid index shifting issues
    for (let i = nodesToProcess.length - 1; i >= 0; i--) {
      const { node, parent, shouldShow } = nodesToProcess[i]
      const nodeIndex = parent.children.indexOf(node)

      if (shouldShow) {
        // Feature is enabled: remove the $Show wrapper but keep children
        parent.children.splice(nodeIndex, 1, ...node.children)
      } else {
        // Feature is disabled: remove the entire $Show element and its children
        parent.children.splice(nodeIndex, 1)
      }
    }

    return tree
  }
}

Subdomains

Frequently Asked Questions

What does showRemark() do?
showRemark() is a function in the supabase codebase.
What does showRemark() call?
showRemark() calls 1 function(s): getAttributeValue.
What calls showRemark()?
showRemark() is called by 1 function(s): preprocessMdxWithDefaults.

Analyze Your Own Codebase

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

Try Supermodel Free