Added export scraper
Here's a scraper for export formats:
getFormatExportDataRaw[fmt_] :=
Block[{$Context =
"ItsASecretToEverybody`Private`", $ContextPath = {"System`"}},
Replace[
SelectFirst[
Map[Function@FileNameJoin@{#, fmt, "Export.m"},
System`ConvertersDump`$FormatsDirectory],
FileExistsQ, $Failed],
s_String :> s -> Import[s, "HeldExpressions"]
]
];
getFormatExportData[fmt_] :=
Module[{data, file},
data = getFormatExportDataRaw[fmt];
If[data =!= $Failed,
{file, data} = List @@ data;
data /. {
HoldPattern[Set[s_Symbol, v : _List | _Association]] :>
RuleCondition[Set[s, v], True]
};
With[{cont =
FirstCase[data, HoldPattern[Begin[c_]] :> c,
"System`FakeHo`", \[Infinity]]},
SortBy[
Switch[#[[1]], "FormatName", 0, "BinaryFormat", 2, "File",
3, _, 1] &
]@
Flatten@{
"DocumentedElements" ->
FirstCase[data,
HoldPattern[
Set[
_Symbol?(
Function[Null,
SymbolName[Unevaluated@#] == "$DocumentedElements",
HoldFirst
]),
v_]
] :> Hold@v, None, \[Infinity]],
"HiddenElements" ->
FirstCase[data,
HoldPattern[
Set[
_Symbol?(
Function[Null,
SymbolName[Unevaluated@#] == "$HiddenElements",
HoldFirst
]),
v_
]
] :> Hold@v,
None,
\[Infinity]],
FirstCase[data,
HoldPattern[
ImportExport`RegisterExport[fmtName_,
function_,
ruls___?System`ConvertersDump`RuleQ
]
] :> {
"FormatName" -> fmtName,
"Function" -> function,
Replace[{ruls},
("AvailableElements" -> _Symbol) -> Nothing,
1],
"File" -> file
},
None,
\[Infinity]]
} /. s_Symbol?(
Function[Null,
Context[#] == "ItsASecretToEverybody`Private`",
HoldFirst
]
) :>
RuleCondition[
ToExpression[cont <> SymbolName[Unevaluated[s]],
StandardForm,
Inactivate
],
True]
],
{}
]
]