Cross posted on StackExchange: Improving paclet formatting
For such an increasingly relevant data type the Paclet
has a particularly useless formatted form.
Can we do better?
In particular we'll want the Paclet
Format
to be attractive, show particularly relevant paclet info, and be customizable.
Here's my version, to get people started:
pacletKeyOrdering =
{
"Name", "Version", "Creator",
"Description", "Root", "WolframVersion",
"MathematicaVersion", "Internal", "Loading",
"Qualifier", "SystemID", "BuildNumber",
"Tags", "Icon", "Categories",
"Authors", "Extensions"
};
With[{keyOrdering = pacletKeyOrdering},
pacletInfoAssociation[PacletManager`Paclet[k__]] :=
KeySortBy[First@FirstPosition[keyOrdering, #] &]@
With[
{
base =
KeyMap[Replace[s_Symbol :> SymbolName[s]], <|k|>]
},
ReplacePart[base,
"Extensions" ->
AssociationThread[
First /@ Lookup[base, "Extensions", {}],
Association@*Rest /@ Lookup[base, "Extensions", {}]
]
]
]
];
If[! AssociationQ@$pacletIconCache, $pacletIconCache = <||>];
pacletGetIcon[a_Association] :=
Replace[
FileNames[
Lookup[
a,
"Icon",
"PacletIcon.m" | "PacletIcon.png"
],
a["Location"]
],
{
{f_, ___} :>
Lookup[$pacletIconCache, f, $pacletIconCache[f] = Import[f]],
{} :>
With[{f =
"https://github.com/b3m2a1/mathematica-BTools/raw/master/\
Resources/Icons/PacletIcon.png"
},
Image[
Lookup[$pacletIconCache, f, $pacletIconCache[f] = Import[f]],
ImageSize -> 28
]
]
}
];
$formatPaclets = True;
Format[p_PacletManager`Paclet /;
($formatPaclets && AssociationQ@
pacletInfoAssociation[p])] :=
With[{a = pacletInfoAssociation[p]},
RawBoxes@
BoxForm`ArrangeSummaryBox[
"Paclet",
p,
pacletGetIcon[a],
KeyValueMap[
BoxForm`MakeSummaryItem[
{Row[{#, ": "}], #2},
StandardForm
] &,
a[[{"Name", "Version"}]]
],
Join[
{
If[KeyMemberQ[a, "Location"],
BoxForm`MakeSummaryItem[
{Row[{"Location", ": "}],
With[{l = a["Location"]},
Button[
Hyperlink[l],
SystemOpen[l],
Appearance -> None,
BaseStyle -> "Hyperlink"
]
]},
StandardForm
],
Nothing
]
},
KeyValueMap[
BoxForm`MakeSummaryItem[
{Row[{#, ": "}], #2},
StandardForm
] &,
KeyDrop[a, {"Name", "Version", "Location"}]
]
],
StandardForm
]
];
FormatValues[PacletManager`Paclet] =
SortBy[
FormatValues[PacletManager`Paclet],
FreeQ[HoldPattern[$formatPaclets]]
];
This is what I use in my own packages. It makes paclets that look like this:
PacletFind /@ {"BTools", "ChemTools"} // Flatten

(sorry about bad raster quality)
Of course where this is actually useful is that it shows you what's inside the paclet:
PacletFind["MQTTLink"][[1]]
