build: refactoring sphinx pre and post processing