Refactoring: use multiple MACHINE loops for better structure
This is a preparation for adding dedicated documentation jobs. In order to have these grouped by stage along with their corresponding machine jobs, we have to get rid of the giant outer loop and add loops for each stage instead.