Slide 1

Slide 1 text

Giving Back Building Your First Elixir Package

Slide 2

Slide 2 text

Generating a new package mix new crazy_pants

Slide 3

Slide 3 text

Generating a new package -> mix new crazy_pants * creating README.md * creating .gitignore * creating mix.exs * creating config * creating config/config.exs * creating lib * creating lib/crazy_pants.ex * creating test * creating test/test_helper.exs * creating test/crazy_pants_test.exs Your Mix project was created successfully. You can use "mix" to compile it, test it, and more: cd crazy_pants mix test Run "mix help" for more commands.

Slide 4

Slide 4 text

Brian Cardarella CEO of DockYard

Slide 5

Slide 5 text

inquisitor mail ecto_fixtures courier Elixir Packages I’ve Written

Slide 6

Slide 6 text

What we’ll cover • Customizing the package • Writing good documentation • Typespecs • Using your package • Distributing • Contributing to Elixir Core

Slide 7

Slide 7 text

Customizing the package -> mix new crazy_pants * creating README.md * creating .gitignore * creating mix.exs * creating config * creating config/config.exs * creating lib * creating lib/crazy_pants.ex * creating test * creating test/test_helper.exs * creating test/crazy_pants_test.exs Your Mix project was created successfully. You can use "mix" to compile it, test it, and more: cd crazy_pants mix test Run "mix help" for more commands.

Slide 8

Slide 8 text

Customizing the package defmodule CrazyPants.Mixfile do use Mix.Project def project do [app: :crazy_pants, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, deps: deps] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do [applications: [:logger]] end # Dependencies can be Hex packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [] end end

Slide 9

Slide 9 text

Customizing the package defmodule CrazyPants.Mixfile do use Mix.Project def project do [app: :crazy_pants, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, package: package(), description: description(), deps: deps] end def package do [maintainers: ["Krazy Kat"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/whodat/crazy_pants"}] end def description do "These pretzels are making me thirsty" end

Slide 10

Slide 10 text

defmodule CrazyPants.Mixfile do use Mix.Project def project do [app: :crazy_pants, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, package: package(), description: description(), deps: deps] end def package do [maintainers: ["Krazy Kat"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/whodat/crazy_pants"}] end def description do "These pretzels are making me thirsty" end Customizing the package

Slide 11

Slide 11 text

Writing good documentation http://elixir-lang.org/docs/stable/elixir/writing-documentation.html

Slide 12

Slide 12 text

Writing good documentation ....CrazyPants.drop(1,2,3) `CrazyPants`

Slide 13

Slide 13 text

Writing good documentation defmodule CrazyPants @moduledoc """ This is the greatest library every written """ @doc """ This is the best function ever written """ def drop(location) do "They're at the #{location}” end end

Slide 14

Slide 14 text

Writing good documentation defp deps do [ {:earmark, "~> 0.1", only: :dev}, {:ex_doc, "~> 0.11", only: :dev} ] end

Slide 15

Slide 15 text

Writing good documentation mix docs

Slide 16

Slide 16 text

Writing good documentation open doc/index.html

Slide 17

Slide 17 text

Writing good documentation

Slide 18

Slide 18 text

Writing good documentation defmodule CrazyPants.Mixfile do use Mix.Project def project do [app: :crazy_pants, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, package: package(), description: description(), deps: deps, docs: [ main: "CrazyPants" ]] end

Slide 19

Slide 19 text

Writing good documentation

Slide 20

Slide 20 text

Writing good documentation

Slide 21

Slide 21 text

Writing good documentation

Slide 22

Slide 22 text

Writing good documentation defmodule CrazyPants.Mixfile do use Mix.Project def project do [app: :crazy_pants, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, package: package(), description: description(), deps: deps, docs: [ main: “CrazyPants”, logo: “crazy_pants.jpg” ]] end

Slide 23

Slide 23 text

Writing good documentation

Slide 24

Slide 24 text

Typespecs

Slide 25

Slide 25 text

Typespecs defmodule CrazyPants do @moduledoc """ This is the greatest library ever written """ @doc """ This is the greatest function ever written """ @spec drop(binary) :: binary def drop(location) do "They're at the #{location}" end end

Slide 26

Slide 26 text

Typespecs

Slide 27

Slide 27 text

Typespecs defmodule CrazyPantsTest do use ExUnit.Case test "using numbers" do assert CrazyPants.number_drop(1) == "They're at the 1" end end ➜ mix test . Finished in 0.02 seconds (0.02s on load, 0.00s on tests) 1 test, 0 failures

Slide 28

Slide 28 text

Typespecs defp deps do [{:earmark, "~> 0.1", only: :dev}, {:ex_doc, "~> 0.11", only: :dev}, {:dialyxir, "~> 0.3.3", only: :dev}] end ➜ mix dialyzer.plt Starting PLT Core Build ... this will take awhile

Slide 29

Slide 29 text

Typespecs ➜ mix dialyzer Compiled lib/crazy_pants.ex Starting Dialyzer crazy_pants.ex:15: The call 'Elixir.CrazyPants':drop(1) breaks the contract (binary()) -> binary() done in 0m0.80s done (warnings were emitted)

Slide 30

Slide 30 text

Typespecs defmodule CrazyPants do @moduledoc """ This is the greatest library ever written """ @doc """ This is the greatest function ever written """ @spec drop(binary) :: binary def drop(location) do "They're at the #{location}" end def num_drop() do drop(1) end end

Slide 31

Slide 31 text

Typespecs defmodule CrazyPants do @moduledoc """ This is the greatest library ever written """ @doc """ This is the greatest function ever written """ @spec drop(binary) :: binary def drop(location) do "They're at the #{location}" end def num_drop() do 1 |> Integer.to_string() |> drop() end end

Slide 32

Slide 32 text

Typespecs ➜ mix dialyzer Compiled lib/crazy_pants.ex Starting Dialyzer Proceeding with analysis... done in 0m0.75s done (passed successfully)

Slide 33

Slide 33 text

Typespecs

Slide 34

Slide 34 text

Using your package defp deps do [{:crazy_pants, path: "/path/to/crazy_pants"}] end

Slide 35

Slide 35 text

Distributing

Slide 36

Slide 36 text

Distributing defmodule CrazyPants.Mixfile do use Mix.Project def project do [app: :crazy_pants, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, package: package(), description: description(), deps: deps, docs: [ main: “CrazyPants”, logo: “crazy_pants.jpg” ]] end

Slide 37

Slide 37 text

Distributing

Slide 38

Slide 38 text

Distributing ➜ git tag v0.0.1 ➜ git push --tags

Slide 39

Slide 39 text

Distributing

Slide 40

Slide 40 text

Distributing ➜ mix hex.publish Publishing crazy_pants 0.0.1 Dependencies: Files: lib/crazy_pants.ex mix.exs README.md App: crazy_pants Name: crazy_pants Description: These pretzels are making me thirsty Version: 0.0.1 Build tools: mix Licenses: MIT Maintainers: Krazy Kat Links: GitHub: https://github.com/whodat/crazy_pants Elixir: ~> 1.2 WARNING! Excluded dependencies (not part of the Hex package): earmark ex_doc dialyxir Before publishing, please read Hex Code of Conduct: https://hex.pm/policies/ codeofconduct Proceed? [Yn]

Slide 41

Slide 41 text

Distributing [#########################] 100% Published at https://hex.pm/packages/crazy_pants/0.0.1 Don't forget to upload your documentation with `mix hex.docs`

Slide 42

Slide 42 text

Distributing ➜ mix hex.docs Docs successfully generated. View them at "doc/index.html". [#########################] 100% Published docs for crazy_pants 0.0.1 Hosted at https://hexdocs.pm/crazy_pants/0.0.1

Slide 43

Slide 43 text

Distributing

Slide 44

Slide 44 text

inquisitor mail ecto_fixtures courier Elixir Packages I’ve Written crazy_pants

Slide 45

Slide 45 text

inquisitor mail ecto_fixtures courier Elixir Packages I’ve Written

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Other places to promote your package • reddit.com/r/elixir • elixir-lang-talk Google Group • phoenix-talk Google Group • https://elixirstatus.com • Elixir Slack • #elixir-lang IRC

Slide 50

Slide 50 text

Other places to promote your package http://www.meetup.com/topics/elixir/

Slide 51

Slide 51 text

Want to build something amazing? dockyard.com Thank you!