Skip to content
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

API: Installed docsets #400

Open
trollixx opened this issue Sep 10, 2015 · 9 comments
Open

API: Installed docsets #400

trollixx opened this issue Sep 10, 2015 · 9 comments

Comments

@trollixx
Copy link
Member

Several requests (#368, #371 and #375) have been submitted about providing a way to retrieve the list of installed docsets.

I do not consider CLI a reliable, and portable interface, so a better alternative is wanted here.

@Kwaadpepper
Copy link

Well other ways left are socket or dBus isn't it ?

@trollixx
Copy link
Member Author

D-Bus almost does not exist outside of *nix world (I am aware about Windows ports).

A local socket might be the best option. Zeal already creates one for the single instance mode and handling custom URL schemes. It shouldn't be hard to utilise it for other purposes.

@Kwaadpepper
Copy link

I just read the code so:

src/main.cpp -> if socket is open -> send query and quit program
src/core/application.cpp -> server listening on socket -> query and bring to front

It could evolve in this way:

prefix=somebytestatic (like shebang or binary prefixing for format)

src/main.cpp -> if socket is open -> send query and quit program (no change)

src/core/application.cpp ->
    server listening on socket ->
        if received prefix+query
            -> query and return json to socket
        else
            -> query and bring to front

Of course there would be a need to include a jsonlib.

Also although i understand the c++ zeal code, i don't actually know the detailed characteristic of the socket just a name "ZealLocalServer". Meaning the address and port so i could connect trough with nodejs or vala for my use case.

EDIT:
I am thinking that using QLocalserver would force people to use Qt or have the language a compatibility to import qtlib (like python does, but vala does not). So using a socket would make the code more complicated since it would have to be replace to have a new tread listening on the socket. So the socket could be more Zeal specific by making use of QTcpSocket instead.

EDIT2:
Just saw bool QTcpServer::listen(const QHostAddress &address, quint16 port) in http://code.qt.io/cgit/qt/qtbase.git/tree/src/network/socket/qtcpserver.cpp line 267, this would be more portable am i wrong ?

@trollixx
Copy link
Member Author

QLocalServer is just a thin wrapper on top of Unix local socket or Windows named pipe. So, there's nothing Qt-specific with it. For Vala the only difference is use of GUnixSocketAddress instead of GInetSocketAddress. For Node.js simply call net.connect() with a socket name as the first argument.

Some sort of JSON interface should be fine. It's pretty easy to detect whether payload contains JSON or something else. I am not sure there's much sense in implementing a binary protocol.

@Kwaadpepper
Copy link

Well the bin protocol is just proposal to make changes simplier.
Otherwise i guess it just have to make another QLocalserver parsing query and outputing json right ?

Edit:
Json output could be like

{
    'results':  {
        'php': ['constants','Constants','apc_define_constants'],
        'mysql': ['1204 ER_SETCONSTANT_ONLY']
        '...'
    }
}

Knowing that we can launch zeal with dash:// or from cli this will give all to abilities to make use of zeal by another program. (launching either dash://php:constants or just dash://constants)

Also i'm not sure if you will be glad for this but since there is a button "Open URL" it could give the url like

 'php': {'constants': 'file:///home/kwaadpepper/.local/share/Zeal/Zeal/docsets/PHP.docset/Contents/Resources/Documents/php.net/manual/en/function.constant.html'},

That way complete page info could be easily embed from results

EDIT2:
I was missing #368 and #371 but to solve these quick solution is to list all docsets in results and somehow maybe allowing to make blank search:

{
    'results':  {
        'php': [],
        'mysql': [],
        ...
    }
}

So even if there is no results in a docset it would be sent but with empty array. This would keep things simple as possible.

@gleber
Copy link

gleber commented Dec 5, 2015

I'd love to see the same API provided via stdin/stdout when called with "zeal --api". This would allow to easily integrate it with various scripts (in my case it's my dotfiles bootstrap script, which ensures that I have all necessary development environment)

@ManuelSchneid3r
Copy link

ManuelSchneid3r commented Mar 20, 2018

Hi I am the author of albert launcher. I think this api wrapped in an albert extension would be the absolute killer workflow. Unfortunately I dont use zeal anymore because using the launcher to google is simply faster. However I like the idea of a dedicated app for documentation and I really would like to use Zeal through albert.

Please give this issue some priority.

@trollixx trollixx added this to the 1.0.0 milestone Mar 20, 2018
@trollixx
Copy link
Member Author

This is something I'd like to address with the new backend, which is currently in works.

@jxsl13
Copy link

jxsl13 commented Nov 19, 2020

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants