Creating Paclets

Wolfram Language paclets are the standard way to extend the Wolfram System with new functionality. Paclets can include Wolfram Language code, documentation, assets and data files, palettes, stylesheets, Wolfram LibraryLink modules and more. Paclets can be shared as a .paclet file or deployed to the Wolfram Cloud.
Creating a Basic Paclet
The PacletTools package provides functions useful for creating and developing paclets.
CreatePaclet
create a new paclet within a specified directory
PacletDocumentationBuild
build documentation for a paclet
Use the CreatePaclet function to create the initial content for your paclet. Begin by evaluating the following statements to load PacletTools and create your new paclet:
To view the files in your new paclet in your operating system's file browser application, evaluate the following:
By default, the following files and directories are created automatically:

1.gif

The presence of a PacletInfo.wl file indicates that this directory contains a paclet. PacletInfo files contain the programmatic description of the paclet, in the form of a PacletObject declaration. The contents of the new PacletInfo.wl file will look something like this:
PacletObject[<|
    "Name" -> "MyPaclet",
    "Version" -> "1.0.0",
    "WolframVersion" -> "12.3+",
    "Extensions" -> {
        {"Kernel", "Root" -> "Kernel", "Context" -> "MyPaclet`"},
        {"Documentation"}
    }
|>]
Sample contents of MyPaclet/PacletInfo.wl.
This PacletInfo.wl file declares that this paclet is called "MyPaclet", that its version number is "1.0.0" and that it is compatible with versions of the Wolfram System greater than or equal to 12.3. It also declares that MyPaclet extends the system with new "Kernel" (Wolfram Language code) and "Documentation" content.
Note that although the new paclet was created by using CreatePaclet, the system is not yet aware of the paclet:
Later on, you will use PacletInstall to install the finished paclet for use in future sessions, but during development, you can temporarily tell the system about the paclet using PacletDirectoryLoad:
The paclet will now be visible to the system for the remainder of the current session:

Wolfram Language Packages

Almost all paclets extend the Wolfram System with new packages. Packages are named collections of Wolfram Language source code. The name of a package must be a valid Wolfram Language context. See "Wolfram Language Packages" for more information about contexts and the structure of packages.
In the PacletInfo.wl file content shown previously, the "Context" property in the "Kernel" extension declares to the system that the source code for the "MyPaclet`" package is provided by this paclet:
        {"Kernel", "Root" -> "Kernel", "Context" -> "MyPaclet`"}
Code snippet showing the "Kernel" extension declaration from MyPaclet/PacletInfo.wl.
When MyPaclet is installed, this declaration makes it possible for users of the paclet to load the source code using Needs["MyPaclet`"].
This is the relationship between paclets and packages in the Wolfram System: MyPaclet is a paclet that extends the system with (among other things) a package called MyPaclet`. Note that the package(s) provided by a paclet (if any) is not required to have the same name as the paclet that provides it, but that is the standard naming convention adopted by the vast majority of paclets that provide packages.
The MyPaclet.wl file created by CreatePaclet contains placeholder content demonstrating the standard structure of a Wolfram Language package file:
BeginPackage["MyPaclet`"]

(* Declare your package's public symbols here. *)

SayHello

Begin["`Private`"]

(* Define your public and private symbols here. *)

SayHello[name_?StringQ] := Print["Hello ", name, "!"]


End[] (* End `Private` *)

EndPackage[]
Sample contents of MyPaclet/Kernel/MyPaclet.wl.
Load your package's code by evaluating:
Symbols from the MyPaclet` context can now be used:
See "Wolfram Language Packages" for information about standard practices for writing packages.

Authoring Documentation

In addition to extending the system with packages, paclets can also extend the system with new documentation, like this tech note page you are currently reading.
Documentation in the Wolfram System consists of specially prepared notebooks, of which the three most common types are symbol reference pages, guide pages and tech notes. These notebooks are authored using the DocumentationTools palette, and built into their final form using the DocumentationBuild package.
To add documentation to your paclet, begin by opening DocumentationTools by clicking the Palettes > DocumentationTools menu item.
Next, click the Add Paclet button at the top of the palette and navigate to the MyPaclet directory.
DocumentationTools will automatically add subdirectories to the Documentation directory for storing the different documentation types (note that tech notes live in the Tutorials directory):

3.gif

Creating a Symbol Reference Page

The most common type of Wolfram documentation pages are symbol reference pages (also called function reference pages). Symbol reference pages describe the usage and behavior of individual symbols defined by a package.
To create a symbol reference page, click the New Function Page button in the (F)unction tab of the DocumentationTools palette:

4.gif

Annotated screen capture showing the location of the New Function Page button in the DocumentationTools palette.
In the dialog prompt that appears, enter the name of the symbol you wish to document:

5.gif

Screen capture showing the New Function Page dialog. Enter the name of the new symbol reference page to create it.
Upon clicking OK, DocumentationTools will create a new symbol documentation "authoring" notebook in the Documentation/English/ReferencePages/Symbols/ directory of your paclet. Symbol documentation notebooks contain basic usage descriptions for the symbol, notes on behavior and available function options, links to related documentation pages, and examples. The DocumentationTools palette provides tools for inserting a variety of formatted content into documentation authoring notebooks.
Documentation authoring notebooks look different from the finished documentation that is built into the Wolfram System. Authoring notebooks are transformed into so-called "in-product" notebooks via a build process. Paclet documentation can be built using PacletDocumentationBuild:
By default, built paclet documentation is placed in the MyPaclet/build/MyPaclet/Documentation/ directory. The built SayHello.nb documentation can be opened by evaluating:

Building Your Paclet

Once your paclet is ready to be shared, it can be built into a distributable .paclet archive file using PacletBuild:
A .paclet archive file contains all of the content of a paclet in a single compressed file.
The build process performs several actions to prepare the paclet for release:
The Success object returned by PacletBuild includes a manifest of all files included in the built paclet (except the PacletInfo.wl file), as well as their file hashes:

Sharing Your Paclet

The .paclet file produced by PacletBuild contains the complete content of the paclet. If a .paclet file is shared with another user, they can install it persistently by evaluating:
The paclet can be uninstalled by evaluating:

Publishing to the cloud

Publishing a paclet to the Wolfram Cloud is a fast and easy way to share your paclet. Before publishing, ensure that your current session is connected to the Wolfram Cloud using CloudConnect:
If you do not have a Wolfram Cloud account, you can sign up for free from the cloud connection prompt, or by visiting www.wolframcloud.com.
To publish to the cloud, copy the .paclet file you created in the previous section to a CloudObject location:
By default, the cloud object will have private permissions: it is only viewable by the cloud account that created it:
To grant permission for another user or group to view the paclet cloud object, use SetPermissions:
To make the paclet cloud object viewable by everyone, specify "Public" permissions:
If you want to make the cloud object private again, use "Private" permissions:
To install the paclet locally from the CloudObject, evaluate:
Other users can install the paclet directly from the CloudObject URL:
PacletInstall["https://www.wolframcloud.com/obj/example/MyPaclet-0.0.1.paclet"]