dldl / sphinx-preview

Sphinx preview in Atom
MIT License
5 stars 4 forks source link

Add an autosave feature #3

Closed quentinus95 closed 7 years ago

quentinus95 commented 7 years ago

It would be great to have an auto-save feature saving the current page every X seconds to have real time preview.

This should be configurable in plugin options to avoid power usage issues.

quentinus95 commented 7 years ago

There already are packages doing the job.

See: https://atom.io/packages/search?utf8=%E2%9C%93&q=keyword:save

splashx commented 7 years ago

auto-saving doesnt solve the problem, does it? I have been able to reach a point where I can preview the rst (on linux), but if I edit and save it manually it can't see the changes "live" - I have to always kill the container and ctrl+alt+o again in order to see the changes :thinking:

quentinus95 commented 7 years ago

Hi @splashx

Does the page refresh on save?

I'm not experiencing any issue on ArchLinux using Atom 1.16.

I had to close / reopen the preview the first time I used it to get something displayed.

When I change something on the file and explicitly save the file by pressing ctrl + S, the preview refreshes and the content is updated.

There was a cache issue I was experiencing when using Ubuntu but it could be solved as explained in #2.

splashx commented 7 years ago

It refreshes on save, but the content displayed is always the "old" one.

I'm on Atom 1.1.16 x64 @ Ubuntu.

I've disabled caching (#2) but without luck :-1:

quentinus95 commented 7 years ago

Can you try to access to the concerned page on an external browser to confirm it is a browser-plus cache related issue?

elmar-hinz commented 5 years ago

Saving triggers a reload of the internal browser, but it does not trigger a re-built of the HTML. External browsers show the outdated HTML, too. Not even a restart of the container securely triggers a new built.

November 2018 on macOS Mojave

Digging a little deeper. The Sphinx-Server is working, if I start it from the command line like given in its documentation:

docker run -itd -v "$(pwd)":/web -u $(id -u):$(id -g) -p 8000:8000 --name sphinx-server dldl/sphinx-server

When I edit the files and save them, the change watcher works and rebuilds the HTML. I can follow this in the console of Kitematik. I can call the changed HTML with any Browser.

[I 181124 20:39:37 server:298](B Serving on http://0.0.0.0:8000
[I 181124 20:39:37 handlers:59](B Start watching changes
[I 181124 20:39:37 handlers:61](B Start detecting changes
[I 181124 20:39:47 handlers:132](B Browser Connected: http://127.0.0.1:8000/Architektur.html
+--------- Architektur.rst changed ----------------------------------------------
| Running Sphinx v1.8.2

When I start the Server from within the Atom Editor it does not work any longer. It just does not detect the change. It also comes under the container name: Sphinx-Preview. The only difference I see is in the ports:

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                                              NAMES
958b2f7614eb        dldl/sphinx-server   "python /opt/sphinx-…"   3 minutes ago       Up 58 seconds       0.0.0.0:8000->8000/tcp, 0.0.0.0:35729->35729/tcp   sphinx-preview

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                               NAMES
c1fb5d789a70        dldl/sphinx-server   "python /opt/sphinx-…"   5 seconds ago       Up 3 seconds        0.0.0.0:8000->8000/tcp, 35729/tcp   sphinx-server