GithubHelp home page GithubHelp logo

willingc / nbquarto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from muellerzr/nbquarto

0.0 0.0 0.0 674 KB

Small python library solely for quick Quarto extensions

Home Page: https://muellerzr.github.io/nbquarto/

License: Apache License 2.0

Python 93.12% Makefile 0.35% Jupyter Notebook 6.52%

nbquarto's Introduction

Key Terms

  • Cell: An executing module or Markdown container in a Jupyter Notebook.
  • Directive: A pipe-delineated (|) comment block recognized by Quarto and nbquarto.
  • Processor: A class that tailors a cell based on its directives.

Introducing nbquarto: Your Python-Powered Notebook Enhancer

Harness the might of Python with nbquarto, a dynamic interface to externally transform Jupyter Notebook cells, designed ideally for Quarto projects. This framework streamlines your documentation process by enabling rapid creation and implementation of post-processors for Jupyter Notebooks. Although Quarto-focused, nbquarto serves as a valuable asset for any Python project leveraging Jupyter Notebooks.

Getting Started

Check out the installation directions here to get started!

Choose nbquarto for a Superior Experience

Drawing inspiration from nbdev, nbquarto steers towards a more comprehensible and less abstracted interface. It focuses on modifications to Jupyter Notebooks as to fully capitalize on Quarto's abundant features, minimizing dependencies, and enhancing code readability.

No More Learning Curve with nbquarto

Why learn a new language (Lua) to modify content already in Python? nbquarto emerges as the Pythonic alternative to Quarto Extensions. Offering flexibility and simplicity at the cost of a negligible increase in processing time, nbquarto empowers you to control the narrative.

How Does nbquarto Work?

At the heart of nbquarto is a Processor. This component modifies a cell to fine-tune code formatting or swiftly craft complex Quarto syntax combinations. Each cell object encompasses two crucial elements: directives_ (a list of cell directives) and source (modifiable cell text).

See how easy it is to add a comment to the top of a cell's text source:

>>> from nbquarto import Processor

>>> class BasicProcessor(Processor):
...    "A basic processor that adds a comment to the top of a cell's text source."
...
...    directives = "process"
...
...    def process(self, cell):
...        if any(directive in cell.directives_ for directive in self.directives):
...            cell.source = f"# This code has been processed!\n{cell.source}"

And in a notebook cell:

# Input
>>> #| process
... print("Hello, world!")

# Output
>>> # This code has been processed!
... print("Hello, world!")

Simplified Configuration

Say goodbye to confusion with nbquarto's configuration file. This handy feature organizes processor use, notebook paths, and processor constants for a seamless user experience.

documentation_source: tests
processors: [
    nbquarto.processors.example:BasicProcessor,
    nbquarto.processors.autodoc:AutoDocProcessor
]

processor_args:
  AutoDocProcessor: 
      repo_owner: muellerzr
      repo_name: nbquarto

Efficient Notebook Processing

Execute the nbquarto-process command to let the configured Processor(s) work their magic on your notebooks. All processed notebooks, saved as qmd files, land safely in your desired output folder:

nbquarto-process \
--config_file tests/test_artifacts/single_processor.yaml \
--notebook_file tests/test_artifacts/test_example.ipynb \
--output_folder docs/

nbdev Reinvented: Experience nbquarto

Transform your understanding of nbdev with nbquarto, a user-friendly reimagining of the original project. Bask in the simplicity of an unambiguous interface for modifying Jupyter Notebooks, enjoy the luxury of minimal abstraction, relish clear error messages, and appreciate the adherence to excellent Python coding practices.

nbquarto's People

Contributors

muellerzr 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.