Library for recording in a markdown file.
Project description
PyMD
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rpymd-1.0.0.tar.gz.
File metadata
- Download URL: rpymd-1.0.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7e5cc982309c2b9b68a0264a70a0d50c0686a37346e51253759654b415e9ac6
|
|
| MD5 |
9d1cc299072d4fbdb5d099a027db9322
|
|
| BLAKE2b-256 |
0d719be579daff126f8e28190df20194396a154ddaaa5c589cc8a8164896f112
|
File details
Details for the file RPyMD-1.0.0-py3-none-any.whl.
File metadata
- Download URL: RPyMD-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06dafbda3827653d1b52d5a53741359f373a70d9e6a089153dbb623d0325a810
|
|
| MD5 |
0103c58bc3776176246dcd4df96f1857
|
|
| BLAKE2b-256 |
12ced815e39462385b1609c9724d70b058cd948183a8b968bb5f5b47b8ec6db2
|