[Doc-SIG] docutils issues

Dethe Elza dethe.elza at blastradius.com
Tue Oct 7 11:54:45 EDT 2003


Hi folks,

I'm trying to build a lightweight templating system around docutils.  
I'm using a (slightly modified, I use core.publish_file) version of 
Nicola Paolucci's recipe to create an HTML fragment from a reST file, 
which works fine as long as there are no errors.  If there are errors, 
I want the option of allowing the error to be processed normally 
(resulting in an HTML fragment with embedded error messages) or throw 
an exception (so I can trap it and display the text instead).  I've 
found that if the docutils processor is running on a file, I cannot get 
it to throw an exception all the way out to the calling method (it 
traps and processes it internally), while if I use a StringIO it causes 
exceptions that don't show up in the file processing.  Docutils appears 
to be using the file object as it's state machine and calling methods 
which aren't part of the StringIO.  Finally, if I use a StringIO, I 
have trouble with the include directive.

If I can get core.publish_file (with a real file) to optionally throw 
an exception on error, I think that would be all I need.  Failing that 
I need to teach core.publish_string (or core.publish_file with StringIO 
"file") to optionally *not* throw an exception *and* pass it a 
parameter for the relative path for include directives to work.

Naturally, I'd prefer the first path.

TIA

--Dethe




More information about the Doc-SIG mailing list