haddock icon indicating copy to clipboard operation
haddock copied to clipboard

Enable quickjump for local documentation

Open gbaz opened this issue 6 years ago • 8 comments

As I suggested here: https://github.com/haskell/cabal/pull/5236#issuecomment-376610195

We can get around xhr limitations by loading the data locally with a tag instead or the like, which lets us keep the benefits of the separate file approach while also allowing local usage. For hackage, producing a json file is still better though, so maybe we can have a flag that is toggled? Or maybe there's a single "best of both worlds" solution with a little cleverness... hmm...

gbaz avatar Mar 31 '18 00:03 gbaz

@gbaz Isn't this fixed? I seem to be successfully generating and using local docs with quickjump.

If it isn't fixed, could you perhaps add some repro instructions?

harpocrates avatar Jan 02 '19 16:01 harpocrates

@harpocrates The problem only occurs when using file:// URIs to view local documentation, since in that case it is not possible for the documentation page to access other resources with file:// URIs (since that would allow a webpage to read all your files). I guess you are using an HTTP server that is running on your machine?

timjb avatar Jan 30 '19 12:01 timjb

Nope, I'm not running an HTTP server. Proof this works with file://:

screen shot 2019-01-30 at 8 46 38 am

On closer inspection: this must be a recent Firefox feature, since Chrome still fails: "Failed to load file 'doc-index'...". If so, it is a welcome feature!

harpocrates avatar Jan 30 '19 16:01 harpocrates

@harpocrates Okay, that's interesting. I've found the relevant page on MDN documenting the same-origin policy of Firefox for file URIs. It basically allows pages to access files in the same directory and subdirectories. This policy has been in place since Gecko 1.9, which has been released in Firefox 3.0 in 2008, hence this is not a recent Firefox feature. However, I guess that this policy is not mandated by web standards, therefore there is no reason to expect Chrome to adopt a similarly liberal policy in the future.

timjb avatar Jan 30 '19 22:01 timjb

Somewhat related issue, I can't do "quickjump" locally even when I serve it with python3 -m http.server. It's asking for a doc-index.json file but I don't see it in the directory.

piq9117 avatar Sep 16 '20 17:09 piq9117

Somewhat related issue, I can't do "quickjump" locally even when I serve it with python3 -m http.server. It's asking for a doc-index.json file but I don't see it in the directory.

In the haddock section of ~/.cabal/config you must set quickjump: True. Probably the error message should have said so

aavogt avatar May 03 '21 16:05 aavogt

That's extremely useful information! Why is that not the default?

Munksgaard avatar May 04 '21 06:05 Munksgaard

Also haddock --quickjump can be used!

siers avatar Jun 16 '21 17:06 siers