Package: nbquarto
Key TermsCell: An executing module or Markdown container in a Jupyter Notebook.Directive: A pipe-delineated (|) comment block recognized by Quarto andnbquarto.Processor: A class that tailors a cell based on its directives.Introducingnbquarto: Your Python-Powered Notebook EnhancerHarness the might of Python withnbquarto, a dynamic interface to externally transform Jupyter Notebook cells, designed ideally forQuartoprojects.
This framework streamlines your documentation process by enabling rapid creation and implementation of post-processors for Jupyter Notebooks.
Although Quarto-focused,nbquartoserves as a valuable asset for any Python project leveraging Jupyter Notebooks.Getting StartedCheck out the installation directionshereto get started!Choosenbquartofor a Superior ExperienceDrawing inspiration fromnbdev,nbquartosteers 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 withnbquartoWhy learn a new language (Lua) to modify content already in Python?nbquartoemerges as the Pythonic alternative to Quarto Extensions. Offering flexibility and simplicity at the cost of a negligible increase in processing time,nbquartoempowers you to control the narrative.How DoesnbquartoWork?At the heart ofnbquartois aProcessor. This component modifies a cell to fine-tune code formatting or swiftly craft complex Quarto syntax combinations.
Eachcellobject encompasses two crucial elements:directives_(a list of cell directives) andsource(modifiable cell text).See how easy it is to add a comment to the top of a cell's text source:>>>fromnbquartoimportProcessor>>>classBasicProcessor(Processor):..."A basic processor that adds a comment to the top of a cell's text source."......directives="process"......defprocess(self,cell):...ifany(directiveincell.directives_fordirectiveinself.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 ConfigurationSay goodbye to confusion withnbquarto's configuration file. This handy feature organizes processor use, notebook paths, and processor constants for a seamless user experience.documentation_source:testsprocessors:[nbquarto.processors.example:BasicProcessor,nbquarto.processors.autodoc:AutoDocProcessor]processor_args:AutoDocProcessor:repo_owner:muellerzrrepo_name:nbquartoEfficient Notebook ProcessingExecute thenbquarto-processcommand to let the configuredProcessor(s) work their magic on your notebooks. All processed notebooks, saved asqmdfiles, land safely in your desired output folder:nbquarto-process\--config_filetests/test_artifacts/single_processor.yaml\--notebook_filetests/test_artifacts/test_example.ipynb\--output_folderdocs/nbdevReinvented: ExperiencenbquartoTransform your understanding ofnbdevwithnbquarto, 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.