Skip to main content

Library for recording in a markdown file.

Project description

PyMD

License

Overview

This packages provides an intuitive way to generate markdown files. While sweeping over parameters for a project, results can be neatly organized and stored within a markdown file.

Features

  • Index over subsections
  • Assign multiple section types to each section
  • Add text, images, figures, lists, tables, checkboxes, and hyperlinks to the markdown.
  • Save and load as JSON

Installation

Pip

Use pip to install PyMD:

pip install .

Markdown File Examples

Create MDGenerator Object

When creating the MDGenerator Object, either the save path and filename can be given together in the save_path or separately. If given together, this will neglect the file_name parameter, and the file descriptor must be given with the save_path. File descriptor is not needed if file_name is given separately.

A list of authors can be provided or a single name. It will be formatted accordingly.

from PyMD import MDGenerator

md = MDGenerator(save_path="folder/filename.md", title="Title of MD file", author="John Smith")

# Add sections to the md object

# Save when done to generate md file
md.save()

Create and Index Section Headers

Section headers are automatically created when a section get or set is made. Levels or subsections can be addressed by a file system format. Examples would be:

Indexing using base object

md.add_text("Section 1/Subsection 1/Subsubsection 1","This is placed in the subsubsection of the first section and first subsection.")

Dictionary Single Indexing

md["Section 1/Subsection 1/Subsubsection 1"].add_text("This is placed in the subsubsection of the first section and first subsection.")

Dictionary Multi Indexing

md["Section 1"]["Subsection 1"]["Subsubsection 1"].add_text("This is placed in the subsubsection of the first section and first subsection.")

Variation of Single and Multi Indexing

md["Section 1/Subsection 1"]["Subsubsection 1"].add_text("This is placed in the subsubsection of the first section and first subsection.")

However, indexing through a function call can only be done by the base object. Not a membering object.

Assignment Functions

Each function will have its own parameters, but the provided functions are the following:

md.add_text(text)
md.add_code(text)
md.add_figure(figure)
md.add_image(image_path)
md.add_table(table)
md.add_list(text_list)
md.add_link(link, text)
md.add_checkbox(text_list, checked)

Default Assignments

To speed up common assignments, text, figures, tables, and lists are allowed to be assigned to the dictionary. For examples, each assignment can be made to add to a section:

Text Assignmnet

md["Section 1"]["Subsection 1"]["Subsubsection 1"] = "This is placed in the subsubsection of the first section and first subsection."

Figure Assignment

from matplotlib import pyplot as plt

fig, ax = plt.subplots()
# Add to the figure
md["Figure or Image Section"] = fig

Dataframe Assignment

from pandas import DataFrame

# Create array instance with or without columns
table = DataFrame(array, columns=columns)
md["Table Section"] = table

Numpy Assignment

import numpy

# Create array instance
md["Table Section"] = array

List Assignment

md["List Section"] = ["Item 1", "Item 2", "Item 3"]

Save and Load JSON file

md.save_json()
md.save_json(new_file_name)
md = MDGenerator(save_path=json_file_location)
md.load_json()
md = MDGenerator()
md.load_json(json_file_location)

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

rpymd-1.0.0.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

RPyMD-1.0.0-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

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