A general formulation for librational dynamics of spacecraft with deploying appendages