{"id":45863930,"url":"https://github.com/heaths/include-file","last_synced_at":"2026-04-03T00:49:22.837Z","repository":{"id":322955068,"uuid":"1091460532","full_name":"heaths/include-file","owner":"heaths","description":"Include sections of files into Rust source code","archived":false,"fork":false,"pushed_at":"2025-11-25T06:40:22.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-28T13:19:19.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heaths.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-07T03:37:18.000Z","updated_at":"2025-11-25T06:40:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/heaths/include-file","commit_stats":null,"previous_names":["heaths/include-file"],"tags_count":7,"template":false,"template_full_name":"heaths/template-rustlang","purl":"pkg:github/heaths/include-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Finclude-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Finclude-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Finclude-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Finclude-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heaths","download_url":"https://codeload.github.com/heaths/include-file/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Finclude-file/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29887570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T05:38:26.446Z","status":"ssl_error","status_checked_at":"2026-02-27T05:38:25.235Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-02-27T07:33:59.666Z","updated_at":"2026-02-27T07:34:00.304Z","avatar_url":"https://github.com/heaths.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Macros for including file content\n\n[![releases](https://img.shields.io/github/v/release/heaths/include-file.svg?logo=github)](https://github.com/heaths/include-file/releases/latest)\n[![docs](https://img.shields.io/docsrs/include-file?logo=rust)](https://docs.rs/include-file)\n[![ci](https://github.com/heaths/include-file/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/heaths/include-file/actions/workflows/ci.yml)\n\nMacros like `include_markdown!(\"README.md\", \"example\")` allow you to include incomplete code from markdown code fences.\nThough Rust doc tests let you hide setup code from being rendered, you cannot do the same when rendering markdown.\nYou can demonstrate just the code you want in markdown while maintaining the benefit of compiling it in tests.\n\n## Examples\n\nThe `include_markdown!()` macro resolves a file path relative to the directory containing the crate `Cargo.toml` manifest file.\n\nConsider a crate `README.md` with the following content:\n\n````markdown\nThe `example()` function returns a model that implements `Debug` so you can easily print it:\n\n```rust ignore example\nlet m = example()?;\nassert_eq!(format!(\"{m:?}\"), r#\"Model { name: \"example\" }\"#);\n```\n````\n\nWe didn't define the `example()` function nor the type of `m`. In Rust doc tests you could do so with lines prefaced with `#` e.g.:\n\n```rust\n/// ```\n/// # #[derive(Debug)] struct Model { name: String }\n/// # fn example() -\u003e Result\u003cModel, Box\u003cdyn std::error::Error\u003e\u003e { Ok(Model { name: \"example\".into() }) }\n/// # fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n/// let m = example()?;\n/// println!(\"{m:#?}\");\n/// # Ok(()) }\n/// ```\nfn f() {}\n```\n\nAll those lines would render in a markdown file. Instead, we can use `include_markdown!(\"README.md\", \"example\")` to include the code example content from `README.md` above in a test to make sure it compiles and even runs.\n\n```rust\n#[derive(Debug)]\nstruct Model {\n    name: String,\n}\n\nfn example() -\u003e Result\u003cModel, Box\u003cdyn std::error::Error\u003e\u003e {\n    Ok(Model {\n        name: \"example\".into(),\n    })\n}\n\n#[test]\nfn test_example() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    include_markdown!(\"README.md\", \"example\");\n    Ok(())\n}\n```\n\nWe also `ignore` the code example since it won't compile with `cargo test --doc`.\n\n## Macros\n\nMacro              | Feature    | Description\n------------------ | ---------- | ---\n`include_asciidoc` | `asciidoc` | Includes Rust snippets from AsciiDoc files, commonly with `.asciidoc`, `.adoc`, or `.asc` extensions.\n`include_markdown` |            | Includes Rust snippets from Markdown files, commonly with `.markdown`, `.mdown`, `.mkdn`, or `.md` extensions.\n`include_org`      | `org`      | Includes Rust snippets from Org files, commonly with `.org` extension.\n`include_textile`  | `textile`  | Includes Rust snippets from Textile files, commonly with `.textile` extension.\n\nAll of these macros also support the following parameters:\n\nParameter  | Description\n---------- | ---\n`path`     | (*Required*) Path relative to the crate root directory.\n`name`     | (*Required*) Name of the code fence to include.\n`scope`    | Include the snippet in braces `{ .. }`.\n`relative` | (*Requires rustc 1.88 or newer*) Path is relative to the source file calling the macro. May show an error in rust-analyzer until [rust-lang/rust-analyzer#15950](https://github.com/rust-lang/rust-analyzer/issues/15950) is fixed.\n\n## License\n\nLicensed under the [MIT](LICENSE.txt) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaths%2Finclude-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheaths%2Finclude-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaths%2Finclude-file/lists"}