Skip to main content

MkDocs plugin to directly insert tables from files into markdown.

Project description

Actions Status PyPI - Python Version PyPI PyPI - Downloads codecov GitHub contributors PyPI - License

mkdocs-table-reader-plugin

MkDocs plugin that adds a {{ read_csv('table.csv') }} markdown tag to directly insert CSV files as a table into a page.

This helps to enable building reproducible reports. For more complex use cases, consider pheasant or nbconvert.

Setup

Install the plugin using pip3:

pip3 install mkdocs-table-reader-plugin

Next, add the following lines to your mkdocs.yml:

plugins:
  - search
  - table-reader

If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set.

Usage

In your markdown documents you can now use:

{{ read_csv('path_to_table.csv') }}

Where the path is relative to the location of your project's mkdocs.yml file.

Under the hood this is basically:

import pandas as pd
df = pd.read_csv('path_to_table.csv')
df.to_markdown(index=False, tablefmt='pipe')

Which means you can pass all parameters of pandas.read_csv().

Available readers

The table reader functions implemented from pandas:

Options

You can customize the plugin by setting options in mkdocs.yml. For example:

plugins:
  - table-reader:
      data_path: "docs"

data_path

Default is ., which means you can specify the path to your table files relative to the location of your project's mkdocs.yml file. If you use a folder for all your table files you can shorten the path specification by setting data_path.

For example, if you set data_path to docs/ in the project below, you will be able to use {{ read_csv("basic_table.csv") }} instead of {{ read_csv("docs/basic_table.csv") }} inside index.md.

.
├── docs
│   ├── basic_table.csv
│   └── index.md
└── mkdocs.yml

Contributing

Contributions are very welcome! Please read CONTRIBUTING.md before putting in any work.

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

mkdocs-table-reader-plugin-0.4.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_table_reader_plugin-0.4.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-table-reader-plugin-0.4.3.tar.gz.

File metadata

  • Download URL: mkdocs-table-reader-plugin-0.4.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for mkdocs-table-reader-plugin-0.4.3.tar.gz
Algorithm Hash digest
SHA256 2c12508c678015aea6e5948aa0e3fe1ad6031dc50d5502e2c539d2eeb57a6e17
MD5 e21d9b1e3a90060c0490ff81188b8063
BLAKE2b-256 e8a01b22060699f8e210caac221e81ee25cca7788c0647412799a1985347f602

See more details on using hashes here.

File details

Details for the file mkdocs_table_reader_plugin-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_table_reader_plugin-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for mkdocs_table_reader_plugin-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2b7406e0d5b46164ec3411c3e133d8a9fbcd9542de9fd6a36a629d1aa3a71b55
MD5 2c908d680013954b298433ee41b7187f
BLAKE2b-256 124ca7343a2b34dfabf7b3d107974c485d0e87d3e4f50f0be656cb957cf9862e

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