There are four parts to a Macaulay 2 package: a preamble which is initiated by the
newPackage function, a section where one defines which variables will be exported to global variables, a section containing the actual coding that constitutes the package, and a section containing documentation and tests for the new package.
A basic template for new packages:
newPackage( ... )
export{ ... }
exportMutable{ ... }
-- Macaulay 2 code goes here
beginDocumentation()
document { ... } -- several document's and TEST's, interspersed
TEST " ... "
The name of the package must be the name of the file, without the '.m2' suffix. Thus a package 'PACKAGENAME' will be in a file named 'PACKAGENAME.m2'. If the package were more complex, then by convention, there should be a directory named 'PACKAGENAME' on the load
path, and the file 'PACKAGENAME.m2' in this directory would load the necessary files.