Fix ex_docs warnings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-04-07 18:37:44 +02:00
parent 698f78ee9a
commit 7a18d0b2bb
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
20 changed files with 58 additions and 42 deletions

View File

@ -19,7 +19,7 @@ defmodule Mobilizon.GraphQL.API.Search do
Searches actors. Searches actors.
""" """
@spec search_actors(map(), integer | nil, integer | nil, ActorType.t()) :: @spec search_actors(map(), integer | nil, integer | nil, ActorType.t()) ::
{:ok, Page.t()} | {:error, String.t()} {:ok, Page.t(Actor.t())} | {:error, String.t()}
def search_actors(%{term: term} = args, page \\ 1, limit \\ 10, result_type) do def search_actors(%{term: term} = args, page \\ 1, limit \\ 10, result_type) do
term = String.trim(term) term = String.trim(term)
@ -64,7 +64,7 @@ defmodule Mobilizon.GraphQL.API.Search do
Search events Search events
""" """
@spec search_events(map(), integer | nil, integer | nil) :: @spec search_events(map(), integer | nil, integer | nil) ::
{:ok, Page.t()} {:ok, Page.t(Event.t())}
def search_events(%{term: term} = args, page \\ 1, limit \\ 10) do def search_events(%{term: term} = args, page \\ 1, limit \\ 10) do
term = String.trim(term) term = String.trim(term)
@ -100,7 +100,7 @@ defmodule Mobilizon.GraphQL.API.Search do
end end
# If the search string is an username # If the search string is an username
@spec process_from_username(String.t()) :: Page.t() @spec process_from_username(String.t()) :: Page.t(Actor.t())
defp process_from_username(search) do defp process_from_username(search) do
case ActivityPubActor.find_or_make_actor_from_nickname(search) do case ActivityPubActor.find_or_make_actor_from_nickname(search) do
{:ok, %Actor{type: :Group} = actor} -> {:ok, %Actor{type: :Group} = actor} ->
@ -118,7 +118,7 @@ defmodule Mobilizon.GraphQL.API.Search do
end end
# If the search string is an URL # If the search string is an URL
@spec process_from_url(String.t()) :: Page.t() @spec process_from_url(String.t()) :: Page.t(struct())
defp process_from_url(search) do defp process_from_url(search) do
case ActivityPub.fetch_object_from_url(search) do case ActivityPub.fetch_object_from_url(search) do
{:ok, object} -> {:ok, object} ->

View File

@ -10,7 +10,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Followers do
alias Mobilizon.Storage.Page alias Mobilizon.Storage.Page
alias Mobilizon.Users.User alias Mobilizon.Users.User
@spec find_followers_for_group(Actor.t(), map(), map()) :: {:ok, Page.t()} @spec find_followers_for_group(Actor.t(), map(), map()) :: {:ok, Page.t(Follower.t())}
def find_followers_for_group( def find_followers_for_group(
%Actor{id: group_id} = group, %Actor{id: group_id} = group,
args, args,

View File

@ -357,7 +357,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do
@doc """ @doc """
Returns this person's group memberships Returns this person's group memberships
""" """
@spec person_memberships(Actor.t(), map(), map()) :: {:ok, Page.t()} | {:error, String.t()} @spec person_memberships(Actor.t(), map(), map()) ::
{:ok, Page.t(Member.t())} | {:error, String.t()}
def person_memberships(%Actor{id: actor_id} = person, args, %{ def person_memberships(%Actor{id: actor_id} = person, args, %{
context: %{current_user: %User{} = user} context: %{current_user: %User{} = user}
}) do }) do
@ -399,7 +400,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do
@doc """ @doc """
Returns this person's group follows Returns this person's group follows
""" """
@spec person_follows(Actor.t(), map(), map()) :: {:ok, Page.t()} | {:error, String.t()} @spec person_follows(Actor.t(), map(), map()) ::
{:ok, Page.t(Follower.t())} | {:error, String.t()}
def person_follows(%Actor{} = person, %{group: group}, %{ def person_follows(%Actor{} = person, %{group: group}, %{
context: %{current_user: %User{} = user} context: %{current_user: %User{} = user}
}) do }) do

View File

@ -81,7 +81,7 @@ defmodule Mobilizon.Activities do
Keyword.t(), Keyword.t(),
integer() | nil, integer() | nil,
integer() | nil integer() | nil
) :: Page.t() ) :: Page.t(Activity.t())
def list_group_activities_for_member( def list_group_activities_for_member(
group_id, group_id,
actor_asking_id, actor_asking_id,
@ -107,7 +107,7 @@ defmodule Mobilizon.Activities do
Keyword.t(), Keyword.t(),
integer() | nil, integer() | nil,
integer() | nil integer() | nil
) :: Page.t() ) :: Page.t(Activity.t())
def list_group_activities( def list_group_activities(
group_id, group_id,
filters \\ [], filters \\ [],

View File

@ -317,7 +317,7 @@ defmodule Mobilizon.Actors do
boolean, boolean,
integer | nil, integer | nil,
integer | nil integer | nil
) :: Page.t() ) :: Page.t(Actor.t())
def list_actors( def list_actors(
type \\ :Person, type \\ :Person,
preferred_username \\ "", preferred_username \\ "",
@ -452,7 +452,7 @@ defmodule Mobilizon.Actors do
Keyword.t(), Keyword.t(),
integer | nil, integer | nil,
integer | nil integer | nil
) :: Page.t() ) :: Page.t(Actor.t())
def search_actors( def search_actors(
term, term,
options \\ [], options \\ [],
@ -1103,7 +1103,7 @@ defmodule Mobilizon.Actors do
Returns the paginated list of external followers for an actor. Returns the paginated list of external followers for an actor.
""" """
@spec list_external_followers_for_actor_paginated(Actor.t(), integer | nil, integer | nil) :: @spec list_external_followers_for_actor_paginated(Actor.t(), integer | nil, integer | nil) ::
Page.t() Page.t(Actor.t())
def list_external_followers_for_actor_paginated(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do def list_external_followers_for_actor_paginated(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do
actor_id actor_id
|> list_external_followers_for_actor_query() |> list_external_followers_for_actor_query()
@ -1113,7 +1113,7 @@ defmodule Mobilizon.Actors do
@doc """ @doc """
Build a page struct for followers of an actor. Build a page struct for followers of an actor.
""" """
@spec build_followers_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec build_followers_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t(Follower.t())
def build_followers_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do def build_followers_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do
actor_id actor_id
|> follower_actors_for_actor_query() |> follower_actors_for_actor_query()
@ -1135,7 +1135,7 @@ defmodule Mobilizon.Actors do
Returns a paginated list of followers for an actor. Returns a paginated list of followers for an actor.
""" """
@spec list_paginated_followers_for_actor(Actor.t(), boolean | nil, integer | nil, integer | nil) :: @spec list_paginated_followers_for_actor(Actor.t(), boolean | nil, integer | nil, integer | nil) ::
Page.t() Page.t(Follower.t())
def list_paginated_followers_for_actor( def list_paginated_followers_for_actor(
%Actor{id: actor_id}, %Actor{id: actor_id},
approved \\ nil, approved \\ nil,
@ -1165,7 +1165,7 @@ defmodule Mobilizon.Actors do
Returns the list of external followings for an actor. Returns the list of external followings for an actor.
""" """
@spec list_external_followings_for_actor_paginated(Actor.t(), integer | nil, integer | nil) :: @spec list_external_followings_for_actor_paginated(Actor.t(), integer | nil, integer | nil) ::
Page.t() Page.t(Follower.t())
def list_external_followings_for_actor_paginated( def list_external_followings_for_actor_paginated(
%Actor{id: actor_id}, %Actor{id: actor_id},
page \\ nil, page \\ nil,
@ -1179,7 +1179,8 @@ defmodule Mobilizon.Actors do
@doc """ @doc """
Build a page struct for followings of an actor. Build a page struct for followings of an actor.
""" """
@spec build_followings_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec build_followings_for_actor(Actor.t(), integer | nil, integer | nil) ::
Page.t(Follower.t())
def build_followings_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do def build_followings_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do
actor_id actor_id
|> followings_actors_for_actor_query() |> followings_actors_for_actor_query()

View File

@ -16,7 +16,7 @@ defmodule Mobilizon.Addresses.Address do
locality: String.t() | nil, locality: String.t() | nil,
region: String.t() | nil, region: String.t() | nil,
description: String.t() | nil, description: String.t() | nil,
geom: Geo.PostGIS.Geometry.t() | nil, geom: Geo.Point.t() | nil,
postal_code: String.t() | nil, postal_code: String.t() | nil,
street: String.t() | nil, street: String.t() | nil,
type: String.t() | nil, type: String.t() | nil,

View File

@ -36,7 +36,7 @@ defmodule Mobilizon.Admin do
@doc """ @doc """
Returns the list of action logs. Returns the list of action logs.
""" """
@spec list_action_logs(integer | nil, integer | nil) :: Page.t() @spec list_action_logs(integer | nil, integer | nil) :: Page.t(ActionLog.t())
def list_action_logs(page \\ nil, limit \\ nil) do def list_action_logs(page \\ nil, limit \\ nil) do
list_action_logs_query() list_action_logs_query()
|> Page.build_page(page, limit) |> Page.build_page(page, limit)

View File

@ -225,7 +225,7 @@ defmodule Mobilizon.Discussions do
@doc """ @doc """
Returns a paginated list of local comments Returns a paginated list of local comments
""" """
@spec list_local_comments(integer | nil, integer | nil) :: Page.t() @spec list_local_comments(integer | nil, integer | nil) :: Page.t(Comment.t())
def list_local_comments(page \\ nil, limit \\ nil) do def list_local_comments(page \\ nil, limit \\ nil) do
Comment Comment
|> where([c], c.visibility == ^:public) |> where([c], c.visibility == ^:public)
@ -238,7 +238,8 @@ defmodule Mobilizon.Discussions do
@doc """ @doc """
Returns the list of public comments for the actor. Returns the list of public comments for the actor.
""" """
@spec list_public_comments_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec list_public_comments_for_actor(Actor.t(), integer | nil, integer | nil) ::
Page.t(Comment.t())
def list_public_comments_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do def list_public_comments_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do
actor_id actor_id
|> public_comments_for_actor_query() |> public_comments_for_actor_query()
@ -263,7 +264,7 @@ defmodule Mobilizon.Discussions do
@doc """ @doc """
Get all the comments contained into a discussion Get all the comments contained into a discussion
""" """
@spec get_comments_for_discussion(integer, integer | nil, integer | nil) :: Page.t() @spec get_comments_for_discussion(integer, integer | nil, integer | nil) :: Page.t(Comment.t())
def get_comments_for_discussion(discussion_id, page \\ nil, limit \\ nil) do def get_comments_for_discussion(discussion_id, page \\ nil, limit \\ nil) do
Comment Comment
|> where([c], c.discussion_id == ^discussion_id) |> where([c], c.discussion_id == ^discussion_id)
@ -326,7 +327,8 @@ defmodule Mobilizon.Discussions do
@doc """ @doc """
Get a paginated list of discussions for a group actor Get a paginated list of discussions for a group actor
""" """
@spec find_discussions_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec find_discussions_for_actor(Actor.t(), integer | nil, integer | nil) ::
Page.t(Discussion.t())
def find_discussions_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do def find_discussions_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do
Discussion Discussion
|> where([c], c.actor_id == ^actor_id) |> where([c], c.actor_id == ^actor_id)

View File

@ -356,7 +356,7 @@ defmodule Mobilizon.Events do
@doc """ @doc """
Returns the list of events. Returns the list of events.
""" """
@spec list_events(integer | nil, integer | nil, atom, atom, boolean) :: Page.t() @spec list_events(integer | nil, integer | nil, atom, atom, boolean) :: Page.t(Event.t())
def list_events( def list_events(
page \\ nil, page \\ nil,
limit \\ nil, limit \\ nil,
@ -410,7 +410,7 @@ defmodule Mobilizon.Events do
@doc """ @doc """
Lists public events for the actor, with all associations loaded. Lists public events for the actor, with all associations loaded.
""" """
@spec list_public_events_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec list_public_events_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t(Event.t())
def list_public_events_for_actor(actor, page \\ nil, limit \\ nil) def list_public_events_for_actor(actor, page \\ nil, limit \\ nil)
def list_public_events_for_actor(%Actor{type: :Group} = group, page, limit), def list_public_events_for_actor(%Actor{type: :Group} = group, page, limit),
@ -521,7 +521,7 @@ defmodule Mobilizon.Events do
@doc """ @doc """
Builds a page struct for events by their name. Builds a page struct for events by their name.
""" """
@spec build_events_for_search(map(), integer | nil, integer | nil) :: Page.t() @spec build_events_for_search(map(), integer | nil, integer | nil) :: Page.t(Event.t())
def build_events_for_search(%{term: term} = args, page \\ nil, limit \\ nil) do def build_events_for_search(%{term: term} = args, page \\ nil, limit \\ nil) do
term term
|> normalize_search_string() |> normalize_search_string()
@ -812,7 +812,7 @@ defmodule Mobilizon.Events do
Default behaviour is to not return :not_approved or :not_confirmed participants Default behaviour is to not return :not_approved or :not_confirmed participants
""" """
@spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) :: @spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) ::
Page.t() Page.t(Participant.t())
def list_participants_for_event( def list_participants_for_event(
id, id,
roles \\ [], roles \\ [],
@ -849,7 +849,7 @@ defmodule Mobilizon.Events do
DateTime.t() | nil, DateTime.t() | nil,
integer | nil, integer | nil,
integer | nil integer | nil
) :: Page.t() ) :: Page.t(Participant.t())
def list_participations_for_user(user_id, after_datetime, before_datetime, page, limit) do def list_participations_for_user(user_id, after_datetime, before_datetime, page, limit) do
user_id user_id
|> list_participations_for_user_query() |> list_participations_for_user_query()
@ -891,7 +891,8 @@ defmodule Mobilizon.Events do
@doc """ @doc """
Returns the list of participations for an actor. Returns the list of participations for an actor.
""" """
@spec list_event_participations_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec list_event_participations_for_actor(Actor.t(), integer | nil, integer | nil) ::
Page.t(Participant.t())
def list_event_participations_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do def list_event_participations_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do
actor_id actor_id
|> event_participations_for_actor_query() |> event_participations_for_actor_query()

View File

@ -12,7 +12,7 @@ defmodule Mobilizon.Events.Tag do
@type t :: %__MODULE__{ @type t :: %__MODULE__{
title: String.t(), title: String.t(),
slug: TitleSlug.Type.t(), slug: String.t(),
related_tags: [t] related_tags: [t]
} }

View File

@ -6,6 +6,16 @@ defmodule Mobilizon.Instances.Instance do
""" """
use Ecto.Schema use Ecto.Schema
@type t :: %__MODULE__{
event_count: non_neg_integer(),
person_count: non_neg_integer(),
group_count: non_neg_integer(),
followers_count: non_neg_integer(),
followings_count: non_neg_integer(),
reports_count: non_neg_integer(),
media_size: non_neg_integer()
}
@primary_key {:domain, :string, []} @primary_key {:domain, :string, []}
schema "instances" do schema "instances" do
field(:event_count, :integer) field(:event_count, :integer)

View File

@ -55,7 +55,7 @@ defmodule Mobilizon.Medias do
@doc """ @doc """
List the paginated media for user List the paginated media for user
""" """
@spec medias_for_user(integer | String.t(), integer | nil, integer | nil) :: Page.t() @spec medias_for_user(integer | String.t(), integer | nil, integer | nil) :: Page.t(Media.t())
def medias_for_user(user_id, page, limit) do def medias_for_user(user_id, page, limit) do
user_id user_id
|> medias_for_user_query() |> medias_for_user_query()

View File

@ -41,14 +41,14 @@ defmodule Mobilizon.Posts do
@doc """ @doc """
Returns the list of recent posts for a group Returns the list of recent posts for a group
""" """
@spec get_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec get_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(Post.t())
def get_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do def get_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do
group_id group_id
|> do_get_posts_for_group() |> do_get_posts_for_group()
|> Page.build_page(page, limit) |> Page.build_page(page, limit)
end end
@spec get_public_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec get_public_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(Post.t())
def get_public_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do def get_public_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do
group_id group_id
|> do_get_posts_for_group() |> do_get_posts_for_group()

View File

@ -18,7 +18,7 @@ defmodule Mobilizon.Resources do
@doc """ @doc """
Returns the list of recent resources for a group Returns the list of recent resources for a group
""" """
@spec get_resources_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec get_resources_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(Resource.t())
def get_resources_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do def get_resources_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do
Resource Resource
|> where(actor_id: ^group_id) |> where(actor_id: ^group_id)
@ -30,7 +30,8 @@ defmodule Mobilizon.Resources do
@doc """ @doc """
Returns the list of resources for a resource folder. Returns the list of resources for a resource folder.
""" """
@spec get_resources_for_folder(Resource.t(), integer | nil, integer | nil) :: Page.t() @spec get_resources_for_folder(Resource.t(), integer | nil, integer | nil) ::
Page.t(Resource.t())
def get_resources_for_folder(resource, page \\ nil, limit \\ nil) def get_resources_for_folder(resource, page \\ nil, limit \\ nil)
def get_resources_for_folder( def get_resources_for_folder(

View File

@ -1,7 +1,5 @@
defmodule Mobilizon.Storage.Repo do defmodule Mobilizon.Storage.Repo do
@moduledoc """ @moduledoc false
Mobilizon Repo.
"""
use Ecto.Repo, use Ecto.Repo,
otp_app: :mobilizon, otp_app: :mobilizon,

View File

@ -22,7 +22,7 @@ defmodule Mobilizon.Todos do
@doc """ @doc """
Returns the list of todo lists for a group. Returns the list of todo lists for a group.
""" """
@spec get_todo_lists_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() @spec get_todo_lists_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(TodoList.t())
def get_todo_lists_for_group(%Actor{id: group_id, type: :Group}, page \\ nil, limit \\ nil) do def get_todo_lists_for_group(%Actor{id: group_id, type: :Group}, page \\ nil, limit \\ nil) do
TodoList TodoList
|> where(actor_id: ^group_id) |> where(actor_id: ^group_id)
@ -34,7 +34,7 @@ defmodule Mobilizon.Todos do
@doc """ @doc """
Returns the list of todos for a group. Returns the list of todos for a group.
""" """
@spec get_todos_for_todo_list(TodoList.t(), integer | nil, integer | nil) :: Page.t() @spec get_todos_for_todo_list(TodoList.t(), integer | nil, integer | nil) :: Page.t(Todo.t())
def get_todos_for_todo_list(%TodoList{id: todo_list_id}, page \\ nil, limit \\ nil) do def get_todos_for_todo_list(%TodoList{id: todo_list_id}, page \\ nil, limit \\ nil) do
Todo Todo
|> where(todo_list_id: ^todo_list_id) |> where(todo_list_id: ^todo_list_id)

View File

@ -358,7 +358,7 @@ defmodule Mobilizon.Users do
Get a paginated list of all of a user's subscriptions Get a paginated list of all of a user's subscriptions
""" """
@spec list_user_push_subscriptions(String.t() | integer(), integer() | nil, integer() | nil) :: @spec list_user_push_subscriptions(String.t() | integer(), integer() | nil, integer() | nil) ::
Page.t() Page.t(PushSubscription.t())
def list_user_push_subscriptions(user_id, page \\ nil, limit \\ nil) do def list_user_push_subscriptions(user_id, page \\ nil, limit \\ nil) do
PushSubscription PushSubscription
|> where([p], p.user_id == ^user_id) |> where([p], p.user_id == ^user_id)

View File

@ -106,7 +106,7 @@ defmodule Mobilizon.Service.Export.Common do
actor |> fetch_identity_participations(limit) |> participations_to_events() actor |> fetch_identity_participations(limit) |> participations_to_events()
end end
@spec fetch_identity_participations(Actor.t(), integer()) :: Page.t() @spec fetch_identity_participations(Actor.t(), integer()) :: Page.t(Participant.t())
defp fetch_identity_participations(%Actor{} = actor, limit) do defp fetch_identity_participations(%Actor{} = actor, limit) do
with %Page{} = page <- Events.list_event_participations_for_actor(actor, 1, limit) do with %Page{} = page <- Events.list_event_participations_for_actor(actor, 1, limit) do
page page

View File

@ -22,6 +22,7 @@ defmodule Mobilizon.Web.Email do
|> put_layout({EmailView, :email}) |> put_layout({EmailView, :email})
end end
@spec add_event_attachment(Swoosh.Email.t(), Event.t()) :: Swoosh.Email.t()
def add_event_attachment(%Swoosh.Email{} = email, %Event{id: event_id}) do def add_event_attachment(%Swoosh.Email{} = email, %Event{id: event_id}) do
with {:ok, %Event{} = event} <- Events.get_event_with_preload(event_id), with {:ok, %Event{} = event} <- Events.get_event_with_preload(event_id),
{:ok, event_ics_data} <- ICalendar.export_event(event) do {:ok, event_ics_data} <- ICalendar.export_event(event) do

View File

@ -90,7 +90,7 @@ defmodule Mobilizon.Web.ActivityPub.ActorView do
| :todos | :todos
| :outbox | :outbox
@spec fetch_collection(collection(), Actor.t(), integer()) :: Page.t() @spec fetch_collection(collection(), Actor.t(), integer()) :: Page.t(Follower.t())
defp fetch_collection(:following, actor, page) do defp fetch_collection(:following, actor, page) do
Actors.build_followings_for_actor(actor, page) Actors.build_followings_for_actor(actor, page)
end end