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.
"""
@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
term = String.trim(term)
@ -64,7 +64,7 @@ defmodule Mobilizon.GraphQL.API.Search do
Search events
"""
@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
term = String.trim(term)
@ -100,7 +100,7 @@ defmodule Mobilizon.GraphQL.API.Search do
end
# 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
case ActivityPubActor.find_or_make_actor_from_nickname(search) do
{:ok, %Actor{type: :Group} = actor} ->
@ -118,7 +118,7 @@ defmodule Mobilizon.GraphQL.API.Search do
end
# 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
case ActivityPub.fetch_object_from_url(search) do
{:ok, object} ->

View File

@ -10,7 +10,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Followers do
alias Mobilizon.Storage.Page
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(
%Actor{id: group_id} = group,
args,

View File

@ -357,7 +357,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do
@doc """
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, %{
context: %{current_user: %User{} = user}
}) do
@ -399,7 +400,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do
@doc """
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}, %{
context: %{current_user: %User{} = user}
}) do

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ defmodule Mobilizon.Admin do
@doc """
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
list_action_logs_query()
|> Page.build_page(page, limit)

View File

@ -225,7 +225,7 @@ defmodule Mobilizon.Discussions do
@doc """
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
Comment
|> where([c], c.visibility == ^:public)
@ -238,7 +238,8 @@ defmodule Mobilizon.Discussions do
@doc """
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
actor_id
|> public_comments_for_actor_query()
@ -263,7 +264,7 @@ defmodule Mobilizon.Discussions do
@doc """
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
Comment
|> where([c], c.discussion_id == ^discussion_id)
@ -326,7 +327,8 @@ defmodule Mobilizon.Discussions do
@doc """
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
Discussion
|> where([c], c.actor_id == ^actor_id)

View File

@ -356,7 +356,7 @@ defmodule Mobilizon.Events do
@doc """
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(
page \\ nil,
limit \\ nil,
@ -410,7 +410,7 @@ defmodule Mobilizon.Events do
@doc """
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{type: :Group} = group, page, limit),
@ -521,7 +521,7 @@ defmodule Mobilizon.Events do
@doc """
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
term
|> normalize_search_string()
@ -812,7 +812,7 @@ defmodule Mobilizon.Events do
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) ::
Page.t()
Page.t(Participant.t())
def list_participants_for_event(
id,
roles \\ [],
@ -849,7 +849,7 @@ defmodule Mobilizon.Events do
DateTime.t() | 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
user_id
|> list_participations_for_user_query()
@ -891,7 +891,8 @@ defmodule Mobilizon.Events do
@doc """
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
actor_id
|> event_participations_for_actor_query()

View File

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

View File

@ -6,6 +6,16 @@ defmodule Mobilizon.Instances.Instance do
"""
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, []}
schema "instances" do
field(:event_count, :integer)

View File

@ -55,7 +55,7 @@ defmodule Mobilizon.Medias do
@doc """
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
user_id
|> medias_for_user_query()

View File

@ -41,14 +41,14 @@ defmodule Mobilizon.Posts do
@doc """
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
group_id
|> do_get_posts_for_group()
|> Page.build_page(page, limit)
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
group_id
|> do_get_posts_for_group()

View File

@ -18,7 +18,7 @@ defmodule Mobilizon.Resources do
@doc """
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
Resource
|> where(actor_id: ^group_id)
@ -30,7 +30,8 @@ defmodule Mobilizon.Resources do
@doc """
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(

View File

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

View File

@ -22,7 +22,7 @@ defmodule Mobilizon.Todos do
@doc """
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
TodoList
|> where(actor_id: ^group_id)
@ -34,7 +34,7 @@ defmodule Mobilizon.Todos do
@doc """
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
Todo
|> 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
"""
@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
PushSubscription
|> 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()
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
with %Page{} = page <- Events.list_event_participations_for_actor(actor, 1, limit) do
page

View File

@ -22,6 +22,7 @@ defmodule Mobilizon.Web.Email do
|> put_layout({EmailView, :email})
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
with {:ok, %Event{} = event} <- Events.get_event_with_preload(event_id),
{:ok, event_ics_data} <- ICalendar.export_event(event) do

View File

@ -90,7 +90,7 @@ defmodule Mobilizon.Web.ActivityPub.ActorView do
| :todos
| :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
Actors.build_followings_for_actor(actor, page)
end