Effects of doping on charge-density waves in layer compounds