Iâve been a fan of literate programming since my first code with tangle and weave. I was always disappointed that it never gained traction. I hope nbdev gets closer to delivering on the promise of literate programming.
To that end, any pointers on how to import existing code and applications into nbdev and re-factoring it? Also any pointers on how to think about literate programming in the nbdev context. For example, when I was using cweb, I wrote the code is if I was writing a book. I started out with the beginning outline and the code segment referred to other fragments later in the narrative. . The beginning section will look something like
=====
This little app takes a set of templates, one to a calendar event and data for each calendar event then expands them using recursive template expansion.
Make ENET monthly meeting blast
<Set up event iteration>
<for each event>
<create template instance>
<expand template>
<generate time key>
<sort header by skip>
The phrase between the <> characters refers to the section containing the detail and narrative. Every section could have a mixture of code and section references. Using my code base is an example, the first segment would be something like"
set up event iteration:
in order to iterate over the calendar events, gather up a list of event files, baseline template, and create dictionary with common data elements used in template expansion.
â Code sectionâ
events=glob.glob("./*.event")
with open("event_template.rtmpl") as f:
event_template=f.read()
common_dict = rTemplate.colon_parser("event_common", EOL=False)
event_dict = {}
nonevent_dict = {}
subsequent sections would fill in the detail outlined in the beginning and the tangle command would organize it in a compiler friendly order.
How do I reframe my literate programming experience to fit the nbdev model?