Commit 9d2832db authored by xa's avatar xa

documentation

parent 0e2e22f7
Pipeline #1217 failed
MIX_ENV=dev
export MIX_ENV=dev
variables:
MIX_ENV: "test"
before_script:
tags:
- elixir
before_script:
- mix local.hex --force
- mix deps.get --only test
mix:
tags: [elixir]
test:
script:
- mix test
pages:
script:
- mix docs --output public
artifacts:
paths:
- public
......@@ -17,9 +17,15 @@ defmodule Duration do
alias Duration.Parser
@moduledoc """
Documentation for Duration.
Convenient module to play with ISO 8601:2004 durations and Timex.shift.
"""
@doc """
Loads a `Duration.t`.
"""
@spec new(Duration.t) :: {:ok, Duration.t} | {:error, atom}
@spec new(String.t) :: {:ok, Duration.t} | {:error, atom}
@spec new(list) :: {:ok, Duration.t} | {:error, atom}
def new(%Duration{} = val), do: {:ok, val}
def new(val) when is_binary(val) do
parse(val)
......@@ -35,7 +41,7 @@ defmodule Duration do
end
@doc """
Hello world.
Parse a duration string to a `Duration.t`.
## Examples
......@@ -43,6 +49,7 @@ defmodule Duration do
{:ok, %Duration{seconds: 3}}
"""
@spec parse(String.t) :: {:ok, Duration.t} | {:error, atom}
def parse(value) when is_binary(value) do
case Parser.parse(value) do
{:ok, params, _, _, _, _} ->
......@@ -53,11 +60,11 @@ defmodule Duration do
end
def parse(_) do
{:error}
{:error, :parse_error}
end
@doc """
Converts Duration into Timex.shift_options, wich can be used with Timex
Converts a `Duration.t` into `Timex.shift_options`, wich can be used with `Timex.shift`.
## Examples
......
......@@ -7,7 +7,18 @@ defmodule Duration.MixProject do
version: "0.1.0",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
deps: deps()
deps: deps(),
# Docs
name: "Duration",
source_url: "https://lab.errorist.xyz/elixir/duration",
homepage_url: "https://elixir.errorist.io/duration",
docs: [
main: "Duration", # The main page in the docs
# logo: "path/to/logo.png",
extras: ["README.md"]
]
]
end
......@@ -25,6 +36,7 @@ defmodule Duration.MixProject do
# {:credo, "~> 1.1", only: [:dev, :test], runtime: false},
# {:dialyxir, "~> 1.0.0-rc.6", only: [:dev, :test], runtime: false},
# {:timex, "~> 3.6", only: [:dev, :test], runtime: false}
{:ex_doc, "~> 0.21", only: [:dev, :test], runtime: false},
]
end
end
......@@ -4,11 +4,15 @@
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm"},
"credo": {:hex, :credo, "1.1.2", "02b6422f3e659eb74b05aca3c20c1d8da0119a05ee82577a82e6c2938bf29f81", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.6", "78e97d9c0ff1b5521dd68041193891aebebce52fc3b93463c0a6806874557d7d", [:mix], [{:erlex, "~> 0.2.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm"},
"erlex": {:hex, :erlex, "0.2.4", "23791959df45fe8f01f388c6f7eb733cc361668cbeedd801bf491c55a029917b", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"gettext": {:hex, :gettext, "0.17.0", "abe21542c831887a2b16f4c94556db9c421ab301aee417b7c4fbde7fbdbe01ec", [:mix], [], "hexpm"},
"hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment