Skip to content

Commit

Permalink
Added PackageControl to readme and changed config file
Browse files Browse the repository at this point in the history
  • Loading branch information
bantya committed Mar 20, 2019
1 parent 7e7d1bc commit 0be54ee
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 81 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,rst,txt}]
indent_size = 2
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.editorconfig
.vscode
make.cmd
build
87 changes: 54 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,62 @@ This is Zealous, a plugin for the

This plugin is developed to facilitate the offline documentation search using the awesome Zeal app.

| ![Zealous usage](./imgs/2019-02-07_00-27-02.gif "Zealous usage") |
| ![Zealous usage](./imgs/demo.gif "Zealous usage") |
| :-: |
| *Zealous Usage* |
| *Zealous demo* |


## Background

[Zeal](https://zealdocs.org) is one of the best offline documentation search tool available today. Its docsets are made available by [Dash](https://kapeli.com).

| ![Zeal App](./imgs/2019-02-07_00-21-47.png "Zeal App") |
| ![Zeal App](./imgs/zeal_app.png "Zeal App") |
| :-: |
| *Zeal App for Windows* |

It provides the ability to install docsets for almost all of the mainstream languages, tools, toolsets and everything that can have its own docset. It can filter the results as per the result type (highlighted above 👆).

## Install

## Download
There are two ways to install:

Download the latest plugin file from [here](https://github.com/bantya/Keypirinha-Zealous/releases).
1. Using **[PackageControl](https://github.com/ueffel/Keypirinha-PackageControl)**:

- Invoke Keypirinha and type `install package`.
- Click enter.
- Now search for package `Keypirinha-Command`.

This comment has been minimized.

Copy link
@ueffel

ueffel Mar 21, 2019

"Keypirinha-Command" wrong repo, huh? :)

This comment has been minimized.

Copy link
@bantya

bantya Mar 26, 2019

Author Owner

Thanks for the tip. Corrected it.
Hence proved, late night coding sucks!
😉

- Again press enter.

## Install
2. Manual:

Download the latest plugin file from [here](https://github.com/bantya/Keypirinha-Zealous/releases/latest).

Once the `Command.keypirinha-package` file is downloaded, move it to the `InstalledPackage` folder located at:

Once the `Zealous.keypirinha-package` file is downloaded,
move it to the `InstalledPackage` folder located at:
- `Keypirinha\portable\Profile\InstalledPackages` in **Portable mode**
- **Or** `%APPDATA%\Keypirinha\InstalledPackages` in **Installed mode** (the
final path would look like
`C:\Users\%USERNAME%\AppData\Roaming\Keypirinha\InstalledPackages`)

* `Keypirinha\portable\Profile\InstalledPackages` in **Portable mode**
* **Or** `%APPDATA%\Keypirinha\InstalledPackages` in **Installed mode** (the
final path would look like
`C:\Users\%USERNAME%\AppData\Roaming\Keypirinha\InstalledPackages`)
**NOTE:** You may have to manually restart Keypirinha to see the package activated.


## Configuration

1. Open the Zealous config file.

| ![Keypirinha configuration](./imgs/2019-02-06_23-59-01.png "Keypirinha configuration") |
| ![Keypirinha configuration](./imgs/config.png "Keypirinha configuration") |
| :-: |
| *Zealous configuration settings.* |
| *Zealous configuration menu* |

2. The **main** section is necessary if you installed the Zeal to non-default location. You will have to provide the **Zeal install path** and **the docsets path** in this case.

The **result** is the count of how many entries to be fetched from the Zeal docsets. **Default: 50**

3. Add the entries to the **docs** section.
* The syntax for the **docs** entry should be:

- The syntax for the **docs** entry should be:

```
[Docset mnemonic] = [The zeal docset search phrase]
Expand All @@ -69,7 +79,8 @@ move it to the `InstalledPackage` folder located at:

The types can be found [here](https://kapeli.com/docsets#supportedentrytypes).

* The syntax for the **types** entry should be:
- The syntax for the **types** entry should be:

```
[Type mnemonic] = [The zeal docset types]
Expand All @@ -81,9 +92,10 @@ move it to the `InstalledPackage` folder located at:
key = Keyword
```

* There are some quirks. Some dataset entrytype (as Zeal calls it) are not as exact as the specified in [here](https://kapeli.com/docsets#supportedentrytypes).
- There are some quirks. Some dataset entrytype (as Zeal calls it) are not as exact as the specified in [here](https://kapeli.com/docsets#supportedentrytypes).

Especially, **php** along with some other docsets, does not follow the rule. So to make it play even with such docsets, we have to add the supported non-exact result types also.

```
e.g.
Expand All @@ -94,16 +106,19 @@ move it to the `InstalledPackage` folder located at:
t = Type,tdef
mc = Macro,macro
```
* All the fields in the above syntax are REQUIRED.

| ![Zealous config file](./imgs/2019-02-07_00-23-15.png "Zealous config file") |
- All the fields in the above syntax are REQUIRED.

| ![Zealous config file](./imgs/files.png "Zealous config file") |
| :-: |
| *Zealous config file.* |
| *Zealous configuration files* |

## Usage

Invoke Keypirinha and put the terms as follows.
* The syntax for the usage should be:

- The syntax for the usage should be:

```
[Docset mnemonic] [Result type]? [Search term]
Expand All @@ -113,34 +128,40 @@ Invoke Keypirinha and put the terms as follows.
ld g auth -> searches 'auth' of 'Guide' type in Laravel docset
js key ...obj -> searches '...obj' of 'Keyword' type in Javascipt docset
```
* Though the usage of [Result type] is optional, using it filters the results only to that type.

| ![Zealous simple search](./imgs/2019-02-07_00-23-49.png "Zealous simple search") |
| ![Zealous simple search](./imgs/usage_simple.png "Zealous simple search") |
| :-: |
| *Simple search.* |
| *Zealous simple usage.* |

| ![Zealous simple search](./imgs/2019-02-07_00-24-18.png "Zealous simple search") |
- Though the usage of [Result type] is optional, using it filters the results only to that type.

| ![Zealous simple search](./imgs/usage_advanced.png "Zealous simple search") |
| :-: |
| *Advanced search with type provided.* |
| *Zealous advanced usage with type provided.* |


## Change Log

### v1.0.1

- Added PackageControl section in README.
- Updated config file.

### v1.0.0

* Bumped version to v1.0.0
* Full working release.
* Added advanced searching ability.
* Updated the README.
- Bumped version to v1.0.0
- Full working release.
- Added advanced searching ability.
- Updated the README.

### v0.0.2 (Unreleased)

* Added docset db search.
* Added simple searching.
- Added docset db search.
- Added simple searching.

### v0.0.1 (Unreleased)

* First working draft
- First working draft


## License
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
43 changes: 25 additions & 18 deletions src/zealous.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,45 @@

[main]
# Plugin's main configuration section
# path
# The path to the zeal executable
# default = "C:\Program Files\Zeal"
#
# docset_path
# The zeal docsets path
# default = "C:\Users\USERNAME\AppData\Local\Zeal\Zeal\docsets"
# * path
# The path to the zeal executable.
# Default = "C:\Program Files\Zeal"
#
# results
# The total results count
# default = 50
# * docset_path
# The zeal docsets path.
# Default = "C:\Users\USERNAME\AppData\Local\Zeal\Zeal\docsets"
#
# * results
# The total results count.
# Default = 50

[docs]
# The zeal docs list
#
# Syntax
# keyword = zeal doc name
# Syntax:
# [distinct keyword] = [zeal doc name]
#
# Examples:
# ap = apache
# ng = nginx
#
# e.g.
# ap = apache
# ng = nginx
# Note:
# A space around equal sign (=) is NOT required.

[types]
# The entry types list
# Check here for reference: https://kapeli.com/docsets#supportedentrytypes
#
# Syntax:
# keyword = entry type
# [distinct keyword] = [entry type]
#
# Examples:
# g = guide
# f = functions
#
# e.g.
# g = guide
# f = functions
# Note:
# A space around equal sign (=) is NOT required.

[var]
# As in every Keypirinha's configuration file, you may optionally include a
Expand Down
58 changes: 29 additions & 29 deletions src/zealous.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ def on_start(self):
def on_catalog(self):
self.on_start()

def on_activated(self):
print('----------')

def on_deactivated(self):
print('----------')

def on_suggest(self, user_input, items_chain):
suggestions = []
input = re.search(self.REGEX_INPUT, user_input)
Expand Down Expand Up @@ -102,6 +96,35 @@ def on_suggest(self, user_input, items_chain):

self.set_suggestions(suggestions)

def on_execute(self, item, action):
if item.category() != self.ITEM_CAT:
return

zeal_exe = self.settings.get_stripped('path', self.SECTION_MAIN, 'C:\\Program Files\\Zeal')

if not 'zeal.exe' in zeal_exe:
zeal_exe = os.path.join(zeal_exe, 'zeal.exe')

if os.path.isfile(zeal_exe):
try:
cmd = [zeal_exe]
cmd.append(item.target())
subprocess.Popen(cmd, cwd = os.path.dirname(zeal_exe))
except Exception as e:
print('Exception: Zeal - (%s)' % (e))
else:
print('Error: Could not find your %s executable.\n\nPlease edit path' % (zeal_exe))

def on_activated(self):
print('----------')

def on_deactivated(self):
print('----------')

def on_events(self, flags):
if flags & kp.Events.PACKCONFIG:
self.on_start()

def _get_docset_folder(self, key):
data = self._read_json()

Expand Down Expand Up @@ -189,25 +212,6 @@ def _set_error(self, msg):
)
]

def on_execute(self, item, action):
if item.category() != self.ITEM_CAT:
return

zeal_exe = self.settings.get_stripped('path', self.SECTION_MAIN, 'C:\\Program Files\\Zeal')

if not 'zeal.exe' in zeal_exe:
zeal_exe = os.path.join(zeal_exe, 'zeal.exe')

if os.path.isfile(zeal_exe):
try:
cmd = [zeal_exe]
cmd.append(item.target())
subprocess.Popen(cmd, cwd = os.path.dirname(zeal_exe))
except Exception as e:
self.dbg("Zeal - (%s)" % (e))
else:
self.err('Could not find your %s executable.\n\nPlease edit path' % (zeal_exe))

def _gather_docs(self):
self.docs = self.load_settings().keys(self.SECTION_DOCS)

Expand All @@ -216,7 +220,3 @@ def _gather_types(self):

def _load_settings(self):
self.settings = self.load_settings()

def on_events(self, flags):
if flags & kp.Events.PACKCONFIG:
self.on_start()

0 comments on commit 0be54ee

Please sign in to comment.