Hi Kevin, Sorry for the delay, I am still interested in the problem, I will check out the code as soon as!
Mike On Fri, Nov 12, 2010 at 1:12 PM, Kevin Dunn <kgd...@gmail.com> wrote: > On Wed, Nov 10, 2010 at 19:28, Mike Hull <mikehul...@googlemail.com> wrote: >> HI, >> I really like sphinx, but I am having some problem adapting it :) >> Basically, I am trying to build a system for automating university >> labs, >> so students can upload interactively solutions. We have been using >> sphinx already to generate static documentation (i.e calling sphinx- >> build >> from the commandline on a set of files) , since it is very nice for >> embedding >> different languages, but now we want to use it a bit more dynamically, >> and >> use django to generate the html on the fly from some rst. I started to >> look >> through the source code, but got a bit lost! >> >> Can anyone give me any pointers as to how to go about this? Has this >> been done before? > > Hi Mike, > > One simple approach (I'm sure there are better) with Django is to: > > 1. accept the user's RST input > 2. write it to an index.rst file on the webserver > 3. call Sphinx's pickle builder on the server using Python's subprocess module > 4. open the pickle file and extract the HTML > 5. return that HTML to the browser (AJAX, or in a Django HTTPResponse) > > I use this approach in two of my projects that rely on Sphinx: > > 1. Sphinx-wiki: http://bitbucket.org/kevindunn/sphinx-wiki/wiki/Home > 2. http://ucomment.org. Please see the Django code here: > http://bitbucket.org/kevindunn/ucommentapp/src/969d4da3da58/views.py, > scroll to line 359 and see the Django views.py function called > ``compile_RST_to_HTML(raw_RST)`` > > For your case I would use all the code from the first project listed, > available here: > http://bitbucket.org/kevindunn/sphinx-wiki/src/tip/sphinx-wiki.py, > because that code was written so multiple people can compile their RST > files on the same server, without overwriting each other's > submissions. > > If you prefer to call Sphinx directly from your Python code (i.e. not > via Python's subprocess module), then take a look at line 1749 in this > Django file: > http://bitbucket.org/kevindunn/ucommentapp/src/969d4da3da58/views.py > > Let me know if you have any questions about the code and getting it to work. > Kevin > >> >> Thanks, >> >> >> Mike > > -- > You received this message because you are subscribed to the Google Groups > "sphinx-dev" group. > To post to this group, send email to sphinx-...@googlegroups.com. > To unsubscribe from this group, send email to > sphinx-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sphinx-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-...@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.