Reconfiguring crystal and electronic structures of MoS2 by substitutional doping