Don't refer to globals, use locals instead, and handle RTD_NEW_THEME = False sanely