Giter Club home page Giter Club logo

dash-docs's Introduction

Dash Docs

Build Status Coverage Status MELPA MELPA Stable Tag Version License

What's it

This package provides an elisp interface to query and show documenation using Dash docsets.

It doesn't require Dash app.

Requirements

  • sqlite3

Installation

It's available on MELPA.

Now, it's possible to choose between install the stable or development version of dash-docs. Here there is an explanation about stable packages and MELPA and here a list of our tags.

m-x package-install dash-docs RET

Installing docsets

Dash-docs uses the same docsets as Dash. You can install them with m-x dash-docs-install-docset for the official docsets or m-x dash-docs-install-user-docset for user contributed docsets (experimental).

To install a docset from a file in your drive you can use m-x dash-docs-install-docset-from-file'. That function takes as input a tgzfile that you obtained, starting from a folder named.docset`, with the command:

tar --exclude='.DS_Store' -cvzf <docset name>.tgz <docset name>.docset

as explained here.

Usage

Search all currently enabled docsets (docsets in dash-docs-docsets or dash-docs-common-docsets):

(dash-docs-search "<pattern>")

Search a specific docset:

(dash-docs-search-docset "<docset>" "<pattern>")

The command dash-docs-reset-connections will clear the connections to all sqlite db's. Use it in case of errors when adding new docsets. The next call to a search function will recreate them.

Variables to customize

dash-docs-docsets-path is the prefix for your docsets. Defaults to ~/.docsets

dash-docs-min-length tells dash-docs from which length to start searching. Defaults to 3.

dash-docs-browser-func is a function to encapsulate the way to browse Dash' docsets. Defaults to browse-url. For example, if you want to use eww to browse your docsets, you can do: (setq dash-docs-browser-func 'eww).

When dash-docs-enable-debugging is non-nil stderr from sqlite queries is captured and displayed in a buffer. The default value is t. Setting this to nil may speed up queries on some machines (capturing stderr requires the creation and deletion of a temporary file for each query).

Sets of Docsets

Common docsets

`dash-docs-common-docsets' is a list that should contain the docsets to be active always. In all buffers.

Buffer local docsets

Different subsets of docsets can be activated depending on the buffer. For the moment (it may change in the future) we decided it's a plain local variable you should setup for every different filetype. This way you can also do fancier things like project-wise docsets sets.

(defun go-doc ()
  (interactive)
  (setq-local dash-docs-docsets '("Go")))

(add-hook 'go-mode-hook 'go-doc)

Only one docset

To narrow the search to just one docset, type its name in the beginning of the search followed by a space. If the docset contains spaces, no problemo, we handle it :D.

use-package integration

If you are using use-package, a :dash keyboard will be added to configure the dash-docs-docsets variable. For example to register the CMake dash documentation with cmake mode:

(use-package cmake-mode
  :dash "CMake")

You can also register multiple docsets:

(use-package cmake-mode
  :dash "CMake" "Foobar")

By default, dash-docs will link the docset to the package name mode hook, you can explicitly set the mode if it is different from the package name:

(use-package my-package
  :dash (my-mode "Docset1" "Docset2"))

And you can register to multiple modes:

(use-package my-package
  :dash (my-mode "Docset1" "Docset2")
        (my-other-mode "Docset3"))

The way it works is by registering a hook to the given mode (<mode-name>-hook) and setting up dash-docs-docsets local variable in that hook.

FAQ

  • Does it work in osX?

sqlite queries. Provisionally, we're executing shell-commands directly. Our idea is come back to use esqlite when some issues will be fixed.

dash-docs has been tested only in linux. We've been notified that it doesn't work in Mac, so we ask for elisp hackers who own something that runs Mac OSX if they could take a look at it.

Hints: It looks like something with 'end of line' differences. The suspicious are esqlite (which dash-docs requires) or pcsv (which esqlite requires)

  • I'm using mac osx and pages open but not in the correct anchor

bug on mac osx's browse-url which can't open urls with #. If you find this issue, and want to debug, great, otherwise, you can use eww or w3 or w3m which will work just fine

  • I get nil for every search I do

make sure you don't have sqlite3 .mode column but .mode list (the default). check your .sqliterc

  • When selecting an item in dash-docs, no browser lookup occurs with firefox >= 38.0.and emacs >= 24.4

try:

(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "/path/to/firefox")
(setq dash-docs-browser-func 'browse-url-generic)

Contribution

We โ™ฅ feedback, issues or pull requests. Feel free to contribute in dash-docs.

We're trying to add tests to the project, if you send a PR please consider add new or update the existing ones.

Install Cask if you haven't already, then:

$ cd /path/to/dash-docs
$ cask

Run all tests with:

$ make

Authors

dash-docs's People

Contributors

agpchil avatar areina avatar aslpavel avatar asmundg avatar coalman avatar davidshepherd7 avatar dickby avatar emacs18 avatar gfzeng avatar gilbertw1 avatar jeeger avatar jfeltz avatar kidd avatar marcelino-m avatar marcinant avatar meditans avatar olymk2 avatar otsaloma avatar otsaw avatar pao avatar purcell avatar sanderson-sfdc avatar sometimesfood avatar stardiviner avatar syohex avatar thomasf avatar tko avatar vspinu avatar xiongtx avatar yasuyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dash-docs's Issues

[Feature Request] Support macOS Dash.app third-part docset locations.

On macOS Dash.app, the default main docsets are downloaded in "/Users/stardiviner/Library/Application Support/Dash/DocSets". But Dash.app also downloaded third-part docsets in other locations:

Cheat Sheets     Data             GitHub           Stack Overflow   library.dash
Clojure DocSets  DocSets          License          User Contributed

Can dash-docs.el make variable dash-docs-docsets-path to be a list of paths for search docsets?

Also getting Installing docset fails with Search failed: "too long"

As in #1

  • 4.19.66-1-MANJARO (up to date linux/arch).
  • emacs 26.2
  • spacemacs develop branch, + packages, all up to date

dash-docs-docsets-path, helm-dash-docsets-path, helm-dash-docset-newpath
all set to ~/.docsets

I did a couple quick runs through dash-docs-extract-and-get-folder, but then I'm not sure what to look for.

Handle "tarix" docsets?

I've only recently started using Dash, so I don't know if this is something new or not, but I've noticed several docsets that have compressed content. For example, if you explore the Python 3 docset, you find this in the Contents/Resources directory:

-rw-r--r-- 1 ndw staff 3.7M Apr 18 07:06 docSet.dsidx
-rw-r--r-- 1 ndw staff  32K Apr 18 07:06 docSet.dsidx-shm
-rw-r--r-- 1 ndw staff 3.7M Apr 18 07:06 docSet.dsidx-wal
-rw-r--r-- 1 ndw staff  14M Apr 18 07:06 tarix.tgz
-rw-r--r-- 1 ndw staff 212K Feb 27 09:40 tarixIndex.db

Unsurprisingly, perhaps, dash-docs doesn't appear to be able to use those.

On a more positive note, dash-docs on MacOS with Emacs 27 seems to work just fine.

`dash-docs-search` fails with `cannot open "''"`

Context: Gentoo, Emacs 28.3, dash-docs-20210830.926, sqlite3 version 3.41.2 2023-03-22

dash-docs-search fails with the error cannot open "''" unless the dash-docs-sql function is modified such that the line:

"-list" "-init" "''" db-path sql)

is replaced by

"-list" db-path sql)

Update usage documentation

With the "Rust" docset installed, (dash-docs--run-query "Rust" "String::new") errors with Wrong type argument: listp, "Rust", and (dash-docs-search "String::new") returns nil. When I edebug dash-docs-search, (dash-docs-maybe-narrow-docsets pattern) returns nil, which seems to cause the search to exit early. This seems to be because there are no open "database connections".

Missing MELPA stable package

Any plans to add the package to melpa stable?

The README says it's possible to install from stable but it isn't? There is not release/tags yet (looks like copy/pasted from helm-dash)

It's available on MELPA.

Now, it's possible to choose between install the stable or development version of dash-docs. Here there is an explanation about stable packages and MELPA and here a list of our tags.

m-x package-install dash-docs RET

Also, thanks for allowing using dash without pulling the helm dependencies!

`Error: in prepare, near "/": syntax error` when calling `dash-docs-search`

Keep running into this whenever I try to run a query via

Example:

----------------
 HEY! This is dash-docs (sqlite) error logging. If you want to disable it, set `dash-docs-enable-debugging` to nil
---------------- 


Error: in prepare, near "/": syntax error
  /Users/gopar/Library/Application Support/Dash/DocSets/Python_2/Python 2.docset
  ^--- error here

Error: in prepare, near "/": syntax error
  /Users/gopar/Library/Application Support/Dash/DocSets/Flask/Flask.docset/Conte
  ^--- error here


Any ideas? Thanks!

[FR] Better search

It would be very convenient if dash-docs supported stronger search engines, such as ugrep --bool (a kind of regex with space acting as AND), or fzf --filter. The current search requires typing things very precisely.

JSON readtable error if github returns 403 forbidden

when url-user-agent is nil, dash-docs-install-docset gives the error:

dash-docs-read-json-from-url: JSON readtable error: 82

As github is returning 403 forbidden for requests that don't contain a user agent. Maybe in dash-docs-read-json-from-url we could locally set url-user-agent to 'default if it's nil. Or else return a more descriptive error message it fails to get the url with 403 forbidden rather than a json parse error.

logo?

Hey @gilbertw1, I created this very simple logo of dash-docs-el. Wanted to add it to the org, but I don't have the rights to change it.

Could you add it? or give the the permissions and I'll do it when I have a minute.

Thanks!

dash-docs-el

Not working with Emacs 26.2?

I recently upgraded Emacs to version 26.2 and dash-docs stopped working. In particular dash-docs-search always returns nil.

I have tried adding a .mode list line to ~/.sqliterc as well as removing this file altogether. Any ideas?

Installing docset fails with Search failed: "too long"

I used the counsel-dash-install-docset with I understand is just an alias to dash-docs-install-docset to install Emacs_Lisp and it does fail with the following error:

Contacting host: api.github.com:443
Contacting host: raw.github.com:443
Wrote /tmp/Emacs_Lisp-feed.xml
Wrote /tmp/Emacs_Lisp-docset.tgz
dash-docs-extract-and-get-folder: Search failed: "too long"

I checked and it does download the docset, but then it never installs it. Do you know what might go wrong? I use the following configuration:

(use-package counsel-dash
  :commands counsel-dash counsel-dash-install-docset
  :hook
  (emacs-lisp-mode-hook . (lambda () (setq-local counsel-dash-docsets '("Emacs Lisp"))))
  :custom
  (counsel-dash-docsets-path "~/.config/dash-docset"))

EDIT: the same happens when I try to install the downloaded tgz using counsel-dash-install-docset-from-file.

Support for Windows

Dash-docs doesn't work correctly on Windows, most likely due to how external commands are handled and syntax. When looking up a symbol with helm-dash for example, dash-docs will correctly find the docset that includes that symbol, but clicking enter will open a dash-docs-errors buffer with

----------------
 HEY! This is dash-docs (sqlite) error logging. If you want to disable it, set `dash-docs-enable-debugging` to nil
---------------- 



cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

cannot open: "''"

(There is a ^L between every line)

And the message helm-M-x-execute-command: ShellExecute failed: The system cannot find the file specified.

I've made sure I'm using windows-version of sqlite3.

I'm assuming it's related to call-process in

(defun dash-docs-sql (db-path sql)
  "Run in the db located at DB-PATH the SQL command and parse the results.
If there are errors, print them in `dash-docs-debugging-buffer'"
  (dash-docs-parse-sql-results
   (with-output-to-string
     (let ((error-file (when dash-docs-enable-debugging
                         (make-temp-file "dash-docs-errors-file"))))
       (call-process "sqlite3" nil (list standard-output error-file) nil
                     ;; args for sqlite3:
                     "-list" "-init" "''" db-path sql)
...

Docset path not correctly constructed

It seems for some docset, like Python_3, the install path is <docsets-path>/Python 3 where the underscore has been replaced by a space, is this the case for all docsets ? I look at the json and XML but there's does not seem to be any mapping between the XML file name we use for the docset name and the extracted path. Maybe we should replace the _ from the docset name ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.