Some packages and document styles had to redefine the command
\document
or \enddocument
to achieve their goal. This is no
longer necessary. You can now use the `hooks' \AtBeginDocument
and
\AtEndDocument
(see Section 4.6). Again, using these
hooks makes it less likely that your code breaks with future versions
of LaTeX. It also makes it more likely that your package can work
together with someone else's.
However, note that code in the \AtBeginDocument
hook is part of the
preamble. Thus there are restrictions on what can be put there; in
particular, no typesettting can be done.