MAINT: make gen_rst more robust (minor)