-
Notifications
You must be signed in to change notification settings - Fork 2
/
mix.exs
119 lines (107 loc) · 3.13 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
defmodule Crux.Rest.MixProject do
use Mix.Project
@vsn "0.3.0-dev"
@name :crux_rest
def project do
[
start_permanent: Mix.env() == :prod,
package: package(),
app: @name,
version: @vsn,
elixir: "~> 1.10",
description: "Package providing rest functions and rate limiting for the Discord API",
source_url: "https://github.com/SpaceEEC/#{@name}/",
homepage_url: "https://github.com/SpaceEEC/#{@name}/",
deps: deps(),
aliases: aliases(),
docs: docs()
]
end
def package do
[
name: @name,
licenses: ["MIT"],
maintainers: ["SpaceEEC"],
links: %{
"GitHub" => "https://github.com/SpaceEEC/#{@name}/",
"Changelog" => "https://github.com/SpaceEEC/#{@name}/releases/tag/#{@vsn}",
"Documentation" => "https://hexdocs.pm/#{@name}/#{@vsn}",
"Unified Development Documentation" => "https://crux.randomly.space/"
}
]
end
def application do
[extra_applications: [:logger]]
end
defp deps do
[
# {:crux_structs, "~> 0.3"},
{:crux_structs, github: "spaceeec/crux_structs"},
{:httpoison, "~> 1.8"},
{:jason, "~> 1.2"},
{:ex_doc, "~> 0.25", only: :dev, runtime: false},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:mox, "~> 1.0", only: :test}
]
end
defp aliases() do
[
docs: ["docs", &generate_config/1]
]
end
defp docs() do
groups = [
"Application Commands": &(&1[:section] == :application_commands),
User: &(&1[:section] == :user),
Channel: &(&1[:section] == :channel),
Message: &(&1[:section] == :message),
Reaction: &(&1[:section] == :reaction),
Guild: &(&1[:section] == :guild),
Member: &(&1[:section] == :member),
Role: &(&1[:section] == :role),
Ban: &(&1[:section] == :ban),
Invite: &(&1[:section] == :invite),
Template: &(&1[:section] == :template),
Emoji: &(&1[:section] == :emoji),
Integration: &(&1[:section] == :integration),
Webhook: &(&1[:section] == :webhook),
Voice: &(&1[:section] == :voice),
Gateway: &(&1[:section] == :gateway),
OAuth2: &(&1[:section] == :oauth2)
]
[
groups_for_functions: groups,
markdown_processor_options: [breaks: true],
formatter: "html",
# To make these very long function names readable
# Comes at the cost of having a variable width sidebar
before_closing_head_tag: fn :html ->
"""
<style>
.sidebar {
width: unset;
min-width: 300px;
}
</style>
"""
end
]
end
def generate_config(_) do
config =
System.cmd("git", ["tag"])
|> elem(0)
|> String.split("\n")
|> Enum.slice(0..-2)
|> Enum.map(&%{"url" => "https://hexdocs.pm/#{@name}/" <> &1, "version" => &1})
|> Enum.reverse()
|> Jason.encode!()
config = "var versionNodes = " <> config
__DIR__
|> Path.split()
|> Kernel.++(["doc", "docs_config.js"])
|> Enum.join("/")
|> File.write!(config)
Mix.Shell.IO.info(~S{Generated "doc/docs_config.js".})
end
end