Skip to main content

Sphinx directives for CSV-powered tabular authoring.

Project description

sphinx-tabular

PyPI Python Docs Downloads

Full documentation

Instead of just modifying the final table output, sphinx-tabular builds real docutils table nodes (table/tgroup/row/entry) the same way docutils' own table directives do, and only overrides the HTML rendering of table cells (for colspan/rowspan/inline styling) — the rest of the output is generated by Sphinx's normal HTML writer.

While the table structure and merged cells will work in the LaTeX builder PDF output, the table formatting (colors, icons, bacgkround color, text color, and alignment) is HTML only.

Donations to help support this project...

Venmo

Features

  • Sphinx extension.
  • Uses standard CSV file format.
  • Easily merge table cells with < and ^.
  • Support reStructuredText and Markdown.
  • Support for inline table data and external files.
  • Optional sticky header support for one or more header rows.
  • Provides a minimal set of spreadsheet formulas.
  • Set table cell alignment and per-cell alignment in both horizontal and vertical directions.
  • Set custom cell text and background colors.
  • Custom status pill.
  • Support for Font Awesome and Bootstrip icons if installed by your theme.
  • Sortable rows by clicking on the header row.
  • Searchable option.

Installation

pip install sphinx-tabular

conf.py

bash extensions = [ ..., 'sphinx_tabular', ..., ]

Directives

RST, external file:

RST .. rcsv-table:: Title :file: table.rcsv

RST, inline data.

``RST .. rcsv-table:: Title

Col 1, Row 1
Col 2, Row 2

``

Markdown, external file:

RST .. rcsv-table:: Title :file: table.mcsv

Markdown, inline data.

``RST .. rcsv-table:: Title

Col 1, Row 1
Col 2, Row 2

``

Merging Cells

Columns

``RST .. rcsv-table:: Title

Merged,<
Unmerged, Unmerged

``

Rows

``RST .. rcsv-table:: Title

Merged,Unmerged
^, Unmerged

``

Options

Supported options include:

  • :file: Path to the .rcsv or .mcsv file.
  • :header-rows: Number of top rows to format as header rows. If :sticky-header: is set, these rows become sticky.
  • :width: CSS width for the table, such as 100%.
  • :widths: A space-separated list of column widths.
  • :class: Additional classes to add to the table.
  • :text-align: Horizontal alignment of text in the cells. Default is left.
  • :vertical-align: Vertical alignment of text in cells. Default is middle.
  • :sticky-header: Make the header rows sticky when scrolling long tables.
  • :sticky-offset: CSS offset for sticky headers, such as 3.5rem.
  • :strict: Treat ragged rows and malformed input as errors instead of warnings.
  • :sortable: Enable row sorting by clicking on the headers.
  • :search: Add a search field with a row count to the table and enable searching.
  • :sort-types: Assigns explicit sort types using COLUMN=TYPE entries.

Formatting

  • Custom theming.
  • =ALIGN() horizontal/vertical cell value alignment.
  • =BG() set the background cell color.
  • =FG() set text color.
  • =ICON() use a Font Awesome or Bootstrap icon, or a fallback.
  • =STATUS() insert a colored status pill.

Spreadsheet

  • ' interprest as literal text without evaluation.
  • +,-,*,/ arithmetic operations on cells.
  • =C4 cell references.
  • =A4:B4 cell ranges.
  • =AVG() take the average.
  • =CONCAT() concatenation of cell values.
  • =COUNT() count number of numerical values.
  • =IF() conditional evaluation.
  • =MAX() find the maximum value.
  • =MIN() find the minimum value.
  • =ROUND() round the number to an int or the specified decimal places.
  • =SUM() sum a set or range of values.

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

sphinx_tabular-0.2.3.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

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

sphinx_tabular-0.2.3-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_tabular-0.2.3.tar.gz.

File metadata

  • Download URL: sphinx_tabular-0.2.3.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sphinx_tabular-0.2.3.tar.gz
Algorithm Hash digest
SHA256 c8abd62f5989759423beca74e029b4f68d5c00c0150c6dc985ed0ad9cdf37c55
MD5 82c45df1d96f399b4d4462bf5c13c3e8
BLAKE2b-256 800a3638c4e7b0b9f70e334fc0a9de8827d61257ada2d31dd18c741d819b2fa1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_tabular-0.2.3.tar.gz:

Publisher: publish.yml on deepthinker2001/sphinx-tabular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_tabular-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: sphinx_tabular-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sphinx_tabular-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 db5bc618b10418978c67a77e493752dcaaac66aa80829ba24c38f5ef87972ccb
MD5 e8c99a7f94988a3022459db1860f722e
BLAKE2b-256 87aa16ffd0918d7b7d608969eb2aa64536b4bb2ead3fdb8f0bca9371f0daee42

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_tabular-0.2.3-py3-none-any.whl:

Publisher: publish.yml on deepthinker2001/sphinx-tabular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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