ex_docを初めて動かした 2017-12-14

ex_docというドキュメントツールがある

僕は今日初めて動かしたのでメモしておく

雑に書く

前準備

mix new する

mix new ex_doc_sample

やったこと

mix.exs を変える

こう変える

defmodule ExDocSample.Mixfile do
  use Mix.Project

  def project do
    [
      app: :ex_doc_sample,
      version: "0.1.0",
      elixir: "~> 1.5",
      start_permanent: Mix.env == :prod,
      deps: deps(),

      name: "ExDocSample",
      source_url: "https://github.com/kytiken/ex_doc_sample",
      homepage_url: "https://github.com/kytiken/ex_doc_sample",
      docs: [main: "ExDocSample", # The main page in the docs
             logo: "./logo.png",
             extras: ["README.md"]]
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:ex_doc, "~> 0.16", only: :dev, runtime: false}
    ]
  end
end
対象のモジュール

mix new した直後のモジュール

defmodule ExDocSample do
  @moduledoc """
  Documentation for ExDocSample.
  """

  @doc """
  Hello world.

  ## Examples

      iex> ExDocSample.hello
      :world

  """
  def hello do
    :world
  end
end
deps.get
mix deps.get
ドキュメントを生成
mix docs
確認

f:id:kytiken:20171214202149p:plain

できたー

感想

簡単にきれいなドキュメント作れる ex_doc 最高だな

参考URL

github.com