LoginSignup
13
13

More than 5 years have passed since last update.

Elixir のライブラリのドキュメントを Dash docset に変換する・暫定版

Last updated at Posted at 2015-08-03

追記:Dash 3.1.1 あたりから Hex Docsets に対応しているので以下は不要。

ExDocDash を使うと Elixir のライブラリのドキュメントを Dash 向けに変換することができる。コマンドで一発というわけにはいかず手作業が必要なので暫定版としておく。

1. ライブラリのソースコードを取得する

ここでは Phoenix を例に取る。 GitHub からリポジトリをクローンする。必要ならドキュメントを生成したいリビジョンをチェックアウトする。

git clone https://github.com/phoenixframework/phoenix
cd phoenix
git checkout v0.15.0  # 必要に応じて

2. mix.exs を書き換える

mix.exs を開き、依存関係に {:ex_doc_dash, "~> 0.0", only: :docs} を追加する。

mix.exs
defmodule Phoenix.Mixfile do
  use Mix.Project
  # ...

  defp deps do
    [{:cowboy, "~> 1.0", optional: true},
     {:plug, ">= 0.13.1 and < 2.0.0"},
     {:poison, "~> 1.3"},

     # Docs dependencies
     {:earmark, "~> 0.1", only: :docs},
     {:ex_doc, "~> 0.7.1", only: :docs},
     {:inch_ex, "~> 0.2", only: :docs},
     {:ex_doc_dash, "~> 0.0", only: :docs},  # これを追加する

     # Test dependencies
     {:phoenix_html, "~> 1.2", only: :test},
     {:websocket_client, github: "jeremyong/websocket_client", only: :test}]
  end

  # ...
end

3. 依存モジュールを取得する

MIX_ENV=docs mix deps.get

ドキュメントに関する依存関係を取得するため MIX_ENV=docs を指定しておく。

4. Dash の docset を生成する

ExDocDash が入っていれば mix docs.dash コマンドが使えるようになる。これを実行すると docset を生成できる。

MIX_ENV=docs mix docs.dash
出力
Compiled lib/mix/tasks/phoenix.routes.ex
Compiled lib/mix/tasks/compile.phoenix.ex
# ...
Generated phoenix app
Docs successfully generated.
Open with the command: open -a Dash "/path/to/phoenix/doc/Phoenix 0.15.0.docset"

生成が完了すると docset を Dash にインストールするコマンドを指示される。指示どおり実行すればインストールできる。

13
13
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13