Package Usage and Development » Paclet Development

Sample Paclets

It can be unclear what type of directory/paclet info structure we want, so we'll go over a number of the different common types.

Keep in mind that you can always mix-and-match with these template structures. I'm just showing how a pure, modularized paclet of each type can be constructed.

Code Paclet

The most common type of paclet is one that just serves code and maybe some front-end/system resources. To get this type of paclet up-and-running we'll take our directory structure to look something like:

 
 MyPaclet 
  + PacletInfo.m 
  Kernel 
   + init.m 
   + Component1.m 
   + Component2.m 
   ...
 + MyPaclet.m

And the PacletInfo.m will be

 Paclet[
  Name        -> "MyPaclet",
  Version     -> "1.0.0",
  Creator     -> "me <me@me.me>",
  Description -> "A world-changing application",
  Extensions  ->{
    {"Kernel", "Root"->".", "Context"->{"MyPaclet`"}}
    }
  ]

Documentation Paclet

Sometimes we just want to distribute documentation, as it can be bulky and unwieldy. If this is the case, we'll want to use a directory structure that looks like:

The most common type of paclet is one that just serves code and maybe some front-end/system resources. To get this type of paclet up-and-running we'll take our directory structure to look something like:

 
 Documentation_MyPaclet 
  + PacletInfo.m 
  Documentation 
   English 
    ReferencePages 
     Symbols 
      + SymbolPage1.nb 
      + SymbolPage2.nb 
      ... 
     Guides 
      + MyPaclet.nb 
      + Guide1.nb 
      ... 
     Tutorials 
      + Tutorial1.nb 
      + Tutorial2.nb 
      ...

And the PacletInfo.m will be

 Paclet[
  Name        -> "Documentation_MyPaclet",
  Version     -> "0.0.1",
  Creator     -> "me <me@me.me>",
  Description -> "Documentation for MyPaclet",
  Extensions  ->{
    {
      "Documentation",
    "Root"->".", 
    "LinkBase"->"MyPaclet",
      "MainPage"->"Guides/MyPaclet"
      }
    }
  ]

We use a small version number that won't conflict with the main MyPaclet ever

FrontEnd Paclet

Sometimes we want to package versioned FE resources separately from a package, or simply pass around standalone palettes and stylesheets. If this is the case we want a front-end paclet, which has a directory structure like:

 
 FrontEnd_MyPaclet 
  + PacletInfo.m 
  FrontEnd 
   StyleSheets 
    MyPaclet 
     + StyleSheet1.nb 
     ... 
   Palettes 
    MyPaclet 
     + Palettes.nb 
     ... 
   SystemResources 
    MyPaclet 
     + SystemResource1.nb 
     + SystemResource2.txt 
     + SystemResource3.png 
     ... 
    Bitmaps 
     MyPaclet 
      + Bitmap1.png 
      + Bitmap2.png 
      ... 
  TextResources 
   MyPaclet 
    + TextResource1.tr 
    + TextResource2.tr 
    ...

And we'd have a pretty simple PacletInfo.m

 Paclet[
  Name        -> "FrontEnd_MyPaclet",
  Version     -> "0.0.1",
  Creator     -> "me <me@me.me>",
  Description -> "FrontEnd resources for MyPaclet",
  Extensions  ->{ {"FrontEnd"} }
  ]

Resource Paclet

Sometimes we want to package versioned FE resources separately from a package, or simply pass around standalone palettes and stylesheets. If this is the case we want a front-end paclet, which has a directory structure like:

 
 Resources_MyPaclet 
  + PacletInfo.m 
  Resources 
   + Resource1.mx 
   Templates 
    + Template1.nb 
    + Template2.nb 
    ...
  ... 

And we'll have a PacletInfo.m that looks like:

 Paclet[
  Name        -> "Resources_MyPaclet",
  Version     -> "0.0.1",
  Creator     -> "me <me@me.me>",
  Description -> "Basic resources for MyPaclet",
  Extensions  ->{ 
    {
      "Resource",
      "Root"->"Resources",
      "Resources"->
        {
          {"Resource1", "Resource1.mx"},
          {"Template1", "Templates/Template1.mx"},
          {"Template2", "Templates/Template2.mx"}
          }
      }
    }
  ]

Data Paclet

Before its curated data system got wrapped into the Entity Framework , Mathematica distributed its curated data via the DataPaclets system. These are resource paclets that simply distribute version controlled data.

We can still make use of this system ourselves, though, as done here . Even if we don't want to hook into that system directly, we can make use of this kind of setup by setting up a directory like:

 
 Data_MyPaclet 
  + PacletInfo.m 
  Data 
   + MyPacletData.wdx 
   + MyPacletHDF5Data.h5 
   ...

Then the PacletInfo.m looks almost exactly like a resource paclet

 Paclet[
  Name        -> "Data_MyPaclet",
  Version     -> "0.0.1",
  Creator     -> "me <me@me.me>",
  Description -> "Data for MyPaclet",
  Extensions  ->{
    {
      "Resource",
    "Root"->"Data", 
    "Resources"->
     {
      {"Data", "MyPacletData.wdx"},
      {"HDF5Data", "MyPacletHDF5Data.h5"},
      ...
          }
      }
    }
  ]