gleedoc/parse

Types

Represents a fenced code block extracted from a doc comment.

pub type CodeBlock {
  CodeBlock(
    language: String,
    code: String,
    source: extract.DocBlock,
    doc_line_offset: Int,
    imports: List(String),
  )
}

Constructors

  • CodeBlock(
      language: String,
      code: String,
      source: extract.DocBlock,
      doc_line_offset: Int,
      imports: List(String),
    )

    Arguments

    language

    The language tag, e.g. “gleam” or “”

    code

    The raw code inside the fence (without import statements)

    source

    The source doc block this came from

    doc_line_offset

    The 1-based line number within the doc comment where the code block starts

    imports

    Import statements extracted from the code block

Values

pub fn extract_code_blocks(
  doc_blocks: List(extract.DocBlock),
) -> List(CodeBlock)

Extract all fenced code blocks from a list of doc blocks.

pub fn gleam_blocks(blocks: List(CodeBlock)) -> List(CodeBlock)

Filter code blocks to only those tagged as gleam.

Search Document