Skip to content

Commit 4c1f4c6

Browse files
committed
Undeprecate Example and rename it to LiveExample
1 parent 06e1c8f commit 4c1f4c6

File tree

8 files changed

+18
-24
lines changed

8 files changed

+18
-24
lines changed

lib/surface/catalogue/examples.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
defmodule Surface.Catalogue.Examples do
22
@moduledoc since: "0.8.0"
33
@moduledoc ~S'''
4-
A generic LiveView to create multiple examples for catalogue tools.
4+
A generic LiveView to create multiple stateless examples for the Surface Catalogue.
55
66
Each example must be a function component defined with the module attribute `@example`.
77
8+
> **NOTE**: If your examples require manipulating state (data) through `handle_event` callbacks,
9+
> use `Surface.Catalogue.LiveExample` instead.
10+
811
## Options
912
1013
Besides the buit-in options provided by the LiveView itself, examples can also

lib/surface/catalogue/example.ex renamed to lib/surface/catalogue/live_example.ex

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
defmodule Surface.Catalogue.Example do
1+
defmodule Surface.Catalogue.LiveExample do
22
@moduledoc """
3-
> #### Deprecation warning {: .warning}
4-
>
5-
> This component has been deprecated in favor of `Surface.Catalogue.Examples`.
3+
A generic LiveView to create a single live example for the Surface Catalogue.
64
7-
A generic LiveView to create a single example for catalogue tools.
5+
Use `LiveExample` if your example requires manipulating state (data) through
6+
`handle_event` callbacks. For stateless examples, you should use `Surface.Catalogue.Examples`
7+
as it allows defining multiple examples on a single module.
88
99
## Options
1010
@@ -36,16 +36,7 @@ defmodule Surface.Catalogue.Example do
3636
3737
"""
3838

39-
@moduledoc deprecated: "Use `Surface.Catalogue.Examples` instead"
40-
4139
defmacro __using__(opts) do
42-
if Mix.env() != :test do
43-
IO.warn(
44-
"`Surface.Catalogue.Example` is deprecated. Use `Surface.Catalogue.Examples` instead",
45-
Macro.Env.stacktrace(__CALLER__)
46-
)
47-
end
48-
4940
subject = Surface.Catalogue.fetch_subject!(opts, __MODULE__, __CALLER__)
5041

5142
quote do

test/support/catalogue/fake_example.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Surface.Catalogue.FakeExample do
2-
use Surface.Catalogue.Example,
2+
use Surface.Catalogue.LiveExample,
33
subject: Surface.FakeComponent,
44
title: "A fake example",
55
assert: ["The code"]

test/support/catalogue/fake_example_moduledoc.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Surface.Catalogue.FakeExampleModuleDocFalse do
22
@moduledoc false
33

4-
use Surface.Catalogue.Example,
4+
use Surface.Catalogue.LiveExample,
55
subject: Surface.FakeComponent,
66
title: "A fake example"
77

test/support/catalogue/fake_example_with_user_config.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Surface.Catalogue.FakeExampleWithUserConfig do
2-
use Surface.Catalogue.Example,
2+
use Surface.Catalogue.LiveExample,
33
subject: Surface.FakeComponent,
44
head_css: "User's fake css",
55
head_js: "User's fake js"

test/support/live_view_test/fake_example.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Surface.LiveViewTestTest.FakeExample do
2-
use Surface.Catalogue.Example,
2+
use Surface.Catalogue.LiveExample,
33
subject: Surface.LiveViewTestTest.FakeComponent,
44
title: "A fake example",
55
assert: "the code"

test/support/live_view_test/fake_example_for_other_fake_component.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Surface.LiveViewTestTest.FakeExampleForOtherFakeComponent do
2-
use Surface.Catalogue.Example,
2+
use Surface.Catalogue.LiveExample,
33
subject: Surface.LiveViewTestTest.OtherFakeComponent,
44
title: "A fake example"
55

test/surface/catalogue/example_test.exs renamed to test/surface/catalogue/live_example_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Surface.Catalogue.ExampleTest do
1+
defmodule Surface.Catalogue.LiveExampleTest do
22
use ExUnit.Case
33

44
alias Surface.Catalogue.FakeExample
@@ -31,16 +31,16 @@ defmodule Surface.Catalogue.ExampleTest do
3131
test "subject is required" do
3232
code = """
3333
defmodule ExampleTest_subject_is_required do
34-
use Surface.Catalogue.Example
34+
use Surface.Catalogue.LiveExample
3535
end
3636
"""
3737

3838
message = """
39-
code.exs:2: no subject defined for Surface.Catalogue.Example
39+
code.exs:2: no subject defined for Surface.Catalogue.LiveExample
4040
4141
Hint: You can define the subject using the :subject option. Example:
4242
43-
use Surface.Catalogue.Example, subject: MyApp.MyButton
43+
use Surface.Catalogue.LiveExample, subject: MyApp.MyButton
4444
"""
4545

4646
assert_raise CompileError, message, fn ->

0 commit comments

Comments
 (0)