Here's a way around that, making use of the very-hard-to-work-with string-embedded syntax for boxes:
Remove[f]
f[a_] := 1;
f::usage = "\!\(f[\*StyleBox[\\\"message\\\", \"TI\", ShowStringCharacters->True]]\) generates a plot of \!\(\*StyleBox[\"f\", \"TI\"]\) as a function of \!\(\*StyleBox[\"x\", \"TI\"]\) from \!\(\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"min\", \"TI\"]]\) to \!\(\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"max\", \"TI\"]]\).";
What did I do here? First I took the ::usage
message for Plot
, coped out the first line, and then made modifications of the argument structure by hand. This will look like:
The styling trick is that I took the first StyleBox
in the message for Plot
and added a ShowStringCharacters->True
One weird thing that seems to come from how Mathematica parses these templates, if you want to add spaces to the message you need to do them in a RowBox
and change the formatting a bit, e.g.:
Remove[f]
f[a_] := 1;
f::usage = "\!\(f[\*StyleBox[RowBox[{\"\\\"this\", \" \", \"is\", \" \", \"a\", \" \", \"message\\\"\"}], \"TI\", ShowStringCharacters->True]]\) generates a plot of \!\(\*StyleBox[\"f\", \"TI\"]\) as a function of \!\(\*StyleBox[\"x\", \"TI\"]\) from \!\(\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"min\", \"TI\"]]\) to \!\(\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"max\", \"TI\"]]\).";