https://scripting.krita.org/lessons/documents "Also notice there is no refreshProjection() like there was when we were changing the layer. Because we are changing the document directly with cropping, that automatically is refreshing the projection so it doesn’t need to be called. Only certain things like changing layer properties need to call that refreshProjection function." This section assumes that the Layers article comes before the Documents article, but that isn't the case. Layers are never mentioned before this section. Sorry if this isn't the right place for this type of report.
Thanks for the report. I just updated that page a bit with updated instructions. I had a feeling there were going to be things like this that came up. I originally combined the layers and document explanation in one lesson. Then separated them out into their own topics as wrote more. Thanks for the feedback.