The tuning guide includes a block diagram.
http://plane.ardupilot.com/wiki/roll-pitch-controller-tuning/#Yaw_Controller
Essentially, there's a damping gain, which is a proportional gain on yaw rate error. There's a high-pass filter on the rate error, such that the rudder will tend to recenter itself. The turn coordination calculation takes a bank angle and airspeed, computes a yaw rate, and projects it onto the body Z axis. This means that the yaw damper won't try to oppose a banked turn. Then there's the SLIP gain, which in combination with the integrator gain, "steps on the ball" (Y accelerometer) in order to keep the aircraft in coordinated flight.