For melee, shield damage formula seems to be truncate((truncate(raw_damage) - shield armor) * (1 - shield skill * 0.08)). If raw_damage - shield armor is 0, it just uses 0.
raw_damage seems appears be calculated by the same function that calculates raw damage for hits on players, so I would guess that it follows most of the same rules (powerstrike, wpf, speed bonus, sweetspot penalty, hold bonus, etc). No guarantees though, the function is enormous and I didn't spend too much time on it.
If a weapon has bonus to shields, then it deals double raw_damage. I didn't see any 'armor reduce' type code, or any code for specific damage types, but I may have just missed them.
e: just saw a stab from a long axe get the bonus to shield damage.