dash-docs-el / helm-dash

Browse Dash docsets inside emacs
510 stars 59 forks source link

Ignore 'strange' docset types gracefully #15

Closed kidd closed 10 years ago

kidd commented 10 years ago

Now, if there are 3 active docsets and 1 of them has an unsupported format (css) everything blows up.

We should just disable it, keep calm, and carry on

agpchil commented 10 years ago

How can I know if a docset is supported by helm-dash or not? I had this issue with a few docsets and its quite annoying.

kidd commented 10 years ago

if the sqlite db has a table called searchIndex I'd say it's enough to know it's supported.

so something like '.schema' to the sqlite connection and regex match

areina commented 10 years ago

Yesterday I was talking with @Kapeli about this. There are two types of docsets: Dash docsets and Apple ones. The apple format is more complex but we must support both.

Kapeli commented 10 years ago

Quite a few of the docsets that come with Dash are Apple ones. These are the docsets that were made before I decided to stop making docsets using Apple's insane format.

As I told @areina, I am currently in no position to help (my Mac is broken), but if you can wait until next week I'll have a look over your code and provide equivalent SQL queries for the Apple docsets.

If you decide to do it on your own, the equivalent of the "searchIndex" table is the "ZTOKEN" table. Not everything is inside ZTOKEN however, so you'll have to look into ZTOKENMETAINFORMATION and ZFILE (or something like that).

In terms of determining if a docset is Dash-style or Apple, you have these options:

  1. Check the schema, as previously suggested
  2. Check the Info.plist file, if it has "isDashDocset" set to YES then it's a Dash docset. This is how Dash differentiates between Dash/Apple docsets.
  3. Just run the queries assuming that all docsets are Dash, if those queries error out, re-run the equivalent Apple queries. I'm not sure how nice this option will work, so you might want to stay away from it.
Kapeli commented 10 years ago

Ok so I see that the query you run is at https://github.com/areina/helm-dash/blob/master/helm-dash.el#L205.

The equivalent query for that in an Apple docset would be:

SELECT ty.ZTYPENAME,
       t.ZTOKENNAME,
       f.ZPATH,
       m.ZANCHOR
  FROM ZTOKEN t,
       ZTOKENTYPE ty,
       ZFILEPATH f,
       ZTOKENMETAINFORMATION m
 WHERE t.ZTOKENNAME LIKE .......
   AND ty.Z_PK = t.ZTOKENTYPE
   AND f.Z_PK = m.ZFILE
   AND m.ZTOKEN = t.Z_PK
ORDER BY LOWER(t.ZTOKENNAME)

Note the m.ZANCHOR. Apple docsets don't store the anchor inside the path like Dash docsets, so you have to combine the two.

areina commented 10 years ago

hey @Kapeli thank you very much!