All Projects → brendanzab → Codespan

brendanzab / Codespan

Licence: apache-2.0
Beautiful diagnostic reporting for text-based programming languages.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Codespan

Bugsnag Node
[DEPRECATED] Please upgrade to our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 48 (-89.21%)
Mutual labels:  error-reporting, diagnostics
Wild Cherry
👸🌷👹 A fairy-tale inspired theme, with tasteful use of emojis
Stars: ✭ 443 (-0.45%)
Mutual labels:  terminal
Yaspin
A lightweight terminal spinner for Python with safe pipes and redirects 🎁
Stars: ✭ 413 (-7.19%)
Mutual labels:  terminal
Figures
Unicode symbols with Windows CMD fallbacks
Stars: ✭ 438 (-1.57%)
Mutual labels:  terminal
Vtm
A text-based desktop environment
Stars: ✭ 411 (-7.64%)
Mutual labels:  terminal
Terminology
The best terminal emulator based on the Enlightenment Foundation Libraries
Stars: ✭ 440 (-1.12%)
Mutual labels:  terminal
Python Coloredlogs
Colored terminal output for Python's logging module
Stars: ✭ 408 (-8.31%)
Mutual labels:  terminal
Hn Cli
📰 CLI to browse Hacker News
Stars: ✭ 448 (+0.67%)
Mutual labels:  terminal
Pulsemixer
CLI and curses mixer for PulseAudio
Stars: ✭ 441 (-0.9%)
Mutual labels:  terminal
Tab Rs
The intuitive, config-driven terminal multiplexer designed for software & systems engineers
Stars: ✭ 431 (-3.15%)
Mutual labels:  terminal
Funky
Funky takes shell functions to the next level by making them easier to define, more flexible, and more interactive.
Stars: ✭ 434 (-2.47%)
Mutual labels:  terminal
Imgcat
a tool to output images as RGB ANSI graphics on the terminal
Stars: ✭ 425 (-4.49%)
Mutual labels:  terminal
Ftxui
💻 C++ Functional Terminal User Interface. ❤️
Stars: ✭ 433 (-2.7%)
Mutual labels:  terminal
Nnn.vim
File manager for vim/neovim powered by n³
Stars: ✭ 414 (-6.97%)
Mutual labels:  terminal
Typewritten
A minimal, lightweight, informative zsh prompt theme
Stars: ✭ 442 (-0.67%)
Mutual labels:  terminal
Terminal On Fb Messenger
Allows user to take full control of the terminal of their computer through Facebook's messaging service.
Stars: ✭ 410 (-7.87%)
Mutual labels:  terminal
Dstask
Single binary terminal-based TODO manager with git-based sync + markdown notes per task
Stars: ✭ 431 (-3.15%)
Mutual labels:  terminal
Globe
Interactive ASCII globe generator
Stars: ✭ 440 (-1.12%)
Mutual labels:  terminal
Aidlearning Framework
🔥🔥AidLearning is a powerful mobile development platform, AidLearning builds a linux env supporting GUI, deep learning and visual IDE on Android...Now Aid supports OpenCL (GPU+NPU) for high performance acceleration...Linux on Android or HarmonyOS
Stars: ✭ 4,537 (+919.55%)
Mutual labels:  terminal
Xi Term
A terminal frontend for Xi
Stars: ✭ 446 (+0.22%)
Mutual labels:  terminal

codespan-reporting

Continuous integration Crates.io Docs.rs Matrix

Beautiful diagnostic reporting for text-based programming languages.

Example preview

Languages like Rust and Elm already support beautiful error reporting output, but it can take a significant amount work to implement this for new programming languages! The codespan-reporting crate aims to make beautiful error diagnostics easy and relatively painless for everyone!

We're still working on improving the crate to help it support broader use cases, and improving the quality of the diagnostic rendering, so stay tuned for updates and please give us feedback if you have it. Contributions are also very welcome!

Example

use codespan_reporting::diagnostic::{Diagnostic, Label};
use codespan_reporting::files::SimpleFiles;
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};

// `files::SimpleFile` and `files::SimpleFiles` help you get up and running with
// `codespan-reporting` quickly! More complicated use cases can be supported
// by creating custom implementations of the `files::Files` trait.

let mut files = SimpleFiles::new();

let file_id = files.add(
    "FizzBuzz.fun",
    unindent::unindent(
        r#"
            module FizzBuzz where

            fizz₁ : Nat → String
            fizz₁ num = case (mod num 5) (mod num 3) of
                0 0 => "FizzBuzz"
                0 _ => "Fizz"
                _ 0 => "Buzz"
                _ _ => num

            fizz₂ : Nat → String
            fizz₂ num =
                case (mod num 5) (mod num 3) of
                    0 0 => "FizzBuzz"
                    0 _ => "Fizz"
                    _ 0 => "Buzz"
                    _ _ => num
        "#,
    ),
);

// We normally recommend creating a custom diagnostic data type for your
// application, and then converting that to `codespan-reporting`'s diagnostic
// type, but for the sake of this example we construct it directly.

let diagnostic = Diagnostic::error()
    .with_message("`case` clauses have incompatible types")
    .with_code("E0308")
    .with_labels(vec![
        Label::primary(file_id, 328..331).with_message("expected `String`, found `Nat`"),
        Label::secondary(file_id, 211..331).with_message("`case` clauses have incompatible types"),
        Label::secondary(file_id, 258..268).with_message("this is found to be of type `String`"),
        Label::secondary(file_id, 284..290).with_message("this is found to be of type `String`"),
        Label::secondary(file_id, 306..312).with_message("this is found to be of type `String`"),
        Label::secondary(file_id, 186..192).with_message("expected type `String` found here"),
    ])
    .with_notes(vec![unindent::unindent(
        "
            expected type `String`
                found type `Nat`
        ",
    )]);

// We now set up the writer and configuration, and then finally render the
// diagnostic to standard error.

let writer = StandardStream::stderr(ColorChoice::Always);
let config = codespan_reporting::term::Config::default();

term::emit(&mut writer.lock(), &config, &files, &diagnostic)?;

Running the CLI example

To get an idea of what the colored CLI output looks like, clone the repository and run the following shell command:

cargo run --example term

More examples of using codespan-reporting can be found in the examples directory.

Projects using codespan-reporting

codespan-reporting is currently used in the following projects:

Alternatives to codespan-reporting

There are a number of alternatives to codespan-reporting, including:

These are all ultimately inspired by rustc's excellent error reporting infrastructure.

Contributing

A guide to contributing to codespan-reporting can be found here.

Code of Conduct

Please note that this project is released with a Code of Conduct. By participating in this project you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].