Move doc_url function out of edxmako middleware