distraction.party/lib/pleroma/docs/generator.ex

74 lines
1.9 KiB
Elixir
Raw Normal View History

2019-08-30 16:14:01 +00:00
defmodule Pleroma.Docs.Generator do
2019-08-30 10:21:48 +00:00
@callback process(keyword()) :: {:ok, String.t()}
@spec process(module(), keyword()) :: {:ok, String.t()}
def process(implementation, descriptions) do
implementation.process(descriptions)
end
2019-08-30 16:14:01 +00:00
@spec uploaders_list() :: [module()]
2019-08-30 10:21:48 +00:00
def uploaders_list do
{:ok, modules} = :application.get_key(:pleroma, :modules)
Enum.filter(modules, fn module ->
name_as_list = Module.split(module)
List.starts_with?(name_as_list, ["Pleroma", "Uploaders"]) and
2019-09-03 06:45:54 +00:00
List.last(name_as_list) != "Uploader"
2019-08-30 10:21:48 +00:00
end)
end
2019-08-30 16:14:01 +00:00
@spec filters_list() :: [module()]
2019-08-30 10:21:48 +00:00
def filters_list do
{:ok, modules} = :application.get_key(:pleroma, :modules)
Enum.filter(modules, fn module ->
name_as_list = Module.split(module)
List.starts_with?(name_as_list, ["Pleroma", "Upload", "Filter"])
end)
end
2019-08-30 16:14:01 +00:00
@spec mrf_list() :: [module()]
2019-08-30 10:21:48 +00:00
def mrf_list do
{:ok, modules} = :application.get_key(:pleroma, :modules)
Enum.filter(modules, fn module ->
name_as_list = Module.split(module)
List.starts_with?(name_as_list, ["Pleroma", "Web", "ActivityPub", "MRF"]) and
length(name_as_list) > 4
end)
end
2019-08-30 16:14:01 +00:00
@spec richmedia_parsers() :: [module()]
2019-08-30 10:21:48 +00:00
def richmedia_parsers do
{:ok, modules} = :application.get_key(:pleroma, :modules)
Enum.filter(modules, fn module ->
name_as_list = Module.split(module)
List.starts_with?(name_as_list, ["Pleroma", "Web", "RichMedia", "Parsers"]) and
length(name_as_list) == 5
end)
end
end
defimpl Jason.Encoder, for: Tuple do
def encode(tuple, opts) do
Jason.Encode.list(Tuple.to_list(tuple), opts)
end
end
defimpl Jason.Encoder, for: [Regex, Function] do
def encode(term, opts) do
Jason.Encode.string(inspect(term), opts)
end
end
defimpl String.Chars, for: Regex do
def to_string(term) do
inspect(term)
end
end