We may want to generalize the implementation I've done in addons and share it with other projects. See https://github.com/readthedocs/addons/pull/116#pullrequestreview-1617933134