Obtaining the source of released debian packages
rosinstall_generator can be used to get the source code of released packages. This is the tool used in the source installation instructions.
As of indigo most debian packages produced on the ROS buildfarm generated sourcedebs which are also made available via the debian repositories.
Alternatively, if you prefer to get the source of the released, installed version of a package using apt-get, first specify a deb-src entry in the apt sources. For example, update /etc/apt/sources.list.d/ros-latest.list as follows (substitute Ubuntu Xenial for the appropriate distribution):
deb http://packages.ros.org/ros/ubuntu xenial main + deb-src http://packages.ros.org/ros/ubuntu xenial main
apt-get source ros-ROSDISTRO-PACKAGE
apt-get source ros-kinetic-rospy
This downloads from the server all the files in the released version of the package (i.e. things not installed in the installation rule (e.g. CMakeLists.txt) are also included).