{"id":15713796,"url":"https://github.com/skippi/docspec","last_synced_at":"2025-10-16T19:50:42.261Z","repository":{"id":134559433,"uuid":"135206035","full_name":"skippi/docspec","owner":"skippi","description":"A crystal library for automatically testing documentation examples.","archived":false,"fork":false,"pushed_at":"2018-06-02T04:41:14.000Z","size":42,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T04:41:23.616Z","etag":null,"topics":["crystal","crystal-lang","crystal-language","crystal-shard","doctest","documentation","testing"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/skippi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-28T20:26:07.000Z","updated_at":"2023-07-06T08:00:23.000Z","dependencies_parsed_at":"2023-06-18T10:52:11.428Z","dependency_job_id":null,"html_url":"https://github.com/skippi/docspec","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skippi%2Fdocspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skippi%2Fdocspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skippi%2Fdocspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skippi%2Fdocspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skippi","download_url":"https://codeload.github.com/skippi/docspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253838087,"owners_count":21972091,"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":["crystal","crystal-lang","crystal-language","crystal-shard","doctest","documentation","testing"],"created_at":"2024-10-03T21:33:31.426Z","updated_at":"2025-10-16T19:50:37.227Z","avatar_url":"https://github.com/skippi.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docspec\n\n[![Build Status](https://travis-ci.com/skippi/docspec.svg?branch=master)](https://travis-ci.com/skippi/docspec)\n[![Read the Docs (version)](https://img.shields.io/readthedocs/pip/stable.svg)](https://skippi.github.io/docspec/)\n\nA crystal library for automatically testing documentation examples.\n\nDocspec is crystal's equivalent of a doctest library.\n\n## Use Cases\n\n* Docspec encourages documentation by creating tests from it.\n* Docspec encourages testing by reducing boilerplate code for test cases.\n* Docspec encourages fast development by reducing boilerplate code for test\n  cases.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  docspec:\n    github: skippi/docspec\n```\n\n## Usage\n\nDocspec parses source files for any commented codeblocks with code in them. For\neach codeblock line with a prefix of `\u003e\u003e`, it executes the line and stores the\nresult. If the line also had an expression appended with `# =\u003e`, then docspec\nwill test that the result equals the appended expression.\n\nAlternatively, you can use the `[](@doctest)` annotation instead of `\u003e\u003e` to\nmark entire codeblocks for doctesting.\n\nIn this example, we will fully doctest `Foo.bar` and `Foo.baz`, while ignoring doctesting for\n`Foo.add`. Note the usage of `\u003e\u003e` and `[](@doctest)`:\n\n```crystal\n# src/foo.cr\n\nmodule Foo\n  # Returns \"hello world\".\n  #\n  # ```\n  # \u003e\u003e Foo.bar # =\u003e \"hello world\"\n  #\n  # \u003e\u003e name = \"say #{Foo.bar}\"\n  # \u003e\u003e name # =\u003e \"say hello world\"\n  # ```\n  def self.bar\n    \"hello world\"\n  end\n\n  # Subtracts two numbers.\n  #\n  # [](@doctest)\n  # ```\n  # Foo.baz(4, 2) # =\u003e 2\n  # Foo.baz(-8, -4) # =\u003e -4\n  # ```\n  def self.baz(a, b)\n    a - b\n  end\n\n  # Adds two numbers.\n  #\n  # ```\n  # Foo.add(1, 3) # =\u003e 4\n  # Foo.add(-2, -4) # =\u003e -6\n  # ```\n  def self.add(a, b)\n    a + b\n  end\nend\n```\n\nRequire docspec and doctest the source file using a relative path:\n\n```crystal\n# spec/foo_spec.cr\n\nrequire \"docspec\"\n\nDocspec.doctest(\"../src/foo.cr\")\n```\n\nLastly, run your tests in your project's root directory.\n\n```bash\ncrystal spec\n```\n\n## Documentation\n\n* [Official docs](https://skippi.github.io/docspec/)\n\n## Contributing\n\n1. Fork it ( [https://github.com/skippi/docspec/fork](https://github.com/skippi/docspec/fork) )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n* [skippi](https://github.com/skippi)  - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskippi%2Fdocspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskippi%2Fdocspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskippi%2Fdocspec/lists"}