Skip to main content

Add the `spreadsheet` directive to reStructuredText for Docutils and Sphinx

Project description

reStructuredSpreadsheet adds 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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rstspreadsheet-0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

rstspreadsheet-0.1.1-py2.6.egg (6.7 kB view details)

Uploaded Source

File details

Details for the file rstspreadsheet-0.1.1.tar.gz.

File metadata

File hashes

Hashes for rstspreadsheet-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1381bb129174a3c94b7c4923cf437f99fa03ede2992d37a475ecbb26ea0efeba
MD5 84ef09ef6bba996ff841b782529d4974
BLAKE2b-256 51755e236d95f9ac262a74a80852946fae9bcc0cba44c059894bc3e0ed48c1dd

See more details on using hashes here.

File details

Details for the file rstspreadsheet-0.1.1-py2.6.egg.

File metadata

File hashes

Hashes for rstspreadsheet-0.1.1-py2.6.egg
Algorithm Hash digest
SHA256 78417a31dc5e7ce50d7da64cb781ddb40b7b4211a12e7f0c4789fd1d0619e955
MD5 5f56d939d833af26d14b0420e1c9ac5c
BLAKE2b-256 20f8c771039018365501535b53fce39a784816758b6b65b3531be116d7ed9c2b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page