{"id":14065563,"url":"https://github.com/tokusumi/readme-code-testing","last_synced_at":"2025-04-15T13:52:14.734Z","repository":{"id":44727898,"uuid":"313580764","full_name":"tokusumi/readme-code-testing","owner":"tokusumi","description":"Helping test \"any\" code in readme with GitHub Action. All you need is unit testing synchronized external files in the ordinary way.","archived":false,"fork":false,"pushed_at":"2023-11-27T19:47:16.000Z","size":22,"stargazers_count":13,"open_issues_count":6,"forks_count":63,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T20:46:11.568Z","etag":null,"topics":["github-action","readme-quality","testing-practices"],"latest_commit_sha":null,"homepage":"","language":"Python","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/tokusumi.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":"2020-11-17T10:16:05.000Z","updated_at":"2025-01-06T21:21:18.000Z","dependencies_parsed_at":"2024-05-28T01:36:44.042Z","dependency_job_id":"2ddfcd09-70e0-4869-bac2-e444b2b67734","html_url":"https://github.com/tokusumi/readme-code-testing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Freadme-code-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Freadme-code-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Freadme-code-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Freadme-code-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tokusumi","download_url":"https://codeload.github.com/tokusumi/readme-code-testing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085474,"owners_count":21210267,"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":["github-action","readme-quality","testing-practices"],"created_at":"2024-08-13T07:04:33.750Z","updated_at":"2025-04-15T13:52:14.696Z","avatar_url":"https://github.com/tokusumi.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Readme code testing example\n\n![Test code and embed into README](https://github.com/tokusumi/readme-code-testing/workflows/Test%20code%20and%20embed%20into%20README/badge.svg)\n\nThis repo demonstrates [Markdown Embed Code From File](https://github.com/marketplace/actions/markdown-embed-code-from-file) (GitHub Action).\n\nThis would helps testing for your code within readme (actually for markdown).\n\nYou could put code in external file and test them, as same as ordinary testing your code. You don't need copy \u0026 paste code and feel anxisous about compatibility anymore.\n\n## Mark your code for embedding\n\nThis action could inspect your code, if you add a file path in code block as \"\\`\\`\\`lang:external/file/path.py\\`\\`\\`\".\n\nThe following code block has a file path `src/helloworld.py`:\n\n```python:src/helloworld.py\ndef hello():\n    return \"v1.0.0 world\"\n\n```\n\nSee [src/helloworld.py](./src/helloworld.py) as:\n\n* Synchronized code.\n* Highlighting code in readme.\n* Not affected code rendering.\n\nAnd notice that there are nothing to do re-embedding new/modified code. This action overrides code automatically if you change code in external file and commit it.\n\n### Try it\n\nLet's try demonstration in your repository as follows:\n\n1. fork this repository.\n1. edit [src/helloworld.py](./src/helloworld.py), create a new branch and start a pull request.\n1. go to PR to check action result.\n1. you can see auto updated readme at new branch you created above. (see if [above code block](#mark-your-code-for-embedding) is modified)\n1. you can try again, if you edit it and commit again.\n\n## More features\n### Embedding specific lines\n\nYou might add specific lines from one file (ex. [src/mul.py](./src/mul.py)).\n\nThis action supports this with the syntax as \"\\`\\`\\`lang:external/file/path.py [start:end]\\`\\`\\`\" for it:\n\n```py:src/mul.py [3-4]\ndef multiple(x):\n    return pow(x, 2)\n```\n\n### Multiple use\n\nYou might add one file path (ex. [src/mul.py](./src/mul.py)) for multiple code blocks:\n\n```py:src/mul.py\nfrom math import pow\n\ndef multiple(x):\n    return pow(x, 2)\n```\n\nIt works!:\n\n```py:src/mul.py\nfrom math import pow\n\ndef multiple(x):\n    return pow(x, 2)\n```\n\nHowever, the other is not available.\n\n### Non-existent file\n\nNotice that this action goes to \"fail\" if a file you add does not exist.\n\n## Multilingual\n\nThis action could work for any programming \"language\".\n\nIdeally you could write as \"\\`\\`\\`lang:external/file/path.py\\`\\`\\`\", but actually this action does not inspect \"lang\", just read path and copy\u0026paste strings into target code block in markdown.\n\nSo, missing \"lang\" is available:\n\n```:src/helloworld.sh\n#!/bin/bash\n\necho \"hello\"\n```\n\n## Formatting\n\nNotice that this action uses markdown parser/formatter, so, if you don't update any code, readme may be updated if formatter works.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokusumi%2Freadme-code-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokusumi%2Freadme-code-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokusumi%2Freadme-code-testing/lists"}