{"id":16732352,"url":"https://github.com/danielberkompas/delegate_with_docs","last_synced_at":"2026-03-16T01:43:38.904Z","repository":{"id":57489039,"uuid":"113477285","full_name":"danielberkompas/delegate_with_docs","owner":"danielberkompas","description":"Delegate functions while preserving their docs","archived":false,"fork":false,"pushed_at":"2017-12-07T17:25:25.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-10T02:35:45.979Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/danielberkompas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-07T17:01:07.000Z","updated_at":"2023-02-17T21:36:07.000Z","dependencies_parsed_at":"2022-08-29T22:11:36.138Z","dependency_job_id":null,"html_url":"https://github.com/danielberkompas/delegate_with_docs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/danielberkompas/delegate_with_docs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fdelegate_with_docs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fdelegate_with_docs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fdelegate_with_docs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fdelegate_with_docs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielberkompas","download_url":"https://codeload.github.com/danielberkompas/delegate_with_docs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fdelegate_with_docs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004176,"owners_count":26083688,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["elixir"],"created_at":"2024-10-12T23:43:59.832Z","updated_at":"2025-10-10T14:33:34.545Z","avatar_url":"https://github.com/danielberkompas.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DelegateWithDocs\n\n[![Hex.pm](https://img.shields.io/hexpm/v/delegate_with_docs.svg)](https://hex.pm/packages/delegate_with_docs)\n[![Build Status](https://travis-ci.org/danielberkompas/delegate_with_docs.svg?branch=master)](https://travis-ci.org/danielberkompas/delegate_with_docs)\n\nDelegate to functions on other modules, including their docs. \n\n`Kernel.defdelegate/2` will only delegate the function, referencing the other\nmodule's documentation, \"See OtherModule.func/1\". This is fine when the other\nmodule is public, but not if it is excluded from documentation with\n`@moduledoc false`.\n\n## Installation\n\nThe [Hex](https://hex.pm) package can be installed by adding\n`delegate_with_docs` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:delegate_with_docs, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\n1. Add `use DelegateWithDocs` to the private module you want to delegate\n   to. This will ensure its docs are available to other modules at\n   compile time.\n\n2. Add `use DelegateWithDocs` to the public module.\n\n3. Use `defdelegate/2` as usual.\n\n## Example\n\nIn this example, we want to exclude `MyModule.Internal` from our\ndocumentation because it's an internal module and may change. However, we\nstill want to expose one of its functions as part of our public API.\n\n```elixir\ndefmodule MyModule.Internal do\n  @moduledoc false\n\n  # We must `use` this in the private module to ensure that\n  # its docs are available at compile time to other modules\n  use DelegateWithDocs\n\n  @doc \"Describe the function\"\n  @spec my_func(any, any) :: no_return\n  def my_func(arg1, arg2) do\n    # ...\n  end\nend\n```\n\nYou could do this with `Kernel.defdelegate/2`, but the documentation would\nbe lost. You'd either have to duplicate the documentation in your public\nmodule, or move it from the internal module to the public module.\n\nIt usually makes more sense to keep the documentation for a function\nco-located with the function that it documents. `DelegateWithDocs` allows\nyou to do that.\n\n```elixir\ndefmodule MyModule do\n  use DelegateWithDocs\n\n  # The docs from MyModule.Internal.my_func/2 will be copied\n  # over and will display as the docs for this delegated function.\n  defdelegate my_func(arg1, arg2), to: MyModule.Internal\nend\n```\n\nYou can also rename the function using the `:as` option, just like\n`Kernel.defdelegate/2`.\n\n```elixir\ndefdelegate better_name(arg1, arg2), to: MyModule.Internal, as: :my_func\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fdelegate_with_docs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielberkompas%2Fdelegate_with_docs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fdelegate_with_docs/lists"}