factor out docstring finding code
complete function args and some cleanup