Add the `spreadsheet` directive to reStructuredText for Docutils and Sphinx
Project description
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
======== ======== ========== ======
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rstspreadsheet-0.1.2.tar.gz.
File metadata
- Download URL: rstspreadsheet-0.1.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9b2ff582af9b72d6bfcd3d60ce1da619044bdece290f51ae2b8e3a297f9f590
|
|
| MD5 |
d30731e2cc6f006850a428b1beb7af63
|
|
| BLAKE2b-256 |
d6a707d06a6b5e4c5abbd20f7c51522352ef3d53f2f3a504156c887d1211ec79
|
File details
Details for the file rstspreadsheet-0.1.2-py2.6.egg.
File metadata
- Download URL: rstspreadsheet-0.1.2-py2.6.egg
- Upload date:
- Size: 11.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea412a028ccba0f8befd18a32411e5f1cf03326e189799ca18069b24bcf69a89
|
|
| MD5 |
276b397b56be70d2dfa6322e7e517718
|
|
| BLAKE2b-256 |
d4bed0c0692671f49cad6d436fc9f82f7647c9506675c888782eedf27cf51419
|