gleedoc/parse
Types
Represents a fenced code block extracted from a doc comment.
pub type CodeBlock {
CodeBlock(
language: String,
attributes: List(String),
code: String,
source: extract.DocBlock,
doc_line_offset: Int,
imports: List(String),
)
}
Constructors
-
CodeBlock( language: String, attributes: List(String), code: String, source: extract.DocBlock, doc_line_offset: Int, imports: List(String), )Arguments
- language
-
The language tag, e.g. “gleam” or “”
- attributes
-
Attributes following the language tag, e.g.
["ignore"]for```gleam,ignore. Always lowercased and trimmed. - 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_gleam_blocks(
doc_blocks: List(extract.DocBlock),
) -> List(CodeBlock)
Extract all fenced code blocks from a list of doc blocks.
Only blocks tagged with gleam are kept, and any block with the ignore
attribute (e.g. ```gleam,ignore) is skipped.