The standard LaTeX files are distributed in the form of documented source
files.
They contain the coding for the actual files along with extensive comments
that not only describe the coding but also provide a user's manual. The
ending is normally .dtx. One processes this file with LaTeX
to obtain the manual and the commented coding. Optionally one can suppress
the coding and print only the manual.
Normally an installation file with ending .ins is also provided.
Processing this with LaTeX or TeX extracts the desired user files. These
are the package (.sty) or class (.cls) files, or any
other assessory files that might be needed.
Often a so-called driver file (.drv) is also extracted. LaTeXing this is
the same as LaTeXing the original .dtx file, the difference being that
one can edit the driver file to change paper type to A4 rather than standard
US letter size, or to suppress the printing of the coding.
My own .dtx files are set up as follows:
the .ins file is contained in it; it is extracted automatically
the first time the .dtx file is LaTeXed
only the manual part is printed when the .dtx file is LaTeXed
if one really wants to see the documented coding, one should take the .drv
file and deactivate the line \OnlyDescription by placing a % sign
in front of it; then LaTeX this .drv file.
As an example, the natbib sources are contained in natbib.dtx.
LaTeX natbib.dtx. If natbib.ins does not exist on your
system, it will be extracted.
LaTeX (or just TeX) natbib.ins. This produces
natbib.sty, the actual package file for the user
natnotes.tex, a 5-page reference sheet when LaTeXed
natbib.drv, a printer driver for the manual, that may be edited
LaTeX natbib.dtx (or natbib.drv) and print or view the
result for a manual