feat: add source hyperlinks + remove thin from-source.md
Every source reference now links to elixir-lang/elixir at commit f4e1b34. 122 hyperlinks across 11 topic files. Added PATTERN_COMPLETE sentinels. Removed from-source.md (326 lines, shallow) — covered by existing files.
This commit is contained in:
+12
-10
@@ -6,7 +6,7 @@ Patterns extracted from the Elixir standard library source code.
|
||||
|
||||
## 1. Public Type with @typedoc
|
||||
|
||||
**Source:** `lib/elixir/lib/gen_server.ex` lines 862–896
|
||||
**Source:** [lib/elixir/lib/gen_server.ex#L862](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/gen_server.ex#L862)
|
||||
|
||||
**What it does:** Every public `@type` is preceded by a `@typedoc` that explains what the type represents, often referencing which functions use it.
|
||||
|
||||
@@ -91,7 +91,7 @@ the current state of a user account.
|
||||
|
||||
## 2. Private Types with @typep
|
||||
|
||||
**Source:** `lib/elixir/lib/macro.ex` lines 84, 97
|
||||
**Source:** [lib/elixir/lib/macro.ex#L84](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/macro.ex#L84), 97
|
||||
|
||||
**What it does:** Uses `@typep` for internal recursive type definitions that are implementation details not meant for external consumers.
|
||||
|
||||
@@ -190,7 +190,7 @@ end
|
||||
|
||||
## 3. @opaque Types (Protocol t())
|
||||
|
||||
**Source:** `lib/elixir/lib/protocol.ex` lines 150–168 (documentation), runtime generation
|
||||
**Source:** [lib/elixir/lib/protocol.ex#L150](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/protocol.ex#L150) (documentation), runtime generation
|
||||
|
||||
**What it does:** Protocols auto-generate an opaque `@type t :: term()` type that represents "any value implementing this protocol."
|
||||
|
||||
@@ -269,7 +269,7 @@ end
|
||||
|
||||
## 4. Union Types in @spec Return Values
|
||||
|
||||
**Source:** `lib/elixir/lib/gen_server.ex` lines 577–583, 647–658
|
||||
**Source:** [lib/elixir/lib/gen_server.ex#L577](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/gen_server.ex#L577), 647–658
|
||||
|
||||
**What it does:** Uses union types with descriptive tagged tuples in callback specs, making all possible return shapes explicit.
|
||||
|
||||
@@ -355,7 +355,7 @@ end
|
||||
|
||||
## 5. `when` Constraints in Specs
|
||||
|
||||
**Source:** `lib/elixir/lib/kernel.ex` lines 635, 1072, 1455
|
||||
**Source:** [lib/elixir/lib/kernel.ex#L635](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/kernel.ex#L635), 1072, 1455
|
||||
|
||||
**What it does:** Uses the `when` clause in `@spec` to bind type variables, expressing relationships between parameters and return values.
|
||||
|
||||
@@ -414,7 +414,7 @@ end
|
||||
|
||||
## 6. Map Types with required/optional Keys
|
||||
|
||||
**Source:** `lib/elixir/lib/supervisor.ex` lines 602–607, 644–652
|
||||
**Source:** [lib/elixir/lib/supervisor.ex#L602](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/supervisor.ex#L602), 644–652
|
||||
|
||||
**What it does:** Uses map type syntax with `required()` and `optional()` keys to define struct-like specs where some fields have defaults.
|
||||
|
||||
@@ -499,7 +499,7 @@ end
|
||||
|
||||
## 7. Keyword List Types for Options
|
||||
|
||||
**Source:** `lib/logger/lib/logger.ex` lines 509–531
|
||||
**Source:** [lib/logger/lib/logger.ex#L509](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/logger/lib/logger.ex#L509)
|
||||
|
||||
**What it does:** Defines option types as keyword lists with specific key-value constraints, sometimes nested.
|
||||
|
||||
@@ -588,7 +588,7 @@ end
|
||||
|
||||
## 8. Parameterized Types (t/1)
|
||||
|
||||
**Source:** `lib/elixir/lib/enum.ex` lines 58–73 (Enumerable protocol)
|
||||
**Source:** [lib/elixir/lib/enum.ex#L58](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/enum.ex#L58) (Enumerable protocol)
|
||||
|
||||
**What it does:** Defines a parameterized type `t(_element)` that allows expressing the element type of an enumerable in function specs.
|
||||
|
||||
@@ -670,7 +670,7 @@ integers and returns an enumerable of strings:
|
||||
|
||||
## 9. Named Parameters in Specs (:: annotation)
|
||||
|
||||
**Source:** `lib/elixir/lib/gen_server.ex` line 577, `lib/elixir/lib/supervisor.ex` line 562
|
||||
**Source:** [lib/elixir/lib/gen_server.ex#L577](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/gen_server.ex#L577), [lib/elixir/lib/supervisor.ex#L562](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/supervisor.ex#L562)
|
||||
|
||||
**What it does:** Uses `name :: type` syntax in callback/spec parameter positions to give meaningful names to parameters.
|
||||
|
||||
@@ -735,7 +735,7 @@ integers and returns an enumerable of strings:
|
||||
|
||||
## 10. @typedoc since: Annotation
|
||||
|
||||
**Source:** `lib/elixir/lib/supervisor.ex` lines 669–670, `lib/elixir/lib/enum.ex` line 72
|
||||
**Source:** [lib/elixir/lib/supervisor.ex#L669](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/supervisor.ex#L669), [lib/elixir/lib/enum.ex#L72](https://github.com/elixir-lang/elixir/blob/f4e1b34617ef92052b65781f18eae5b88a490098/lib/elixir/lib/enum.ex#L72)
|
||||
|
||||
**What it does:** Attaches a `since:` metadata annotation to `@typedoc` indicating when a type was introduced.
|
||||
|
||||
@@ -797,3 +797,5 @@ end
|
||||
```
|
||||
|
||||
**Why:** `since:` annotations are for library consumers checking compatibility across versions. Application code doesn't have "consumers" checking which version introduced a type — it's all deployed together.
|
||||
|
||||
<!-- PATTERN_COMPLETE -->
|
||||
|
||||
Reference in New Issue
Block a user