Just found out that all the good documentation for the DBMS_METADATA package is in the Utilities manual. I’ve just been looking at the “PL/SQL Packages and Types Reference” manual for the details of how to use DBMS_METADATA. I’ve been handcuffing myself for years. There are lots of good examples in the Utilities manual. In the 11.2 manual it is chapter 20 “Using the Metadata APIs”.
DBMS_METADATA lets you extract the SQL needed to recreate tables, packages, etc.