As already stated, both the doors and hard top from a CJ7 WILL fit on a YJ.
There are a few things to a aware of though.
1: early CJ's used a "twist" style handle on the doors. If using these early CJ doors, you'll need to modify the striker on the tub of the YJ. If using later doors witht the "paddle" style handles, no modifications are needed.
2: CJ's have a drop down tail gate, and the hard tops on them were designed to close after/open before the tail gate. If you still have the stock spare tire mount/3rd brake light, it can be a little tricky. You'll have to open/close the tail gate and hard top hatch at the same time in order to get the hatch between the tailgate and spare.
3: CJ's did not have the spreader/sport bars (the ones that go from the roll bar to the windshield frame. Because of this, you may have to "clearance" the hard top to fit around the spreader bar mounting flange on the windshield frame.
just for reference, I have a CJ7 hard top and doors on my 93 YJ, here's a pic,