Giter VIP home page Giter VIP logo

beetroot's Introduction

beetroot

Install

pip install beetroot

How to use

From the command-line, using the markdown backend:

br_export --backend markdown path/to/notebook.ipynb path/to/output_directory

As a Python API:

import json
from pathlib import Path

from beetroot.markdown.api import export_markdown_notebook

# Input and output paths
nb_path = Path('path/to/notebook.ipynb')
output_path = Path('path/to/output/directory')

# Load the notebook contents as JSON
nb_json = json.loads(nb_path.read_text())

# Export the notebook
markdown, completions = export_markdown_notebook(nb_json)

# Run the completion to write all external files
for completion in completions:
    completion(output_path)

# Write the markdown to an output file
md_filename = output_path / nb_path.with_suffix('.md').name
with open(md_filename, 'w') as md_file:
    md_file.write(markdown)

Dev Environment Setup

  1. Create a virtual environment for beetroot development:
python3 -m venv ~/venv/venv-beetroot-dev
source ~/venv/venv-beetroot-dev/bin/activate
  1. Install requirements
pip install -r requirements.dev.txt

Before committing changes

Run the following to ensure all dependencies are generated from notebooks and notebooks are cleaned:

nbdev_export && mypy beetroot/ && nbdev_test && nbdev_clean && nbdev_clean --fname test_artifacts/ && nbdev_readme

Useful Tricks

Search for a string in all python files (.ipynb and .py files):

find . -name '_proc' -prune -o \( -name '*.ipynb' -o -name '*.py' \) -type f -exec grep -nH 'export_notebook' {} \;

beetroot's People

Contributors

spather avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.