From 0be54eef661901691c3ee8e37b436659981ee899 Mon Sep 17 00:00:00 2001 From: Rahul Thakare Date: Thu, 21 Mar 2019 01:56:40 +0530 Subject: [PATCH] Added PackageControl to readme and changed config file --- .editorconfig | 13 +++ .gitignore | 1 - README.md | 87 +++++++++++------- imgs/{2019-02-06_23-59-01.png => config.png} | Bin imgs/{2019-02-07_00-27-02.gif => demo.gif} | Bin imgs/{2019-02-07_00-23-15.png => files.png} | Bin ...-02-07_00-24-18.png => usage_advanced.png} | Bin ...19-02-07_00-23-49.png => usage_simple.png} | Bin .../{2019-02-07_00-21-47.png => zeal_app.png} | Bin src/zealous.ini | 43 +++++---- src/zealous.py | 58 ++++++------ 11 files changed, 121 insertions(+), 81 deletions(-) create mode 100644 .editorconfig rename imgs/{2019-02-06_23-59-01.png => config.png} (100%) rename imgs/{2019-02-07_00-27-02.gif => demo.gif} (100%) rename imgs/{2019-02-07_00-23-15.png => files.png} (100%) rename imgs/{2019-02-07_00-24-18.png => usage_advanced.png} (100%) rename imgs/{2019-02-07_00-23-49.png => usage_simple.png} (100%) rename imgs/{2019-02-07_00-21-47.png => zeal_app.png} (100%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9ebe43d --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitignore b/.gitignore index d8c8856..e06fa86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.editorconfig .vscode make.cmd build diff --git a/README.md b/README.md index def0302..92a43cc 100644 --- a/README.md +++ b/README.md @@ -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`. + - 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] @@ -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] @@ -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. @@ -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] @@ -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 diff --git a/imgs/2019-02-06_23-59-01.png b/imgs/config.png similarity index 100% rename from imgs/2019-02-06_23-59-01.png rename to imgs/config.png diff --git a/imgs/2019-02-07_00-27-02.gif b/imgs/demo.gif similarity index 100% rename from imgs/2019-02-07_00-27-02.gif rename to imgs/demo.gif diff --git a/imgs/2019-02-07_00-23-15.png b/imgs/files.png similarity index 100% rename from imgs/2019-02-07_00-23-15.png rename to imgs/files.png diff --git a/imgs/2019-02-07_00-24-18.png b/imgs/usage_advanced.png similarity index 100% rename from imgs/2019-02-07_00-24-18.png rename to imgs/usage_advanced.png diff --git a/imgs/2019-02-07_00-23-49.png b/imgs/usage_simple.png similarity index 100% rename from imgs/2019-02-07_00-23-49.png rename to imgs/usage_simple.png diff --git a/imgs/2019-02-07_00-21-47.png b/imgs/zeal_app.png similarity index 100% rename from imgs/2019-02-07_00-21-47.png rename to imgs/zeal_app.png diff --git a/src/zealous.ini b/src/zealous.ini index da0b448..091bec8 100644 --- a/src/zealous.ini +++ b/src/zealous.ini @@ -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 diff --git a/src/zealous.py b/src/zealous.py index f2cf66b..5b3fbd3 100644 --- a/src/zealous.py +++ b/src/zealous.py @@ -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) @@ -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() @@ -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) @@ -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()