{"id":16826780,"url":"https://github.com/jdkato/blocktest","last_synced_at":"2025-04-11T03:42:34.384Z","repository":{"id":57518899,"uuid":"122371084","full_name":"jdkato/blocktest","owner":"jdkato","description":":white_check_mark: A command-line tool for managing code snippets in documentation.","archived":false,"fork":false,"pushed_at":"2018-10-02T23:42:24.000Z","size":38,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T02:47:00.034Z","etag":null,"topics":["automated-testing","continuous-integration","documentation"],"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/jdkato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-21T17:44:56.000Z","updated_at":"2021-11-18T00:04:16.000Z","dependencies_parsed_at":"2022-09-26T18:00:45.524Z","dependency_job_id":null,"html_url":"https://github.com/jdkato/blocktest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdkato%2Fblocktest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdkato%2Fblocktest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdkato%2Fblocktest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdkato%2Fblocktest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdkato","download_url":"https://codeload.github.com/jdkato/blocktest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339287,"owners_count":21087213,"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":["automated-testing","continuous-integration","documentation"],"created_at":"2024-10-13T11:18:24.427Z","updated_at":"2025-04-11T03:42:34.345Z","avatar_url":"https://github.com/jdkato.png","language":"Rust","readme":"# blocktest [![Build Status](https://travis-ci.org/errata-ai/blocktest.svg?branch=master)](https://travis-ci.org/errata-ai/blocktest) [![Crates.io](https://img.shields.io/crates/v/blocktest.svg)](https://crates.io/crates/blocktest)\n\n`blocktest` is a \"preprocessor\" for markup (e.g., Markdown or reStructuredText) code blocks. It allows you to keep your code and prose separate without duplicating work. The idea is simple: `blocktest` extracts your code examples from within a larger testing context and adds them to your markup at user-specified locations.\n\nFor instance, let's say that you're writing this [section of the spaCy documentation](https://spacy.io/api/language#call). In this example, you want to include the following Python code snippet in your explanation:\n\n```python\ndoc = nlp(u'An example sentence. Another sentence.')\nassert (doc[0].text, doc[0].head.tag_) == ('An', 'NN')\n```\n\nWith `blocktest`, you need two files:\n\n1. A Python test file with the snippet inside of its test-related boilerplate:\n\n    ```python\n    # test_language.py\n    import spacy\n\n    nlp = spacy.load('en')\n\n    def test_example():\n        doc = nlp(u'An example sentence. Another sentence.')  # example1 begin\n        assert (doc[0].text, doc[0].head.tag_) == ('An', 'NN')  # example1 end\n     ```\n 2. A markup file which specifies where to find the snippet:\n \n     ````\n     \u003c!-- example.md --\u003e\n\n     ```python\n     {{\u003c id=\"example1\" src=\"test_language.py\" \u003e}}\n     ```\n     ````\n     \n  `blocktest` will scan `example.md` looking for *block definitions*, which specify a unique ID and a source file for each snippet. It will then extract the snippet (as indicated by the `\u003cid\u003e begin` / `\u003cid\u003e end` comments) from the source file and substitute it back into your markup. This allows you to write a thorough test suite for your code examples without having to maintain multiple copies of the same snippet.\n\n## Getting Started\n\n###### Installation\n\n```shell\n$ cargo install blocktest\n```\n\n###### Usage\n\n```\n$ blocktest input_dir .md output_dir\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdkato%2Fblocktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdkato%2Fblocktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdkato%2Fblocktest/lists"}