nrnrnr / noweb

The noweb tool for literate programming
BSD 2-Clause "Simplified" License
253 stars 27 forks source link

Finding all root chunks or accidentally "loose" chunks #34

Closed dbosk closed 11 months ago

dbosk commented 11 months ago

Do you have any tool (or way of working) to avoid that a chunk is loose? Consider the following:

The program outline:
<<*>>=
<<imports>>
<<helper functions>>
<<main program>>
@

Now we want to do the following.
<<main program>>=
val = func(0)
<<functions>>=
def func ...

Note that we have <<functions>> instead of the intended <<helper functions>>.

Do you have any tool or other technique to help detect this? That chunk <<functions>> becomes a "loose" chunk since it's not linked in from <<*>>. Strictly it's its own root chunk. So do you know of any tool that lists root chunks of a file? Or how do you handle this when you write?

nrnrnr commented 11 months ago

Are you looking to find a chunk that has a definition but no use? The noroots script will do that for you. It is part of the distribution.

dbosk commented 11 months ago

Yes, that's exactly what I wanted, thanks! Awkward that I didn't find it myself. I even started looking through the contrib directory. But then thought that this can't be hidden in there, must be something you use more often.

Thanks again!