Skip to content

Commit

Permalink
Group PageBuilder component docs under Components group (#428)
Browse files Browse the repository at this point in the history
* Add @doc type: :component to PageBuilder components

* Add groups_for_function doc option to mix.exs

* Remove parenthesis from some page builder component slot definitions
  • Loading branch information
rktjmp committed Oct 21, 2023
1 parent faa33e1 commit 17daa01
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
22 changes: 15 additions & 7 deletions lib/phoenix/live_dashboard/page_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the applications, processes, sockets pages and many others.
"""
@doc type: :component
attr :id, :any,
required: true,
doc: "Because is a stateful `Phoenix.LiveComponent` an unique id is needed."
Expand Down Expand Up @@ -300,6 +301,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the Metrics and Ecto info pages.
"""
@doc type: :component
attr :id, :any,
required: true,
doc: "Because is a stateful `Phoenix.LiveComponent` an unique id is needed."
Expand Down Expand Up @@ -342,6 +344,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
@doc """
Hint pop-up text component
"""
@doc type: :component
attr :text, :string, required: true, doc: "Text to show in the hint"

@spec hint(assigns :: Socket.assigns()) :: Phoenix.LiveView.Rendered.t()
Expand All @@ -362,6 +365,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
@doc """
Card title component.
"""
@doc type: :component
attr :title, :string, default: nil, doc: "The title above the card."
attr :hint, :string, default: nil, doc: "A textual hint to show close to the title."

Expand All @@ -380,8 +384,8 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the Home and OS Data pages.
"""

slot(:inner_block, required: true, doc: "The value that the card will show.")
@doc type: :component
slot :inner_block, required: true, doc: "The value that the card will show."
attr :title, :string, default: nil, doc: "The title above the card."
attr :hint, :string, default: nil, doc: "A textual hint to show close to the title."
attr :inner_title, :string, default: nil, doc: "The title inside the card."
Expand Down Expand Up @@ -409,7 +413,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the Home page in the Environment section.
"""

@doc type: :component
attr :fields, :list,
required: true,
doc: "A list of key-value elements that will be shown inside the card."
Expand Down Expand Up @@ -448,12 +452,12 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the Home page and OS Data pages.
"""
slot(:col,
@doc type: :component
slot :col,
required: true,
doc:
"A list of components. It can receive up to 3 components." <>
" Each element will be one column."
)

@spec row(assigns :: Socket.assigns()) :: Phoenix.LiveView.Rendered.t()
def row(assigns) do
Expand Down Expand Up @@ -485,6 +489,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the Home page and OS Data pages.
"""
@doc type: :component
attr :title, :string, default: nil, doc: "The title above the card."
attr :hint, :string, default: nil, doc: "A textual hint to show close to the title."
attr :dom_id, :string, required: true, doc: "A unique identifier for all usages in this card."
Expand Down Expand Up @@ -542,7 +547,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
attr :dom_id, :string, required: true
attr :percent, :float, required: true
attr :csp_nonces, :any, required: true
slot(:inner_block, required: true)
slot :inner_block, required: true

defp title_bar_component(assigns) do
~H"""
Expand Down Expand Up @@ -575,6 +580,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use the Home page and OS Data pages.
"""
@doc type: :component
attr :usages, :list,
required: true,
doc: """
Expand Down Expand Up @@ -700,6 +706,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
...> ]
...> ]
"""
@doc type: :component
attr :id, :any,
required: true,
doc: "Because is a stateful `Phoenix.LiveComponent` an unique id is needed."
Expand Down Expand Up @@ -764,6 +771,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
You can see it in use in the modal in Ports or Processes page.
"""
@doc type: :component
slot :elem, required: true, doc: "Value for each element of the list" do
attr :label, :string, required: true, doc: "Label for the elem"
end
Expand Down Expand Up @@ -792,7 +800,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
attr :title, :string, required: true, doc: "Title of the modal"

attr :return_to, :string, required: true, doc: "Path to return when closing the modal"
slot(:inner_block, required: true, doc: "Content to show in the modal")
slot :inner_block, required: true, doc: "Content to show in the modal"

def live_modal(assigns) do
~H"""
Expand Down
5 changes: 4 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ defmodule Phoenix.LiveDashboard.MixProject do
source_url: "https://github.com/phoenixframework/phoenix_live_dashboard",
extra_section: "GUIDES",
extras: extras(),
nest_modules_by_prefix: [Phoenix.LiveDashboard]
nest_modules_by_prefix: [Phoenix.LiveDashboard],
groups_for_functions: [
Components: &(&1[:type] == :component)
]
]
end

Expand Down

0 comments on commit 17daa01

Please sign in to comment.