Planetary nebulae with Wolf–Rayet-type central stars – II. Dissecting the compact planetary nebula M 2-31 with GTC MEGARA