some online tool or automation plugin for sublimetext for generating sphinx RST tables

andilabs picture andilabs · Oct 28, 2014 · Viewed 7.3k times · Source

I am using sphinx for documentation.

I would like to easily genearate based e.g on CSV file or copy-paste text the table like shown here: http://sphinx-doc.org/rest.html

+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | ...        | ...      |          |
+------------------------+------------+----------+----------+

Please help me and point which sublimeText plugin can I use for it or maybe there exists some online tool

Answer

Iodnas picture Iodnas · Sep 17, 2017

Using a CSV list to define a table is possible in ReST without any extra tools (many people don't know that though, including me until recently). You can link to a file or URL as resource, or just provide the text:

.. csv-table:: Frozen Delights!
   :header: "Treat", "Quantity", "Description"
   :widths: 15, 10, 30

   "Albatross", 2.99, "On a stick!"
   "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
   crunchy, now would it?"
   "Gannet Ripple", 1.99, "On a stick!"

Creates this table:

result of CSV table in restructuredText

Documentation can be found here: http://docutils.sourceforge.net/docs/ref/rst/directives.html#id4