[IMP] improve code in _get_documentation_stage.