Skip to content

Commit

Permalink
Polish more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed May 3, 2023
1 parent 0048b81 commit 97bc0df
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
8 changes: 8 additions & 0 deletions lib/xandra/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ defmodule Xandra.Error do
example, for logging purposes), it is possible to use `Exception.message/1` to
get a formatted version of the error.
"""

@doc """
The exception struct for a Cassandra error.
"""
defexception [:reason, :message, warnings: []]

@typedoc """
The type for a Cassandra error exception.
"""
@type t :: %__MODULE__{
reason: atom,
message: String.t(),
warnings: [String.t()]
}

@doc false
@spec new(atom, String.t(), [String.t()]) :: t
def new(reason, message, warnings)
when is_atom(reason) and is_binary(message) and is_list(warnings) do
Expand Down
19 changes: 15 additions & 4 deletions lib/xandra/prepared.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ defmodule Xandra.Prepared do
@moduledoc """
A data structure used to internally represent prepared queries.
These are the publicly accessible fields of this struct:
See [`%Xandra.Prepared{}`](`__struct__/0`) for information about which fields are
public. All other fields are documented in `t:t/0` to avoid Dialyzer warnings,
but are not meant to be used by users.
"""

@doc """
A struct that represents a prepared query.
These are the publicly-accessible fields of this struct:
* `:tracing_id` - the tracing ID (as a UUID binary) if tracing was enabled,
or `nil` if no tracing was enabled. See the "Tracing" section in `Xandra.execute/4`.
Expand All @@ -12,10 +20,7 @@ defmodule Xandra.Prepared do
it's of type `t:Xandra.custom_payload/0`. See the "Custom payloads" section
in the documentation for the `Xandra` module.
All other fields are documented in `t:t/0` to avoid Dialyzer warnings,
but are not meant to be used by users.
"""

defstruct [
:statement,
:values,
Expand All @@ -32,6 +37,12 @@ defmodule Xandra.Prepared do
:result_metadata_id
]

@typedoc """
The type for a prepared query.
The only public fields here are `:tracing_id` and `:response_custom_payload`.
See [`%Xandra.Prepared{}`](`__struct__/0`).
"""
@type t :: %__MODULE__{
statement: Xandra.statement(),
values: Xandra.values() | nil,
Expand Down
13 changes: 11 additions & 2 deletions lib/xandra/schema_change.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ defmodule Xandra.SchemaChange do
@moduledoc """
A struct that represents the result of a query that modifies the schema.
See [`%Xandra.SchemaChange{}`](`__struct__/0`) for information on the fields of this struct.
"""

@doc """
The struct for the "schema change" result.
This struct has the following fields:
* `:effect` - the type of change involved. It's one of `"CREATED"`,
Expand All @@ -25,11 +31,14 @@ defmodule Xandra.SchemaChange do
If the server doesn't send a custom payload, this field is `nil`. Otherwise,
it's of type `t:Xandra.custom_payload/0`. See the "Custom payloads" section
in the documentation for the `Xandra` module.
"""

defstruct [:effect, :target, :options, :tracing_id, :custom_payload]

@typedoc """
The type for a schema change result.
See [`%Xandra.SchemaChange{}`](`__struct__/0`) for information.
"""
@type t :: %__MODULE__{
effect: String.t(),
target: String.t(),
Expand Down
3 changes: 3 additions & 0 deletions lib/xandra/set_keyspace.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ defmodule Xandra.SetKeyspace do

defstruct [:keyspace, :tracing_id, :custom_payload]

@typedoc """
The type for a "set keyspace" result.
"""
@type t :: %__MODULE__{
keyspace: String.t(),
tracing_id: binary() | nil,
Expand Down
6 changes: 6 additions & 0 deletions lib/xandra/simple.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ defmodule Xandra.Simple do
:custom_payload
]

@typedoc """
The type for a simple query.
The fields of this are not meant to be used, but are documented to avoid
Dialyzer warnings.
"""
@type t :: %__MODULE__{
statement: Xandra.statement(),
values: Xandra.values() | nil,
Expand Down
3 changes: 3 additions & 0 deletions lib/xandra/void.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ defmodule Xandra.Void do

defstruct [:tracing_id, :custom_payload]

@typedoc """
The type for a "void" result.
"""
@type t :: %__MODULE__{
tracing_id: binary | nil,
custom_payload: Xandra.custom_payload() | nil
Expand Down

0 comments on commit 97bc0df

Please sign in to comment.