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.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Egg

File details

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

File metadata

  • Download URL: rstspreadsheet-0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rstspreadsheet-0.1.tar.gz
Algorithm Hash digest
SHA256 e2d300900d8adcd8522049d266a7663ad39c08b91bfc1cd48548bf429ad9d0fe
MD5 7905b19246f641dd606a3fd136d2526c
BLAKE2b-256 6194ede76ed94b42fdc273c953d50035c94a35e9368e96d072ff60edccb54210

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rstspreadsheet-0.1-py2.6.egg
Algorithm Hash digest
SHA256 531ed64e2a96efa82748d7a780992e6823587677b8ce43992b52fc6157e0248a
MD5 b4ff6d44a604bf5ed22e9a85f162ab1d
BLAKE2b-256 22b028a5276ccfc38ab675bde0de6d0c7dad12c973e21c385d9afc755e90fc86

See more details on using hashes here.

Supported by

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