Skip to content

Commit

Permalink
feat(abbr): overwrite search abbreviation, default to first two chars…
Browse files Browse the repository at this point in the history
… of project name
  • Loading branch information
russmatney committed May 19, 2017
1 parent 080280c commit 6aee91f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion lib/docset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ defmodule ExDash.Docset do
<dict>
<key>CFBundleIdentifier</key> <string>{{CONFIG_PROJECT}}-{{CONFIG_VERSION}}</string>
<key>CFBundleName</key> <string>{{CONFIG_PROJECT}} {{CONFIG_VERSION}}</string>
<key>DocSetPlatformFamily</key> <string>{{CONFIG_PROJECT}}</string>
<key>DocSetPlatformFamily</key> <string>{{CONFIG_PROJECT_ABBREV}}</string>
<key>isDashDocset</key> <true/>
<key>isJavaScriptEnabled</key> <true/>
<key>dashIndexFilePath</key> <string>index.html</string>
Expand All @@ -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
6 changes: 6 additions & 0 deletions lib/mix/tasks/dash.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand Down

0 comments on commit 6aee91f

Please sign in to comment.