AND...
just because the absolute max rating is 40mA per I/O pin, doesn't mean the part won't source more than that, as the Dr found out in post #10. The uC doesn't limit the max current, YOU have to. What the data sheet is saying is that if you go over (or even close to) 40mA, all bets are off.
and on your 74HC4017 data sheet, just because the output will source 25mA, if you bring the pin higher than 5.5V (or VCC + .5V) with a current limit of 25mA, you'll blow the clamp diode, as they'll only take 20mA (look at the 25mA spec, it clearly states Voh < Vcc + .5V).
And what the test spec is saying is not that the part will source 20mA @ 5V or 10mA @ 3V. It is spec'ing the Voh level at those currents with those Vcc's, and guaranteeing a minimum Voh for those currents at those Vcc's. It could be higher, but that is the minimum levels. That is why I use Vcc when doing my calculations, worst case scenario. (I suppose I should've used 494 ohm because of 5% resistor, but just know current calculated will be +/- 5%.)