diff --git a/README.md b/README.md index df96143..1166809 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,11 @@ Options: - `--name`: Overwrite the project name when naming the docset. The name defaults to the project name, or for umbrella apps, the name of the directory. +- `--abbr`: Overwrite the abbreviation for searching the docs. + Defaults to the first two characters of the project name. + Note that changing the abbreviation of the app requires + deleting the docset entirely from Dash (via the preferneces pane) + and likely running `mix docs.dash --open` to force the docset to re-index. # Hacking ExDocs into Dash Docs diff --git a/lib/docset.ex b/lib/docset.ex index 24ba97c..986c407 100644 --- a/lib/docset.ex +++ b/lib/docset.ex @@ -120,7 +120,7 @@ defmodule ExDash.Docset do CFBundleIdentifier {{CONFIG_PROJECT}}-{{CONFIG_VERSION}} CFBundleName {{CONFIG_PROJECT}} {{CONFIG_VERSION}} - DocSetPlatformFamily {{CONFIG_PROJECT}} + DocSetPlatformFamily {{CONFIG_PROJECT_ABBREV}} isDashDocset isJavaScriptEnabled dashIndexFilePath index.html @@ -138,9 +138,19 @@ defmodule ExDash.Docset do version end + abbreviation = + case Store.get(:abbreviation) do + nil -> + name |> String.slice(0, 2) + + abbr -> + abbr + end + @info_plist_template |> String.replace("{{CONFIG_PROJECT}}", name) |> String.replace("{{CONFIG_VERSION}}", version) + |> String.replace("{{CONFIG_PROJECT_ABBREV}}", abbreviation) end end diff --git a/lib/mix/tasks/dash.ex b/lib/mix/tasks/dash.ex index 6110bc2..76f57f3 100644 --- a/lib/mix/tasks/dash.ex +++ b/lib/mix/tasks/dash.ex @@ -19,6 +19,8 @@ defmodule Mix.Tasks.Docs.Dash do Defaults to true unless the docset exists in the `/doc` dir before the run. * `--name NAME`: names the docset something other than the app name. Defaults to the project name, or (if an umbrella app) the `cwd` of the mix task + * `--abbr ABBREVIATION`: the default abbreviation to search for your docs with. + Default: first two characters of the project name. (i.e. `ex` for `ex_dash`). """ @spec run(args) :: String.t @@ -29,9 +31,13 @@ defmodule Mix.Tasks.Docs.Dash do name = Keyword.get(opts, :name) + abbr = + Keyword.get(opts, :abbr) + Store.start_link() Store.set(:name, name) + Store.set(:abbreviation, abbr) [doc_set_path] = Docs.run(["-f", ExDash])