Donner 0.5.0
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::DiagnosticRenderer Class Reference

Renders diagnostic messages with source context and caret/tilde indicators, similar to clang/rustc output. More...

#include "donner/base/DiagnosticRenderer.h"

Classes

struct  Options
 Options for rendering diagnostics. More...

Static Public Member Functions

static std::string format (std::string_view source, const ParseDiagnostic &diag, const Options &options)
 Format a single diagnostic against source text.
static std::string format (std::string_view source, const ParseDiagnostic &diag)
static std::string formatAll (std::string_view source, const ParseWarningSink &sink, const Options &options)
 Format all warnings in a sink against source text.
static std::string formatAll (std::string_view source, const ParseWarningSink &sink)

Detailed Description

Renders diagnostic messages with source context and caret/tilde indicators, similar to clang/rustc output.

Example output:

error: Unexpected character
--> test.svg:1:25
|
1 | <path d="M 100 100 h 2!" />
| ^

For multi-character ranges, tildes indicate the span:

warning: Invalid paint server value
--> line 4, col 12
|
4 | <path fill="url(#)"/>
| ^~~~~~

Class Documentation

◆ donner::DiagnosticRenderer::Options

struct donner::DiagnosticRenderer::Options

Options for rendering diagnostics.

Collaboration diagram for donner::DiagnosticRenderer::Options:
[legend]
Class Members
bool colorize = false Enable ANSI color codes in the output.
string_view filename Optional filename for the header (e.g. "test.svg").

Member Function Documentation

◆ format()

std::string donner::DiagnosticRenderer::format ( std::string_view source,
const ParseDiagnostic & diag,
const Options & options )
static

Format a single diagnostic against source text.

Parameters
sourceThe original source text that was parsed.
diagThe diagnostic to render.
optionsRendering options.
Returns
Formatted diagnostic string with source context.

◆ formatAll()

std::string donner::DiagnosticRenderer::formatAll ( std::string_view source,
const ParseWarningSink & sink,
const Options & options )
static

Format all warnings in a sink against source text.

Parameters
sourceThe original source text that was parsed.
sinkWarning sink containing diagnostics to render.
optionsRendering options.
Returns
Formatted diagnostic strings, concatenated.

The documentation for this class was generated from the following files: