{"id":13484794,"url":"https://github.com/brendanzab/codespan","last_synced_at":"2025-05-12T15:32:59.574Z","repository":{"id":38429818,"uuid":"122145662","full_name":"brendanzab/codespan","owner":"brendanzab","description":"Beautiful diagnostic reporting for text-based programming languages.","archived":false,"fork":false,"pushed_at":"2025-04-14T19:30:32.000Z","size":1027,"stargazers_count":1176,"open_issues_count":45,"forks_count":64,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-03T03:09:57.217Z","etag":null,"topics":["diagnostics","error-reporting","programming-languages","rust","source-code","terminal"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brendanzab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-02-20T02:11:13.000Z","updated_at":"2025-04-30T11:01:23.000Z","dependencies_parsed_at":"2024-02-11T13:23:33.001Z","dependency_job_id":"ef357db5-3dad-4f43-b03c-1de62238be43","html_url":"https://github.com/brendanzab/codespan","commit_stats":{"total_commits":487,"total_committers":33,"mean_commits":"14.757575757575758","dds":"0.39835728952772076","last_synced_commit":"57c223b08932ba8a4644f2dcc1571c87844b7c68"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendanzab%2Fcodespan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendanzab%2Fcodespan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendanzab%2Fcodespan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendanzab%2Fcodespan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brendanzab","download_url":"https://codeload.github.com/brendanzab/codespan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253765897,"owners_count":21960815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagnostics","error-reporting","programming-languages","rust","source-code","terminal"],"created_at":"2024-07-31T17:01:33.841Z","updated_at":"2025-05-12T15:32:59.554Z","avatar_url":"https://github.com/brendanzab.png","language":"Rust","readme":"# codespan-reporting\n\n[![Continuous integration][actions-badge]][actions-url]\n[![Crates.io][crate-badge]][crate-url]\n[![Docs.rs][docs-badge]][docs-url]\n[![Matrix][matrix-badge]][matrix-lobby]\n\n[actions-badge]: https://img.shields.io/github/actions/workflow/status/brendanzab/codespan/ci.yml?branch=master\n[actions-url]: https://github.com/brendanzab/codespan/actions\n[crate-url]: https://crates.io/crates/codespan-reporting\n[crate-badge]: https://img.shields.io/crates/v/codespan-reporting.svg\n[docs-url]: https://docs.rs/codespan-reporting\n[docs-badge]: https://docs.rs/codespan-reporting/badge.svg\n[matrix-badge]: https://img.shields.io/badge/matrix-%23codespan%3Amatrix.org-blue.svg\n[matrix-lobby]: https://app.element.io/#/room/#codespan:matrix.org\n\nBeautiful diagnostic reporting for text-based programming languages.\n\n![Example preview](./codespan-reporting/assets/readme_preview.svg?sanitize=true)\n\nLanguages like Rust and Elm already support beautiful error reporting output,\nbut it can take a significant amount work to implement this for new programming\nlanguages! The `codespan-reporting` crate aims to make beautiful error\ndiagnostics easy and relatively painless for everyone!\n\nWe're still working on improving the crate to help it support broader use cases,\nand improving the quality of the diagnostic rendering, so stay tuned for\nupdates and please give us feedback if you have it. Contributions are also very\nwelcome!\n\n## Example\n\n```rust\nuse codespan_reporting::diagnostic::{Diagnostic, Label};\nuse codespan_reporting::files::SimpleFiles;\nuse codespan_reporting::term::termcolor::{ColorChoice, StandardStream};\n\n// `files::SimpleFile` and `files::SimpleFiles` help you get up and running with\n// `codespan-reporting` quickly! More complicated use cases can be supported\n// by creating custom implementations of the `files::Files` trait.\n\nlet mut files = SimpleFiles::new();\n\nlet file_id = files.add(\n    \"FizzBuzz.fun\",\n    unindent::unindent(\n        r#\"\n            module FizzBuzz where\n\n            fizz₁ : Nat → String\n            fizz₁ num = case (mod num 5) (mod num 3) of\n                0 0 =\u003e \"FizzBuzz\"\n                0 _ =\u003e \"Fizz\"\n                _ 0 =\u003e \"Buzz\"\n                _ _ =\u003e num\n\n            fizz₂ : Nat → String\n            fizz₂ num =\n                case (mod num 5) (mod num 3) of\n                    0 0 =\u003e \"FizzBuzz\"\n                    0 _ =\u003e \"Fizz\"\n                    _ 0 =\u003e \"Buzz\"\n                    _ _ =\u003e num\n        \"#,\n    ),\n);\n\n// We normally recommend creating a custom diagnostic data type for your\n// application, and then converting that to `codespan-reporting`'s diagnostic\n// type, but for the sake of this example we construct it directly.\n\nlet diagnostic = Diagnostic::error()\n    .with_message(\"`case` clauses have incompatible types\")\n    .with_code(\"E0308\")\n    .with_labels(vec![\n        Label::primary(file_id, 328..331).with_message(\"expected `String`, found `Nat`\"),\n        Label::secondary(file_id, 211..331).with_message(\"`case` clauses have incompatible types\"),\n        Label::secondary(file_id, 258..268).with_message(\"this is found to be of type `String`\"),\n        Label::secondary(file_id, 284..290).with_message(\"this is found to be of type `String`\"),\n        Label::secondary(file_id, 306..312).with_message(\"this is found to be of type `String`\"),\n        Label::secondary(file_id, 186..192).with_message(\"expected type `String` found here\"),\n    ])\n    .with_notes(vec![unindent::unindent(\n        \"\n            expected type `String`\n                found type `Nat`\n        \",\n    )]);\n\n// We now set up the writer and configuration, and then finally render the\n// diagnostic to standard error.\n\nlet writer = StandardStream::stderr(ColorChoice::Always);\nlet config = codespan_reporting::term::Config::default();\n\nterm::emit(\u0026mut writer.lock(), \u0026config, \u0026files, \u0026diagnostic)?;\n```\n\n## Running the CLI example\n\nTo get an idea of what the colored CLI output looks like,\nclone the [repository](https://github.com/brendanzab/codespan)\nand run the following shell command:\n\n```sh\ncargo run --example term\n```\n\nMore examples of using `codespan-reporting` can be found in the\n[examples directory](./codespan-reporting/examples).\n\n## Projects using codespan-reporting\n\n`codespan-reporting` is currently used in the following projects:\n\n- [cargo-deny](https://github.com/EmbarkStudios/cargo-deny)\n- [cargo-about](https://github.com/EmbarkStudios/cargo-about)\n- [CXX](https://github.com/dtolnay/cxx)\n- [full_moon](https://github.com/Kampfkarren/full-moon)\n- [Gleam](https://github.com/gleam-lang/gleam)\n- [Gluon](https://github.com/gluon-lang/gluon)\n- [MDBook LinkCheck](https://github.com/Michael-F-Bryan/mdbook-linkcheck)\n- [mos](https://github.com/datatrash/mos)\n- [Pikelet](https://github.com/pikelet-lang/pikelet)\n- [Naga](https://github.com/gfx-rs/wgpu/tree/trunk/naga)\n- [Spade](https://gitlab.com/spade-lang/spade)\n \n ... [any many more](https://crates.io/crates/codespan-reporting/reverse_dependencies)\n\n## Alternatives to codespan-reporting\n\nThere are a number of alternatives to `codespan-reporting`, including:\n\n- [annotate-snippets][annotate-snippets]\n- [codemap][codemap]\n- [language-reporting][language-reporting] (a fork of codespan)\n\nThese are all ultimately inspired by rustc's excellent [error reporting infrastructure][librustc_errors].\n\n[annotate-snippets]: https://crates.io/crates/annotate-snippets\n[codemap]: https://crates.io/crates/codemap\n[language-reporting]: https://crates.io/crates/language-reporting\n[librustc_errors]: https://github.com/rust-lang/rust/tree/master/compiler/rustc_errors/src\n\n## Contributing\n\nA guide to contributing to codespan-reporting [can be found here](/CONTRIBUTING.md).\n\n## Code of Conduct\n\nPlease note that this project is released with a [Code of Conduct](./CODE_OF_CONDUCT.md).\nBy participating in this project you agree to abide by its terms.\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrendanzab%2Fcodespan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrendanzab%2Fcodespan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrendanzab%2Fcodespan/lists"}