{"id":37186314,"url":"https://github.com/blocky/pluck","last_synced_at":"2026-01-14T21:36:25.747Z","repository":{"id":289932257,"uuid":"972702072","full_name":"blocky/pluck","owner":"blocky","description":"A tool for plucking snippets from source code often for documentation. ","archived":false,"fork":false,"pushed_at":"2025-06-18T22:16:58.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-11T00:58:29.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/blocky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2025-04-25T14:11:11.000Z","updated_at":"2025-06-18T22:16:59.000Z","dependencies_parsed_at":"2025-06-12T23:32:23.228Z","dependency_job_id":"936a8e3e-4cf7-40c7-bc91-1078ca142f23","html_url":"https://github.com/blocky/pluck","commit_stats":null,"previous_names":["blocky/pluck"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/blocky/pluck","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocky%2Fpluck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocky%2Fpluck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocky%2Fpluck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocky%2Fpluck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blocky","download_url":"https://codeload.github.com/blocky/pluck/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocky%2Fpluck/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28435508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-14T21:36:25.027Z","updated_at":"2026-01-14T21:36:25.739Z","avatar_url":"https://github.com/blocky.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pluck\n\nWhy is it so hard to put working code into docs? A few common options are:\n\n1. Embed the code in the text.  But trying to actually run that code tends to\n   be problematic.  The result is that often the code does not even\n   run--let alone run correctly.\n\n2. [Literate programming](https://en.wikipedia.org/wiki/Literate_programming)\n   is a great option.  (In fact, I tried for a bit to write my dissertation\n   using this approach.)  Often, the challenge with this option is that it needs\n   purpose built system (such as [knitr](https://yihui.org/knitr/) or\n   [jupyter](https://jupyter.org/)) and so it can be challenging if you have\n   constraints that do not fit in those ecosystems.\n\n3. Extract code by line number.  This seems to be a pretty common option. It\n   is lightweight and allows the code to be tested. Unfortunately, it can\n   result in some pretty odd results if the code changes without updating the\n   line numbers.\n\nPluck seeks to provide many of the benefits of extracting by line, but extract\ncode by \"tag\".  And since we are talking about code, we can use functions and\ntype definitions as our \"tags\".\n\n## Install\n\nTo install the latest version, run:\n\n```bash\ngo install github.com/blocky/pluck/cmd/pluck@latest\n```\n\nAnd give it is try! Let's create a go file:\n\n```bash\ncat  \u003c\u003cEOF \u003e go-file.go\npackage myPackge\n\ntype AType struct {\n    FieldOfAType int\n}\n\nfunc (f *AType) AMethodOfAType() error {\n    return nil\n}\n\nfunc AFunction() {}\nEOF\n```\n\nAnd let's extract the type from the file:\n\n```bash\npluck --input go-file.go --pick type:AType\n```\n\nIt will produce the following code snippet:\n\n```\ntype AType struct {\n    FieldOfAType int\n}\n```\n\nWe can even grab multiple items. For example, the two functions:\n\n```bash\npluck --input go-file.go --pick function:AType.AMethodOfAType --pick function:AFunction\n```\n\nWhich produces the code snippet:\n\n```\nfunc (f *AType) AMethodOfAType() error {\n    return nil\n}\n\nfunc AFunction() {}\n```\n\nAnd that is about it... Enjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblocky%2Fpluck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblocky%2Fpluck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblocky%2Fpluck/lists"}