|
Pretty Diagnostics
Create your own pretty diagnostics
|
A plain-text renderer for diagnostic Reports.
More...
#include <renderer.hpp>
Public Member Functions | |
| TextRenderer (const Report &report) | |
Initializes the renderer with a reference layout taken from a Report More... | |
| void | render (const Severity &severity, std::ostream &stream) override |
| Renders just the severity label to the stream. More... | |
| void | render (const Report &report, std::ostream &stream) override |
| Renders an entire report to the stream. More... | |
| void | render (const FileGroup &file_group, std::ostream &stream) override |
| Renders a single file group to the stream. More... | |
| void | render (const LineGroup &line_group, std::ostream &stream) override |
| Renders a single line group to the stream. More... | |
Public Member Functions inherited from pretty_diagnostics::IReporterRenderer | |
| virtual | ~IReporterRenderer ()=default |
| virtual void | render (const Severity &severity, std::ostream &stream)=0 |
| Renders just the severity label (e.g. "error", "warning") More... | |
| virtual void | render (const Report &report, std::ostream &stream)=0 |
| Renders an entire report. More... | |
| virtual void | render (const FileGroup &file_group, std::ostream &stream)=0 |
| Renders a single file group. More... | |
| virtual void | render (const LineGroup &line_group, std::ostream &stream)=0 |
| Renders a single line group. More... | |
Static Public Member Functions | |
| static size_t | render (const Label &label, std::ostream &stream, const std::vector< std::string > &text_lines, size_t text_index, bool active_render, size_t column_start=0) |
| Renders an individual label, optionally in active mode to draw the actual span arrows. More... | |
| static size_t | widest_line_number (const Report::MappedFileGroups &groups, size_t padding) |
| Computes the width of the widest line number across groups, plus padding. More... | |
| static std::vector< std::string > | wrap_text (const std::string &text, size_t max_width) |
Wraps the given text to lines no longer than max_width characters. More... | |
A plain-text renderer for diagnostic Reports.
Produces a clean, human-friendly multi-line output similar to compilers
|
explicit |
|
overridevirtual |
Renders a single file group to the stream.
| file_group | File group to render |
| stream | Output stream to write to |
Implements pretty_diagnostics::IReporterRenderer.
|
static |
Renders an individual label, optionally in active mode to draw the actual span arrows.
| label | Label to render |
| stream | Output stream to write to |
| text_lines | Pre-wrapped lines of the label text |
| text_index | Index into text_lines to start rendering from |
| active_render | Whether to draw guides/arrows for the label |
| column_start | Optional starting column for rendering (0-based) |
|
overridevirtual |
Renders a single line group to the stream.
| line_group | Line group to render |
| stream | Output stream to write to |
Implements pretty_diagnostics::IReporterRenderer.
|
overridevirtual |
Renders an entire report to the stream.
| report | Report to be rendered |
| stream | Output stream to write to |
Implements pretty_diagnostics::IReporterRenderer.
|
overridevirtual |
Renders just the severity label to the stream.
| severity | Severity to render (e.g., error, warning) |
| stream | Output stream to write to |
Implements pretty_diagnostics::IReporterRenderer.
|
static |
Computes the width of the widest line number across groups, plus padding.
| groups | Mapped file groups used for rendering |
| padding | Extra characters to add to the computed width |
|
static |
Wraps the given text to lines no longer than max_width characters.
| text | Text to wrap |
| max_width | Maximum line width |