Skip to content

Commit

Permalink
Add typedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
varsill committed May 8, 2023
1 parent 983db3e commit e840e77
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/membrane/bin/pad_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule Membrane.Bin.PadData do

@type private_field :: term()

@typedoc @moduledoc
@type t :: %__MODULE__{
ref: Membrane.Pad.ref(),
options: Membrane.ChildrenSpec.pad_options(),
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/buffer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Membrane.Buffer do

@type metadata :: map

@typedoc @moduledoc
@type t :: %Buffer{
pts: Time.t() | nil,
dts: Time.t() | nil,
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/child_entry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Membrane.ChildEntry do
"""
use Bunch.Access

@typedoc @moduledoc
@type t :: %__MODULE__{
name: Membrane.Child.name(),
module: module,
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/clock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defmodule Membrane.Clock do
alias Membrane.Core.Message
alias Membrane.Time

@typedoc @moduledoc
@type t :: pid

@typedoc """
Expand Down
6 changes: 4 additions & 2 deletions lib/membrane/component_path.ex
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
defmodule Membrane.ComponentPath do
@moduledoc """
Traces element's path inside a pipeline.
Path is a list consisted of following pipeline/bin/element names down the assembled pipeline.
Path is a list consisting of following pipeline/bin/element names down the assembled pipeline.
Information is being stored in a process dictionary and can be set/appended to.
It traces element's path inside a pipeline.
"""

@typedoc @moduledoc
@type path :: list(String.t())

@key :membrane_path
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/element/pad_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defmodule Membrane.Element.PadData do

@type private_field :: term()

@typedoc @moduledoc
@type t :: %__MODULE__{
availability: Pad.availability(),
stream_format: StreamFormat.t() | nil,
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule Membrane.Event do

alias Membrane.EventProtocol

@typedoc @moduledoc
@type t :: EventProtocol.t()

@spec event?(t()) :: boolean
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/event/discontinuity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ defmodule Membrane.Event.Discontinuity do

defstruct duration: nil

@typedoc @moduledoc
@type t :: %__MODULE__{duration: duration}
end
2 changes: 2 additions & 0 deletions lib/membrane/event/underrun.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ defmodule Membrane.Event.Underrun do
"""
@derive Membrane.EventProtocol
defstruct []

@typedoc @moduledoc
@type t :: %__MODULE__{}
end
3 changes: 3 additions & 0 deletions lib/membrane/event_protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ defprotocol Membrane.EventProtocol do
Each event has to implement or derive this protocol.
"""

@typedoc """
A type describing all the types that implement the `Membrane.EventProtocol`.
"""
@type t :: struct

@doc """
Expand Down
1 change: 1 addition & 0 deletions lib/membrane/keyframe_request_event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ defmodule Membrane.KeyframeRequestEvent do

defstruct []

@typedoc @moduledoc
@type t :: %__MODULE__{}
end
3 changes: 2 additions & 1 deletion lib/membrane/notification.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule Membrane.ChildNotification do
`c:Membrane.Parent.handle_child_notification/4` callback.
"""

@typedoc @moduledoc
@type t :: any
end

Expand All @@ -20,6 +21,6 @@ defmodule Membrane.ParentNotification do
A notification can be handled in child with `c:Membrane.Element.Base.handle_parent_notification/3` or
`c:Membrane.Bin.handle_parent_notification/3` callback.
"""

@typedoc @moduledoc
@type t :: any
end
3 changes: 3 additions & 0 deletions lib/membrane/payload.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ defprotocol Membrane.Payload do
@callback new(binary()) :: Membrane.Payload.t()
end

@typedoc """
A type describing all the types that are implementing `Membrane.Payload` protocol.
"""
@type t :: any()

@doc """
Expand Down
2 changes: 2 additions & 0 deletions lib/membrane/playback.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ defmodule Membrane.Playback do
Untils the setup lasts, the component won't enter `:playing` playback.
"""

@typedoc @moduledoc
@type t :: :stopped | :playing
end
13 changes: 13 additions & 0 deletions lib/membrane/rc_message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ defmodule Membrane.RCMessage do
Check `t:t/0` for available messages.
"""

@typedoc """
The type describing all possible `Membrane.RCMessage`s.
"""
@type t ::
__MODULE__.Playing.t()
| __MODULE__.StartOfStream.t()
Expand All @@ -16,6 +19,8 @@ defmodule Membrane.RCMessage do
@moduledoc """
Message sent when the pipeline starts playing
"""

@typedoc @moduledoc
@type t :: %__MODULE__{from: pid()}

@enforce_keys [:from]
Expand All @@ -26,6 +31,8 @@ defmodule Membrane.RCMessage do
@moduledoc """
Message sent when some element of the pipeline receives the start of stream event on some pad.
"""

@typedoc @moduledoc
@type t :: %__MODULE__{
from: pid(),
element: Membrane.Element.name(),
Expand All @@ -40,6 +47,8 @@ defmodule Membrane.RCMessage do
@moduledoc """
Message sent when some element of the pipeline receives the start of stream event on some pad.
"""

@typedoc @moduledoc
@type t :: %__MODULE__{
from: pid(),
element: Membrane.Element.name(),
Expand All @@ -54,6 +63,8 @@ defmodule Membrane.RCMessage do
@moduledoc """
Message sent when the some element of the pipeline receives a notification.
"""

@typedoc @moduledoc
@type t :: %__MODULE__{
from: pid(),
element: Membrane.Element.name(),
Expand All @@ -68,6 +79,8 @@ defmodule Membrane.RCMessage do
@moduledoc """
Message sent when the pipeline gracefully terminates.
"""

@typedoc @moduledoc
@type t :: %__MODULE__{from: pid()}

@enforce_keys [:from]
Expand Down
2 changes: 2 additions & 0 deletions lib/membrane/remote_stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule Membrane.RemoteStream do
- `:type` - either `:bytestream` (continuous stream) or `:packetized` (each buffer
contains exactly one specified unit of data)
"""

@typedoc @moduledoc
@type t :: %__MODULE__{
content_format: module | nil,
type: :bytestream | :packetized
Expand Down
3 changes: 3 additions & 0 deletions lib/membrane/resource_guard.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ defmodule Membrane.ResourceGuard do
require Membrane.Core.Message, as: Message
require Membrane.Logger

@typedoc """
Utility for handling resources that must be cleaned up after use
"""
@type t :: pid()

@spec start_link(owner_pid :: pid) :: {:ok, t}
Expand Down
2 changes: 2 additions & 0 deletions lib/membrane/stream_format.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ defmodule Membrane.StreamFormat do
To link two pads together, their capabilities have to be compatible.
"""

@typedoc @moduledoc
@type t :: struct
end
4 changes: 4 additions & 0 deletions lib/membrane/sync.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ defmodule Membrane.Sync do

@no_sync :membrane_no_sync

@typedoc """
A type describing the the synchronization mechanism, used to synchronize multiple
processes, so that they could perform their jobs at the same time.
"""
@type t :: pid | :membrane_no_sync
@type status :: :registered | :sync

Expand Down
3 changes: 3 additions & 0 deletions lib/membrane/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ defmodule Membrane.Time do
@compile {:inline,
native_units: 1, native_unit: 0, nanoseconds: 1, nanosecond: 0, second: 0, seconds: 1}

@typedoc """
The time represented in Membrane's native time units - nanoseconds.
"""
@type t :: integer
@type non_neg :: non_neg_integer

Expand Down
4 changes: 4 additions & 0 deletions lib/membrane/utility_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ defmodule Membrane.UtilitySupervisor do
end
"""

@typedoc """
The pid of the `Membrane.UtilitySupervisor` process.
"""
@type t :: pid()

@doc """
Expand Down

0 comments on commit e840e77

Please sign in to comment.