-
Notifications
You must be signed in to change notification settings - Fork 28
add support for using existing Dash.app docsets #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
1f9d853
a992bec
a5bac0d
83e2a6f
be94464
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,11 @@ | |
| # If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/` | ||
| # or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`. | ||
| # | ||
| # `DASHT_USE_DASH_APP` | ||
| # Set to "true" to use Dash.app's (MacOS only) docset library. Disables | ||
| # docset management commands (install, remove, update). Also changes the | ||
| # default `DASHT_DOCSETS_DIR` to "~/Library/Application Support/Dash". | ||
| # | ||
| # ## EXIT STATUS | ||
| # | ||
| # 44 | ||
|
|
@@ -67,11 +72,29 @@ | |
| # Written in 2016 by Suraj N. Kurapati <https://github.com/sunaku/dasht> | ||
| # Distributed under the terms of the ISC license (refer to README file). | ||
|
|
||
| : ${DASHT_USE_DASH_APP:=false} | ||
| if $DASHT_USE_DASH_APP; then | ||
| : ${DASHT_DOCSETS_DIR:="/Users/smackesey/Library/Application Support/Dash"} | ||
smackesey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else | ||
| : ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
| fi | ||
|
|
||
| if test $# -gt 0; then | ||
| pattern=$1 | ||
| shift | ||
| fi | ||
|
|
||
| # Ensure any docsets we are accessing from the Dash.app library have had their | ||
| # documents extracted. Dash.app leaves the documents in the tarball by default. | ||
| if $DASHT_USE_DASH_APP; then | ||
| dasht-docsets "$@" | while read docset; do | ||
| root=("$DASHT_DOCSETS_DIR/"*/*"/${docset}.docset") | ||
|
||
| if ! test -d "${root}/Contents/Resources/Documents"; then | ||
| dasht-docsets-extract "$root/Contents/Resources/tarix.tgz" | ||
|
||
| fi | ||
| done | ||
| fi | ||
|
|
||
| count=$(dasht-docsets "$@" | wc -l) | ||
| if test $count -eq 0; then | ||
| # notify user when no docsets are installed so they can go install them | ||
|
|
@@ -80,6 +103,7 @@ if test $count -eq 0; then | |
| fi | ||
|
|
||
| trap 'exit 44' USR1 # exit with a nonzero status when no results are found | ||
|
|
||
smackesey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if ! dasht-query-html "$pattern" "$@"; then | ||
| # notify user when no results are found so they can refine their search | ||
| echo "dasht: '$pattern' not found in $count docsets matching '${*:-.*}'" >&2 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,11 @@ | |
| # If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/` | ||
| # or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`. | ||
| # | ||
| # `DASHT_USE_DASH_APP` | ||
| # Set to "true" to use Dash.app's (MacOS only) docset library. Disables | ||
| # docset management commands (install, remove, update). Also changes the | ||
| # default `DASHT_DOCSETS_DIR` to "~/Library/Application Support/Dash". | ||
| # | ||
| # ## EXIT STATUS | ||
| # | ||
| # 44 | ||
|
|
@@ -86,7 +91,12 @@ | |
| # Written in 2016 by Suraj N. Kurapati <https://github.com/sunaku/dasht> | ||
| # Distributed under the terms of the ISC license (refer to README file). | ||
|
|
||
| : ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
| : ${DASHT_USE_DASH_APP:=false} | ||
| if $DASHT_USE_DASH_APP; then | ||
| : ${DASHT_DOCSETS_DIR:="/Users/smackesey/Library/Application Support/Dash"} | ||
| else | ||
| : ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
| fi | ||
|
|
||
| pattern=$(echo " $1 " | sed -e 's/[%_]/\\&/g' -e 's/[[:space:]]\{1,\}/%/g') | ||
| test $# -gt 0 && shift # shift off PATTERN so argv contains solely DOCSETs | ||
|
|
@@ -95,7 +105,12 @@ status=44 # (default) exit with a nonzero status when no results are found | |
| trap 'status=0' USR1 # override default exit status when results are found | ||
|
|
||
| dasht-docsets "$@" | while read -r docset; do | ||
| database="$DASHT_DOCSETS_DIR/$docset".docset/Contents/Resources/docSet.dsidx | ||
| if $DASHT_USE_DASH_APP; then | ||
| relpath=("$DASHT_DOCSETS_DIR"/*/*/"$docset".docset) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the |
||
| database="$relpath/Contents/Resources/docSet.dsidx" | ||
| else | ||
| database="$DASHT_DOCSETS_DIR/$docset".docset/Contents/Resources/docSet.dsidx | ||
| fi | ||
| file_url="file://$(dirname "$database")/Documents/" | ||
|
|
||
| dasht-query-exec "$pattern" "$database" -line | | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.