Skip to content

existential-birds/beagle / plugins/beagle-elixir/skills/elixir-writing-docs

elixir-writing-docs

Verified

Guides writing Elixir documentation with @moduledoc, @doc, @typedoc, doctests, cross-references, and metadata. Use when adding or improving documentation in .ex files.

FileKindSize
SKILL.mdskill md9.0 KB
references/admonitions-and-formatting.mdmarkdown7.1 KB
references/cross-references.mdmarkdown4.3 KB
references/doctests.mdmarkdown6.8 KB

references/cross-references.md

View on GitHub
# Cross-References and Linking

ExDoc auto-links identifiers written in backtick-delimited code spans. This reference covers every linking syntax available.

## Module Links

Reference another module by writing its name in backticks:

```elixir
@moduledoc """
See `MyApp.Accounts` for user management functions.
"""
```

If the module name collides with a local function or could be ambiguous, use the `m:` prefix:

```elixir
@doc """
Delegates to `m:MyApp.Accounts` for persistence.
"""
```

The `m:` prefix is also useful when linking to modules whose names look like function calls.

## Function Links

### Remote Functions (Other Modules)

```elixir
@doc """
Similar to `MyApp.Accounts.get_user/1` but raises on failure.
Accepts the same options as `MyApp.Accounts.list_users/2`.
"""
```

### Local Functions (Same Module)

Omit the module name to link to a function in the current module:

```elixir
@doc """
The bang variant of `fetch_config/1`. Raises `KeyError` if the key is missing.
"""
```

### Operators

```elixir
@doc """
Works like the `Kernel.<>/2` operator but for lists.
"""
```

### Function Arity

Always include the arity. `function/1` and `function/2` are distinct links:

```elixir
@doc """
See `transform/1` for the single-argument version, or
`transform/2` to pass options.
"""
```

## Type Links

Use the `t:` prefix to link to types:

```elixir
@doc """
Returns a `t:MyApp.Money.amount/0` representing the balance.

Accepts any `t:Enumerable.t/0` as input.
"""
```

For types in the same module:

```elixir
@doc """
Returns a `t:result/0` tuple.
"""
```

## Callback Links

Use the `c:` prefix to link to behaviour callbacks:

```elixir
@doc """
Invoked by the framework. See `c:GenServer.init/1` for details.

Implementations must satisfy `c:MyApp.PaymentGateway.charge/2`.
"""
```

## Erlang Module and Function Links

### Erlang Modules

Use `m:` with the atom syntax:

```elixir
@doc """
Uses `m::ets` for fast in-memory lookups.
"""
```

### Erlang Functions

Use the atom syntax directly:

```elixir
@doc """
Wraps `:erlang.system_info/1` to fetch VM metrics.

Delegates to `:timer.send_interval/2` for periodic messages.
"""
```

### Erlang Types

```elixir
@doc """
Returns a `t::erlang.reference/0`.
"""
```

## Custom Text Links

When you want link text that differs from the identifier, use markdown link syntax with a backtick-delimited destination:

```elixir
@doc """
Returns a [money amount](`MyApp.Money.amount/0`) in the given currency.

See the [payment gateway behaviour](`MyApp.PaymentGateway`) for the
full contract.

Read the [validation rules](`MyApp.Validation.validate/2`) for details.
"""
```

## Cross-Application References

Link to documentation in other Hex packages or OTP apps using `e:`:

```elixir
@doc """
Follows the patterns described in the
[Elixir writing documentation guide](`e:elixir:writing-documentation.html`).

See [Plug.Conn](`e:plug:Plug.Conn.html`) for the full struct reference.
"""
```

For functions in other apps:

```elixir
@doc """
Wraps [`Ecto.Repo.transaction/2`](`e:ecto:Ecto.Repo.html#c:transaction/2`).
"""
```

## Linking to Extra Pages

If your project includes extra markdown pages in the ExDoc configuration, link to them by filename:

```elixir
@moduledoc """
For deployment instructions, see the [Operations Guide](operations-guide.md).

Architecture decisions are documented in [ADR-001](adr/001-event-sourcing.md).
"""
```

## Summary of Prefixes

| Prefix | Links to | Example |
|--------|----------|---------|
| *(none)* | Module or function | `` `MyApp.Repo` ``, `` `fetch/1` `` |
| `m:` | Module (explicit) | `` `m:MyApp.Repo` `` |
| `t:` | Type | `` `t:String.t/0` `` |
| `c:` | Callback | `` `c:GenServer.init/1` `` |
| `e:` | Cross-app page | `` `e:elixir:writing-documentation.html` `` |

## Common Mistakes

```elixir
# BAD - missing arity
@doc "See `MyApp.Accounts.get_user` for details."

# GOOD - include arity
@doc "See `MyApp.Accounts.get_user/1` for details."

# BAD - using URL-style links for internal modules
@doc "See [MyApp.Accounts](https://hexdocs.pm/my_app/MyApp.Accounts.html)."

# GOOD - let ExDoc resolve the link
@doc "See `MyApp.Accounts`."

# BAD - linking to private functions (ExDoc will warn)
@doc "Uses `do_internal_parse/2` under the hood."

# GOOD - only link to public API
@doc "Uses an internal parser to process the input."
```
rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).Stars: 198kUpdated Claude CodeCodexUnverifiedInstall
doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.Stars: 198kUpdated Claude CodeCodexVerifiedInstall