Electron impact polarization of atomic spectral lines. I. A general theoretical scheme