firecrown.fctools.code_block_checker

Check Python code blocks in Quarto (.qmd) files for syntax errors.

Attributes

app

Functions

check_qmd_file(file_path)

Parse a .qmd file, extract Python code blocks, and check their syntax.

extract_code_blocks(content, code_blocks)

Extract Python code blocks from Quarto markdown content.

main([directory, quiet])

Check Python code blocks in Quarto (.qmd) files for syntax errors.

Module Contents

firecrown.fctools.code_block_checker.app
firecrown.fctools.code_block_checker.check_qmd_file(file_path)[source]

Parse a .qmd file, extract Python code blocks, and check their syntax.

Parameters:

file_path (pathlib.Path) – Path to the Quarto (.qmd) file to check

Returns:

List of error messages for code blocks with syntax errors

Return type:

list[str]

firecrown.fctools.code_block_checker.extract_code_blocks(content, code_blocks)[source]

Extract Python code blocks from Quarto markdown content.

Parses content line by line to find code blocks delimited by {python} or {.python} (display-only), including blocks with execution options like {python, echo=false}. Appends the code from each Python block to the code_blocks list.

Parameters:
  • content (str) – The Quarto markdown content to parse

  • code_blocks (list[str]) – List to append extracted code blocks to (modified in-place)

Return type:

None

firecrown.fctools.code_block_checker.main(directory=typer.Argument(..., help='The directory containing .qmd files to check', exists=True), quiet=typer.Option(False, '--quiet', '-q', help='Only report errors, suppress success messages'))[source]

Check Python code blocks in Quarto (.qmd) files for syntax errors.

Scans all .qmd files in the specified directory, extracts Python code blocks, and checks them for syntax errors using Python’s ast.parse().

Usage:

code_block_checker.py tutorial/

Exit codes:

0: No errors found 1: Syntax errors found or directory invalid

Parameters:
  • directory (pathlib.Path)

  • quiet (bool)

Return type:

None