Spreadsheet directive for reStructuredText
rstSpreadsheet provides the spreadsheet directive for reStructuredText. You can use it from Docutils or Sphinx. Any python function/module can be used to calculate the cell value. Please see the documentation and examples
Install
pip install rstspreadsheet # or easy_install rstspreadsheet
Usage
Use as a standalone program:
python -m rstspreadsheet sample.rst sample.html
Or use as a sphinx extension by adding it to extensions:
extensions = [
# other extensions...
'rstspreadsheet']
Examples
Simple spreadsheet
You can do this simple calculation:
p |
q |
p and q |
not (p and q) |
|---|---|---|---|
0 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
with this simple code:
.. spreadsheet::
:eq: {2} = {0} and {1}
{3} = int(not {2})
=== === ========= ===============
p q p and q not (p and q)
=== === ========= ===============
0 0
1 0
0 1
1 1
=== === ========= ===============
Spreadsheet with python functions
If you want to calculate some complicated math functions like this:
function |
argument |
expression |
result |
|---|---|---|---|
fac |
5 |
fac(5) |
120.00 |
sin |
pi |
sin(pi) |
0.00 |
cos |
pi |
cos(pi) |
-1.00 |
exp |
1 |
exp(1) |
2.72 |
use python module/function!:
.. spreadsheet::
:eq: {2} = '{0}({1})'
{3} = {2}
:setup: from math import sin, cos, exp, pi
def fac(n):
return fac(n-1) * n if n > 1 else 1
:format: 3:'%0.2f'
======== ======== ========== ======
function argument expression result
======== ======== ========== ======
fac 5
sin pi
cos pi
exp 1
======== ======== ========== ======
Metadata
Release files for rstspreadsheet 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rstspreadsheet-0.1.2.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rstspreadsheet-0.1.2-py2.6.egg | Legacy Egg format | - | - | Details |
Total release size: 17.1 kB
Release files / rstspreadsheet-0.1.2.tar.gz
| Download URL | rstspreadsheet-0.1.2.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9b2ff582af9b72d6bfcd3d60ce1da619044bdece290f51ae2b8e3a297f9f590
|
|
BLAKE2b-256 checksum How to use checksums |
d6a707d06a6b5e4c5abbd20f7c51522352ef3d53f2f3a504156c887d1211ec79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rstspreadsheet-0.1.2-py2.6.egg
| Download URL | rstspreadsheet-0.1.2-py2.6.egg |
|---|---|
| Size | 11.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
ea412a028ccba0f8befd18a32411e5f1cf03326e189799ca18069b24bcf69a89
|
|
BLAKE2b-256 checksum How to use checksums |
d4bed0c0692671f49cad6d436fc9f82f7647c9506675c888782eedf27cf51419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |