Optimize doctest generation