mpastell / Pweave

Pweave is a scientific report generator and a literate programming tool for Python. It can capture the results and plots from data analysis and works well with numpy, scipy and matplotlib.
http://mpastell.com/pweave
Other
435 stars 64 forks source link

How can I get the live preview working (as seen on the homepage)? #115

Open neo-anderson opened 6 years ago

neo-anderson commented 6 years ago

I have been trying to get this working for hours. Please help. http://mpastell.com/pweave/index.html I am able to run individual code chunks. But how can I generate a report like in the picture shown above with Atom? Thanks

piccolbo commented 6 years ago

Please describe the steps you took and what you get as opposed to what you expect. The way I do it, I run pweave at the cmd line, open the md output in atom and then use the markdown-preview package. It may not be the most polished, but since I use directly py files to have access to all manners of linters and what not, I don't write pmd files. I hope this helps.

neo-anderson commented 6 years ago

Thank you. I just tried what you said and I was able to get it working. It's not obvious from the official documentation that this is the way to do it though. apm install language-markdown atom-html-preview pdf-view

  1. Shouldn't the above command install preview tools for Atom? What are those plugins for?
  2. Is there a way to make pweave watch the file and run automatically?
piccolbo commented 6 years ago

The only package you need is markdown-preview. Not sure why you bring up these other packages. I would suggest asking on an Atom forum or some such, but certainly unrelated to pweave. As far as making the pweave part happen automatically, I tried myself and failed. I wrote a makefile to run pweave to generate the md file when needed, then used watch to run make every n seconds. If there are saved changes, it should run. Unfortunately my python code failed when pweave run inside make, whereas it worked fine outside make. I did not invest a huge amount of time to troubleshoot the issue.

neo-anderson commented 6 years ago

That command was taken straight from the editor support page @ pweave. http://mpastell.com/pweave/editors.html Seeing that command, I kinda assumed that the plugins would facilitate preview of some sort.

piccolbo commented 6 years ago

I see, that is reasonable. Being somewhat experienced with markdown, I couldn't see your point. Imagine someone that comes to pweave and has no atom or markdown experience. Maybe he's someone who does notebooks and has finally seen the light and wants to try something else, and has no atom or markdown experience or picking up them on the fly. I think you make a case for hand-holding the user a tiny bit more to get to that screenshot. On the other hand, this thing of running pweave in the background is very suboptimal since one has to run it manually, keep the md open in atom, which should not be edited, something I've done by mistake in more than one occasion, and then there's a need for another package so that atom will auto-refresh when pweave runs and rewrites the md file. Thinking about it, I doubt this is the experience @mpastell has in mind. Maybe if we give him a couple of days he will chip in with the Right Way™.

n-batalha commented 5 years ago

I was looking for an answer too. While we lack better answers, you can use inotifywait.

Here is a wrapper script, place this in say monitor.sh:

#!/bin/sh
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written")
"$@"
while inotifywait -qre close_write --format "$FORMAT" .
do
    "$@"
done

In the terminal run:

./monitor.sh pweave -f md2html FIR_designp.pmd

Now each change of any file will trigger a pweave rebuild. Not ideal.