gh-35658: Fix build with sphinx 7
Replace or remove use of deprecated stuff
Tried to keep it compatible with older sphinx, but needs testing
URL: https://github.com/sagemath/sage/pull/35658
Reported by: Antonio Rojas
Reviewer(s): Antonio Rojas, Kwankyu Lee