Open kalekundert opened 3 years ago
protocol.add_footnotes()
is another way to avoid this issue.
There is a fundamental difference between adding a step and merging in a new protocol; most of the logic in Protocol.merge
doesn't apply when just adding a step.
But, by allowing steps with undefined footnotes to be added to the protocol, it opens the possibility of those footnotes getting messed up if another protocol with footnotes is merged before the undefined footnotes are defined. For example:
p = stepwise.Protocol()
p += "Step with footnote [1]"
p += stepwise.load('protocol with footnote [1]')
p.footnotes[1] = "Footnote..."
Because merge()
resolves footnotes based on the kys in the footnotes
dictionary, it won't notice that the first step and the loaded protocol both define the same footnote. So when the footnote is finally defined, it overwrites the footnote from the protocol. Thinking about this, maybe I actually want to be even more strict about footnotes than I am currently...
Right now, I think footnote checking is skipped if there are no footnotes. But this doesn't work well with
stepwise.load()
, which could pull in a protocol with footnotes. For example:My first impression is that it might be better to defer all checks until the protocol is rendered, but I'll have to think more carefully about how feasible that is.