Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » creating a package
next | previous | forward | backward | up | index | toc

# creating a package

Creating a package is the most common way of contributing to Macaulay2. Packages can contain code for working with objects of a certain category, generating examples for testing a conjecture, or an implementation of algorithms introduced in the literature.

#### There are five parts to a Macaulay2 package

- the preamble, initiated by newPackage
- a list of exported functions and variables, set via export and exportMutable
- the code that constitutes the package
- the documentation for the package, which comes after beginDocumentation
- a number of tests for the new package, added using TEST or by adding files to a "tests" subdirectory of the package directory

See an example of a package for the basic template for new packages, or packageTemplate for a utility for generating the skeleton for a new package.

The name of the package must be the name of the file, without the .m2 suffix. Thus a package NewMath will be in a file named NewMath.m2. Other sources required by the package may be stored in a subdirectory named NewMath located in the same directory as the package.

### Documenting and testing a package

The documentation and tests included in a package inform others about how to use your package and ensure that your package continues to work with future versions of Macaulay2. See writing documentation for more information.

### Distributing a package

To add your package to the list of packages distributed with Macaulay2, authors can submit their package via a pull request to the GitHub repository for Macaulay2.

Before submitting your package, use the installPackage and check functions to ensure there are no errors in the package documentation and that all the tests pass.

## See also

- packages -- Macaulay2 packages
- writing documentation

### Menu

- an example of a package
- currentPackage -- the current package

#### Components of a package

- newPackage -- the preamble of a package
- export -- export symbols from a package
- exportFrom -- export symbols from a package's private dictionary
- exportMutable -- export mutable symbols from a package
- beginDocumentation -- start documentation section of a package
- TEST -- add a test for a package
- endPackage -- end a new package

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/ov_packages.m2:244:0.