11
$\begingroup$

Upon building documentation in Workbench, Workbench sometimes converts the output of examples on function pages into rasterized images, and sometimes not. Does anybody know what controls this behavior?

For example, say if we have a package containing the following code:

MakeBoxes[tensor, StandardForm] = InterpretationBox[
    StyleBox@GridBox[
        {{
            "T", 
            StyleBox@GridBox[{{"a"}, {"b"}}]
        }}, 
        ColumnSpacings -> 0.05
    ], 
    tensor
];

TestSymbol[n_] := Table[tensor, {n}];

And let the documentation notebook of TestSymbol contain the following examples:

TestSymbol[1]
TestSymbol[2]
TestSymbol[3]
TestSymbol[4]
TestSymbol[5]
TestSymbol[6]

The output of the first 5 examples are left untouched by the documentation build process, but somehow output of the 6th gets rasterized. (And for any TestSymbol[n], with n > 5 for that matter).

The culprit seems to be the ColumnSpacings option; if I remove that then none of the output gets rasterized.

I tried digging through the documentation tools source code, but unfortunately that was like searching for a needle in a haystack. Does anybody have a clue what's causing this behavior?

$\endgroup$

1 Answer 1

2
$\begingroup$

Turns out the ColumnSpacings was a red herring; instead, the deciding factor here is notebook file size. From the source of Common.m of the Documentation Tools:

(* Here we shrink notebooks by converting graphics to bitmaps (but only if the resulting
   bitmap is smaller than the original Graphics expression). Also, as an optimization
   for the time it takes for this conversion process, only operate on notebooks that
   are at least a certain size. This process modifies the notebooks in place.
*)

This comment is right above the function that does the actual rasterization, ConvertGraphicsToBitmaps. If we replace it with

ConvertGraphicsToBitmaps[nb_NotebookObject, entityType_] := Null;

then no output cells are rasterized anymore.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.