DOC: Improve code quality of doc/make.py
In #18949, python files in the scripts/ directory were reviewed to pass PEP-8, and added to lint. But doc/make.py was left out, as it wasn't in that directory.

Besides PEP-8 problems, make.py has repetitive code that could be avoided by a refactoring.

Also, #15591 and #10340 can be addressed as part of this refactoring.