title: How to generate reST/sphinx source from python?
body: <p>I'd like to generate documentation via reST, but don't want to write the reST source manually, but let a python script do that and then produce other formats (HTML, PDF) with sphinx. </p>
  
  <p>Imagine I have a telephone book in binary format. Now I use a python script to parse this and generate a document with all the names and numbers:</p>
  
  <pre><code>  phone_book = PhonebookParser("somefile.bin")
  
    restdoc = restProducer.NewDocument()
    for entry in phone_book:
      restdoc.add_section( title = entry.name, body = entry.number )
  
    restdoc.write_to_file("phonebook.rst")
  </code></pre>
  
  <p>Then I would go on to invoke sphinx for generating pdf and html:</p>
  
  <pre><code>  &gt; sphinx phonebook.rst -o phonebook.pdf
    &gt; sphinx phonebook.rst -o phonebook.html
  </code></pre>
  
  <p>Is there a python module (aka restProducer in the example above) that offers an API for generating reST? Or is the best way to just dump reST markup via a couple of print statements?</p>