Code Tips

Pipeline for annotating code cells with notes

Code Tips operate the same way as Code Notes however they show up as tooltips instead and use the tip tag instead of the explain. Note that it also uses multiline CodeNotes by default so you need a start and an end.

To use this make sure that you add in hint.css and tips.css to the _quarto.yml under the css section!

from fastcore.test import test_eq

source

download_tooltip_css

 download_tooltip_css ()

source

write_tooltip_directives

 write_tooltip_directives (explanation:str,
                           hint_directives:list=['rounded', 'medium',
                           'right'], filename:str=None)

Creates a tooltip in style of hint_directives with content explanation

Type Default Details
explanation str The tooltip text
hint_directives list [‘rounded’, ‘medium’, ‘right’] A list of css directives to modify the tooltip
filename str None An optional filename to be rendered

source

convert_explanation

 convert_explanation (explanation_cell, source)

Takes an explanation and source code and linkes them together in a new cell


source

extract_code

 extract_code (start_code, end_code, source, instance_num,
               end_instance_num=0)

Finds code between start and finish potentially with instances to check


source

parse_code

 parse_code (code_cell, markdown_cell)

Parses directives to extract the code needed to be highlighted


source

TipExportProc

 TipExportProc (nb)

A proc that checks and reorganizes cells for documentation for proper explainations


source

parse_notes

 parse_notes ()

Exports notebooks to parsed notes for documentation. Should be called in the workflow, not yourself!

processor = NBProcessor("test.ipynb", [TipExportProc], rm_directives=False)
processor.process()
write_nb(processor.nb, "result.ipynb")

To use this, add nbdev-extensions.codetips:TipExportProc to your settings.ini and add the required css files to your _quarto.yml

Now it will automatically build your docs like notes!

    return a+b