{"id":15492276,"url":"https://github.com/ethlo/source-extractor-maven-plugin","last_synced_at":"2025-07-20T13:33:34.080Z","repository":{"id":221416661,"uuid":"754319277","full_name":"ethlo/source-extractor-maven-plugin","owner":"ethlo","description":"Source extractor for documentation purposes. Extract code from actual source code to avoid maintaining codesamples in documentation. Link to full examples.","archived":false,"fork":false,"pushed_at":"2024-02-11T10:05:50.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-10T23:06:52.505Z","etag":null,"topics":["documentation","java","source-code","technical-writing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethlo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-02-07T20:20:18.000Z","updated_at":"2025-02-15T04:39:27.000Z","dependencies_parsed_at":"2025-03-28T16:43:02.130Z","dependency_job_id":"b1d98563-b553-4af7-8683-9516ab64c5cb","html_url":"https://github.com/ethlo/source-extractor-maven-plugin","commit_stats":null,"previous_names":["ethlo/java-code-extractor-maven-plugin","ethlo/source-extractor-maven-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ethlo/source-extractor-maven-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethlo%2Fsource-extractor-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethlo%2Fsource-extractor-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethlo%2Fsource-extractor-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethlo%2Fsource-extractor-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethlo","download_url":"https://codeload.github.com/ethlo/source-extractor-maven-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethlo%2Fsource-extractor-maven-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135014,"owners_count":23881774,"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":["documentation","java","source-code","technical-writing"],"created_at":"2024-10-02T07:59:56.540Z","updated_at":"2025-07-20T13:33:34.057Z","avatar_url":"https://github.com/ethlo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### source-extractor-maven-plugin\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.ethlo.documentation/source-extractor-maven-plugin.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.ethlo.time%22%20a%3A%22itu%22)\n[![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](LICENSE)\n\nAn opinionated little tool to extract code samples for inclusion in HTML or markdown to avoid maintaining example code separately from tests.\n\nAn example can be seen here: https://github.com/ethlo/itu/?tab=readme-ov-file#parsing\n\nStanding on the shoulders of these awesome projects:\n* https://github.com/javaparser/javaparser\n* https://github.com/PebbleTemplates/pebble\n\n### How it works\nYou define the plugin to extract methods from classes in a given package. These are processed and then rendered with the specified template,  and are available as a variable name matching the defined `\u003csource\u003e` name.\nThis variable can then be used in maven resource interpolation to be included in a readme file, for example.\n\n### Usage\n\nWe need to set up the plugin to extract the relevant source code. I recommend a package with samples you want to showcase, like `src/test/java/mysamples`.\n\nThe example below stores a `README.md` _template_ in `src/site`.\n\nThe `pom.xml` resources section (must be filtered) so that you can include snippets rendered.\n```xml\n\u003cproject\u003e\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003ecom.ethlo.documentation\u003c/groupId\u003e\n                \u003cartifactId\u003esource-extractor-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e0.3.0\u003c/version\u003e\n                \u003cconfiguration\u003e\n                    \u003ctemplate\u003esrc/main/site/github.template.md\u003c/template\u003e\n                    \u003csources\u003e\n                        \u003csource\u003esrc/test/java/samples\u003c/source\u003e\n                    \u003c/sources\u003e\n                \u003c/configuration\u003e\n                \u003cexecutions\u003e\n                    \u003cexecution\u003e\n                        \u003cphase\u003einitialize\u003c/phase\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003eextract\u003c/goal\u003e\n                        \u003c/goals\u003e\n                    \u003c/execution\u003e\n                \u003c/executions\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n        \u003cresources\u003e\n            \u003cresource\u003e\n                \u003cdirectory\u003esrc/main/resources\u003c/directory\u003e\n            \u003c/resource\u003e\n            \u003cresource\u003e\n                \u003cfiltering\u003etrue\u003c/filtering\u003e\n                \u003cdirectory\u003e${project.basedir}/src/main/site\u003c/directory\u003e\n                \u003cincludes\u003e\n                    \u003cinclude\u003eREADME.md\u003c/include\u003e\n                \u003c/includes\u003e\n                \u003ctargetPath\u003e${project.basedir}\u003c/targetPath\u003e\n            \u003c/resource\u003e\n        \u003c/resources\u003e\n    \u003c/build\u003e\n\u003c/project\u003e\n```\n### Extracted samples\n\n\n\n#### showOffFeatureA \u003cspan style=\"font-weight: normal\"\u003e[\u0026raquo; source](src/test/java/samples/SampleCode.java#L28C5-L37C6)\u003c/span\u003e\n\n\u003cp\u003eDescription of the cool feature A goes here!\u003c/p\u003e\n\n```java\nfinal List\u003cString\u003e list = Arrays.asList(\"something\", \"cool\");\nassert list.size() == 2;\nassert list != null;\n```\n\n\n#### showOffFeatureB \u003cspan style=\"font-weight: normal\"\u003e[\u0026raquo; source](src/test/java/samples/SampleCode.java#L39C5-L50C6)\u003c/span\u003e\n\nDescription of the cool feature B goes here!\n\n And some more here!\n\n```java\nfinal List\u003cString\u003e list = Arrays.asList(\"something\", \"else\", \"cool\");\nassert list.size() == 2;\nassert list != null;\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethlo%2Fsource-extractor-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethlo%2Fsource-extractor-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethlo%2Fsource-extractor-maven-plugin/lists"}