{"id":19248978,"url":"https://github.com/sbt/sbt-boilerplate","last_synced_at":"2025-04-05T09:07:12.487Z","repository":{"id":4997676,"uuid":"6155879","full_name":"sbt/sbt-boilerplate","owner":"sbt","description":"sbt plugin for generating scala.Tuple/Function related boilerplate code","archived":false,"fork":false,"pushed_at":"2025-03-03T21:27:12.000Z","size":119,"stargazers_count":109,"open_issues_count":6,"forks_count":20,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-03-29T08:07:21.159Z","etag":null,"topics":["code-generator","sbt","sbt-plugin","scala"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"hapijs/call","license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbt.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":"2012-10-10T10:46:23.000Z","updated_at":"2025-03-03T21:27:16.000Z","dependencies_parsed_at":"2024-07-10T23:32:05.697Z","dependency_job_id":"73df9567-401c-4b9e-8f48-d5acba55f4a6","html_url":"https://github.com/sbt/sbt-boilerplate","commit_stats":{"total_commits":94,"total_committers":12,"mean_commits":7.833333333333333,"dds":0.5106382978723405,"last_synced_commit":"af2bf341ea7705ec9a2ba9534501c7cc61afec01"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbt%2Fsbt-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbt%2Fsbt-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbt%2Fsbt-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbt%2Fsbt-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbt","download_url":"https://codeload.github.com/sbt/sbt-boilerplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312078,"owners_count":20918344,"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":["code-generator","sbt","sbt-plugin","scala"],"created_at":"2024-11-09T18:11:50.886Z","updated_at":"2025-04-05T09:07:12.021Z","avatar_url":"https://github.com/sbt.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sbt-boilerplate\n\nBoilerplate is an sbt-plugin that generates stubs for code which has to be expanded\nfor all numbers of arguments from 1 to 22. This is sometimes necessary to support\nall of the `TupleX` or `FunctionX` generically.\n\nThe plugin defines a simple template language for this purpose.\n\n## The template language\n\nThe template file contains mostly literal code with some control characters guiding the\nexpansion. Expansion follows these rules:\n\n - The current number of arguments `i` is initialized to 22.\n - Code embraced in `[#` and `#]` is copied `i` times and the expansion is applied\n   recursively with `i` being set accordingly.\n   - It is possible to define a custom separator\n     between the copied instances by putting the separator text between the `#` and the `]` of the closing\n     bracket. If no separator is supplied `\", \"` is assumed.\n   - You can specify a custom range `i` should iterate through by placing a term of the form `\u003cstart\u003e..\u003cend\u003e` between\n     the starting `[` and `#` of an expansion. Either `start` or `end` can be omitted in which case the defaults are         assumed.\n - Everywhere digit `1` is replaced by `i`, digit `0` is replaced by `i - 1`, and digit `2` is replaced by `i + 1`\n   unless the digit is prefixed with `##`.\n - To encode the sharp `'#'` character precede it with a backslash e.g. `\"\\#\"`.\n\n## Examples\n\n### Apply function to tuple\n\nConsider the task is to provide overloads for a function which can apply a function to\na tuple for all numbers of arguments from 1 to 22.\n\nStart by writing out the function for only one argument:\n\n    def applyFunc[P1, R](input: Tuple1[P1], func: (P1) =\u003e R): R =\n      func(input._1)\n\nFor the function to be copied for each possible number of arguments, enclose it in `[#`\nand `#]` (the newline between the closing `#` and `]` defines that instances should be\nseparated by newline and not by the default `\", \"`):\n\n    [#def applyFunc[P1, R](input: Tuple1[P1], func: (P1) =\u003e R): R =\n      func(input._1)#\n    ]\n\nThis will already expand to:\n\n    def applyFunc[P1, R](input: Tuple1[P1], func: (P1) =\u003e R): R =\n      func(input._1)\n    def applyFunc[P2, R](input: Tuple2[P2], func: (P2) =\u003e R): R =\n      func(input._2)\n    def applyFunc[P3, R](input: Tuple3[P3], func: (P3) =\u003e R): R =\n      func(input._3)\n    def applyFunc[P4, R](input: Tuple4[P4], func: (P4) =\u003e R): R =\n      func(input._4)\n    // ...\n\nThis is not yet what we want, because we `P1` to expand to\n`P1, P2, ..., Pi` and `input._1` to `input._1, input._2, ..., input._i`. So we embrace the\nparts to expand another time:\n\n    [#def applyFunc[[#P1#], R](input: Tuple1[[#P1#]], func: ([#P1#]) =\u003e R): R =\n      func([#input._1#])#\n    ]\n\nThis now expands correctly to\n\n    def applyFunc[P1, R](input: Tuple1[P1], func: (P1) =\u003e R): R =\n      func(input._1)\n    def applyFunc[P1, P2, R](input: Tuple2[P1, P2], func: (P1, P2) =\u003e R): R =\n      func(input._1, input._2)\n    def applyFunc[P1, P2, P3, R](input: Tuple3[P1, P2, P3], func: (P1, P2, P3) =\u003e R): R =\n      func(input._1, input._2, input._3)\n    def applyFunc[P1, P2, P3, P4, R](input: Tuple4[P1, P2, P3, P4], func: (P1, P2, P3, P4) =\u003e R): R =\n      func(input._1, input._2, input._3, input._4)\n\n## Usage\n\nsbt-boilerplate currently supports sbt 1.x.\n\nPut\n\n    addSbtPlugin(\"com.github.sbt\" % \"sbt-boilerplate\" % \"0.7.0\")\n\ninto your `plugins.sbt`. sbt-boilerplate is an `AutoPlugin` which needs to be enabled using\n\n```scala\nenablePlugins(spray.boilerplate.BoilerplatePlugin)\n```\n\nThe templates have to be put into the `src/main/boilerplate` directory and the file name\nmust end with `.template`. The generated files will be put into the same hierarchy as they\nappear in `src/main/boilerplate` with the `.template` extension stripped off. If the stripped\nfilename has no extension \".scala\" is added automatically.\n\n## Known issues\n\n * Instances for zero arguments have to be supplied manually.\n\n## Projects using sbt-boilerplate\n\n * [akka](https://github.com/akka/akka) uses sbt-boilerplate for akka-actor, akka-stream, and akka-http\n * [spray-routing](https://github.com/spray/spray) uses sbt-boilerplate to provide conversions to/from HLists\n * [product-collections](https://github.com/marklister/product-collections)\n\n## License\n\nCopyright (c) 2012-2016 Johannes Rudolph\n\nPublished under the [BSD 2-Clause License](http://www.opensource.org/licenses/BSD-2-Clause).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbt%2Fsbt-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbt%2Fsbt-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbt%2Fsbt-boilerplate/lists"}