Integrate into Cargo to analyze the whole package

I'm currently writing an analyzer for rust, currently I can analyze individual rs files via rustc_interface, but I want to support analysis of entire packages, how do I integrate my tool into cargo to analyze entire packages like rustdoc? As far as I know, the cargo doc is compiled layer by layer with the -L parameter, but I don't know how I can do that.