Comment by WillAdams
This seems to be one of the core lessons behind John Ousterhout's _A Philosophy of Software Design_
https://www.goodreads.com/book/show/39996759-a-philosophy-of...
and I find that the mechanism of "Literate Programming":
https://literateprogramming.com/
is a useful one for doing this since it allows one to write about both how the low level details are implements in a function, _and_ how the written function is used in a way which allows the twain to support each other.
That needs to be http://literateprogramming.com/ at the moment because their certificate / HTTPS setup is borked.