refactor Document code out into module

also, fix Edit plugin path which was broken