Api for atom.io package contents?


#1

I want to write a package to list all keybindings in all published packages. It would help devs like me choose keybindings for a package. It would be almost as good as having a keybinding registry.

Is there an API to retrieve package files without installing? Otherwise, to read all the files I’d have to install each and every package one at a time to read the files. I guess I could do this offline every night and somehow make it available to my users.

I have been saying “files”, but could I count on only looking at the one file in the keymaps folder to find all bindings?

EDIT: I just realized if I had access to just the package.json file I could go to the github repo and download any file there.

EDIT 2: I’m trying to fork apm now and hack it to get what I need. I figure it would be easier to add a command to apm than to reverse engineer the api and code from scratch.


#2

No need to hack apart apm to find the information:

You can get the list of packages, and for each package get the GitHub repository, find the keymaps directory (if it exists) and parse the keymaps. Of course, you’ll probably want to only parse the keymaps on update after the first pass.


#3

Thanks. I didn’t know about atom/docs.


#4

I’ve done all that. There are a zillion keys. I now realize that the majority of keys are very scope specific and will not be interesting to devs working outside that scope. Here are some sample keys showing the range of specificities …

scope: ".autocomplete-plus input.hidden-input", key: "escape",           cmd: "autocomplete-plus:cancel"
scope: ".editor",                               key: "ctrl-shift-space", cmd: "autocomplete-plus:activate"
scope: ".workspace, .workspace .editor",        key: "ctrl-M",           cmd: "markdown-preview:toggle"
scope: ".platform-darwin .markdown-preview",    key: "cmd-+",            cmd: "markdown-preview:zoom-in"
scope: ".platform-darwin .markdown-preview",    key: "cmd-=",            cmd: "markdown-preview:zoom-in"

I think the UI for this tool will need to allow the dev to somehow enter a scope and see the keys for only that scope. I don’t know the actual DOM hierarchy in advance so I don’t see how I can find nested scopes. This means I can’t precisely show what will match. So I will have to come up with something fuzzy?