{"id":21391349,"url":"https://github.com/ottomatica/docable","last_synced_at":"2025-07-13T17:30:52.978Z","repository":{"id":37997562,"uuid":"188052576","full_name":"ottomatica/docable","owner":"ottomatica","description":":gear::ledger: CI for documentation. Testing if documentation is runable.","archived":false,"fork":false,"pushed_at":"2023-03-04T03:46:51.000Z","size":2019,"stargazers_count":11,"open_issues_count":11,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-07T15:23:13.977Z","etag":null,"topics":["ci","documentation","testing","tutorial"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ottomatica.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":"2019-05-22T14:12:24.000Z","updated_at":"2024-09-24T17:39:23.000Z","dependencies_parsed_at":"2023-02-15T04:46:33.379Z","dependency_job_id":null,"html_url":"https://github.com/ottomatica/docable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ottomatica/docable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fdocable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fdocable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fdocable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fdocable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ottomatica","download_url":"https://codeload.github.com/ottomatica/docable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fdocable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265178377,"owners_count":23723250,"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":["ci","documentation","testing","tutorial"],"created_at":"2024-11-22T13:26:05.570Z","updated_at":"2025-07-13T17:30:52.661Z","avatar_url":"https://github.com/ottomatica.png","language":"JavaScript","readme":"# docable\n\n_CI for documentation_: Testing if documentation is runable.\n\nSuppose you wanted to test the following tutorial (inspired from [benmoral](https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6).)\n\n## Example Tutorial\n\nLet’s create a small server using PHP. I can see your eyebrows rising, but it works surprisingly well. We’ll listen to UDP port 10000, and return any message received with a ROT13 transformation:\n\n```php\n\u003c?php\n$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);\nsocket_bind($sock, '0.0.0.0', 10000);\nfor (;;) {\n    socket_recvfrom($sock, $message, 1024, 0, $ip, $port);\n    $reply = str_rot13($message);\n    socket_sendto($sock, $reply, strlen($reply), 0, $ip, $port);\n}\n```\n\nLet’s start it:\n\n```\n$ php server.php\n```\n\nAnd test it in another terminal:\n\n```\nclient$ echo 'Hello, world!' | nc -q 1 -u 127.0.0.1 10000\nUryyb, jbeyq!\n```\n\nCool, it works. Now we want this script to run at all times, be restarted in case of a failure (unexpected exit), and even survive server restarts. That’s where systemd comes into play.\n\n...\n\n----\n\nHow would we test these instructions actually work? After you updated them? On different platforms and versions of php (5 vs 7) or tools (netcat openbsd vs traditional)? After a year has passed? That's what `docable` helps do for you.\n\n## Testing with `docable`\n\nTo test this example tutorial, we can run the following:\n\n```bash\ndocable report examples/unix-service/steps.yml\n```\n\n`docable` uses a stepfile, such as the following.\n\n```yml\nsetup:\n#  local: {}  \n  slim:\n    image: ubuntu16.04-php\n\nunix-service.md: \n  steps:\n    - selectAsFile: ROT13 transformation =\u003e server.php\n    - selectAndServe: \"start it:\"\n    - selectAndExpect: \"another terminal:\"\n```\n\nThe stepfile using a \"select-assert\" pattern for testing documentation. That is, we first find an instruction step in the tutorial using a lightweight selector, then, we transform the step into an action we can perform within a \"headless infrastructure\" (such as a vm), and finally we assert it's behavior is correct.\n\nThe result looks something like this:\n\n![example report](img/example-report.png)\n\nTurns out that our tutorial breaks if using a different version of netcat, which does not support the `-q 1` option. Oops!\n\nAfter fixing the issue by changing to using \"-w 1\" (terminated after timeout instead of time since no STDIN input). Running `docable test`, we verify have fixed the tutorial:\n\n![example execution](img/example-run.png)\n\n\n## Installing docable\n\n```\n$ git clone https://github.com/ottomatica/docable\n$ npm install\n$ npm link\n```\n\nUsing `slim` provider requires installing [slim](https://github.com/ottomatica/slim). You can also switch the stepfile to use a local provider under `setup:`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fottomatica%2Fdocable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fottomatica%2Fdocable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fottomatica%2Fdocable/lists"}