{"id":29290932,"url":"https://github.com/roxlabs/coldsnip","last_synced_at":"2026-02-12T07:36:51.810Z","repository":{"id":54492013,"uuid":"389223977","full_name":"roxlabs/coldsnip","owner":"roxlabs","description":"Extract code snippets from source files.","archived":false,"fork":false,"pushed_at":"2024-05-02T13:20:31.000Z","size":1358,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T03:29:37.441Z","etag":null,"topics":["cli","documentation","javascript","snippets","typescript"],"latest_commit_sha":null,"homepage":"https://roxlabs.github.io/coldsnip/","language":"TypeScript","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/roxlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2021-07-25T00:05:26.000Z","updated_at":"2024-03-03T03:54:25.000Z","dependencies_parsed_at":"2023-12-31T04:24:35.532Z","dependency_job_id":"d20159b8-4c87-4514-a701-28a13a5add65","html_url":"https://github.com/roxlabs/coldsnip","commit_stats":null,"previous_names":["roxlabs/coldsnip","roxlabs/snippetfy"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/roxlabs/coldsnip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxlabs%2Fcoldsnip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxlabs%2Fcoldsnip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxlabs%2Fcoldsnip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxlabs%2Fcoldsnip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roxlabs","download_url":"https://codeload.github.com/roxlabs/coldsnip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxlabs%2Fcoldsnip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29361621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cli","documentation","javascript","snippets","typescript"],"created_at":"2025-07-06T07:09:26.330Z","updated_at":"2026-02-12T07:36:51.796Z","avatar_url":"https://github.com/roxlabs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snippets from actual code\n\nColdsnip extracts code snippets from codebases to ensure code embeded on documentation, blog posts and books are always *correct* and *up-to-date*. Stop writing code on Markdown and HTML files and focus on working samples.\n\n![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/roxlabs/coldsnip/build.yml?style=flat-square)\n![Coldsnip on NPM](https://img.shields.io/npm/v/coldsnip?style=flat-square\u0026label=coldsnip)\n![License](https://img.shields.io/github/license/roxlabs/coldsnip?style=flat-square)\n\n\n## About the project\n\nThis project was motivated by past experiences dealing with outdated or faulty code samples in documentation, as both an open source maintainer and consumer. As developers, we often make mistakes when writing code directly on Markdown or HTML files. Coldsnip attempts to avoid those mistakes by pulling code snippets tagged in actual source code.\n\n## Getting Started\n\nColdsnip can be used as a library, as a CLI or through direct integrations with other platforms. Check the [getting started guide](https://roxlabs.github.io/coldsnip/getting-started/) in order to determine the best option for your needs.\n\n\n### Library\n\n\u003c!-- @include:start(\"readme.lib\") --\u003e\n\n```ts\nconst snippets = await extractSnippets([\n  { path: \"src/__tests__\", pattern: \"snippets/twoSnippets.js\" },\n]);\n```\n\n\u003c!-- @include:end --\u003e\n\nThe return type is an map between the key and the snippet information, as detailed bellow:\n\n\u003c!-- @include:start(\"readme.types\") --\u003e\n\n```ts\n/**\n * Represents a code snippet extracted from a source file. The field\n * `permalink` is only present when the source is from a Git repository.\n */\nexport interface Snippet {\n  /** The source language. It matches the file extension. */\n  language: string;\n  /** The file path relative to the working directory. */\n  sourcePath: string;\n  /** The name of the file, derived from `sourcePath`. */\n  filename: string;\n  /** The start line of the snippet. */\n  startLine: number;\n  /** The end line of the snippet. */\n  endLine: number;\n  /** The lines to be highlighted, if any. */\n  highlightedLines: number[];\n  /** The snippet content. Leading spaces are trimmed. */\n  content: string;\n  /** The link to the file on the remote Git repo when available. */\n  permalink?: string;\n  /**\n   * An extra qualifier that can be used to differentiate snippets with the same key\n   * that might come from the same file extension.\n   */\n  qualifier?: string;\n}\n\n/**\n * A map between a `key` and a collection of {@link Snippet} represented by it.\n * Different snippets can be identified by the same key, which is the case in projects\n * with support to multiple languages that want to provide samples of the same API in\n * each supported language.\n */\nexport type Snippets = { [key: string]: Snippet[] };\n```\n\n\u003c!-- @include:end --\u003e\n\n## Roadmap\n\nSee the [open feature requests](https://github.com/roxlabs/coldsnip/labels/enhancement) for a list of proposed features and join the discussion.\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Make sure you read our [Code of Conduct](https://github.com/roxlabs/coldsnip/blob/main/CODE_OF_CONDUCT.md)\n1. Fork the project and clone your fork\n1. Setup the local environment with `npm install`\n1. Create a feature branch (`git checkout -b feature/cool-thing`) or a bugfix branch (`git checkout -b fix/bad-bug`)\n1. Commit the changes (`git commit -m 'feat: some meaningful message'`)\n1. Push to the branch (`git push origin feature/cool-thing`)\n1. Open a Pull Request\n\n\n## License\n\nDistributed under the MIT License. See [LICENSE](https://github.com/roxlabs/coldsnip/blob/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froxlabs%2Fcoldsnip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froxlabs%2Fcoldsnip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froxlabs%2Fcoldsnip/lists"}