Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3282 > unrolled thread

Re: Convenient way to add inline formatting to usage Messages

Started byMike Bryniarski <michael.bryniarski@gmail.com>
First post2011-06-24 11:53 +0000
Last post2011-06-24 11:53 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Convenient way to add inline formatting to usage Messages Mike Bryniarski <michael.bryniarski@gmail.com> - 2011-06-24 11:53 +0000

#3282 — Re: Convenient way to add inline formatting to usage Messages

FromMike Bryniarski <michael.bryniarski@gmail.com>
Date2011-06-24 11:53 +0000
SubjectRe: Convenient way to add inline formatting to usage Messages
Message-ID<iu1tr1$9lf$1@smc.vnet.net>
On second examination, it's not really clear to me what you are looking to 
accomplish and my initial response wasn't very useful. I think the styles in question are just used to format internal stuff consistently; they have names like "TI"(Times Italic?) and "SO" (Sans Oblique).

Are you looking for a way to automate the formatting usage messages? I don't think there is any built in system for doing that so you would have to style your messages manually. For functions with flat sequences of arguments you could do something like:

ClearAll[makeUsageTemplateString, makeStyledString];
Attributes[makeUsageTemplateString] = {HoldAll};
makeUsageTemplateString[fn_[args___], style_: "TI"] :=
  ToString[Defer[fn] @@
    Thread[Style[{args}, style, StripOnInput -> True]], StandardForm];

makeStyledString[str_String, style_: "TI"] :=
  ToString[Style[str, style, StripOnInput -> True], StandardForm];

makeUsageTemplateString::usage =
  makeUsageTemplateString[makeUsageTemplateString["f", "sty"]] <>
   " applies the style " <> makeStyledString["sty"] <>
   " returns the function " <> makeStyledString["f"] <> " as string.";

makeUsageTemplateString::usage // FullForm

If you want the RowBoxs included you may need to do some stuff with MakeBoxes. I don't see much point in this since the ctrl+shift+K template stuff works properly with this setup.

I hope this is helpful


On Tuesday, June 21, 2011 4:52:57 AM UTC-5, Alexey Popkov wrote:
> Usage Messages of built-in functions have embedded in-line formatting. For example:
>
> In[1]:= AiryAiPrime::usage // FullForm
> Out[1]//FullForm=
> "\!\(\*RowBox[{\"AiryAiPrime\", \"[\", StyleBox[\"z\", \"TI\"], \"]\"}]\) gives the derivative of the Airy function \!\(\*RowBox[{SuperscriptBox[\"Ai\", \"\[Prime]\"], \"(\", StyleBox[\"z\", \"TI\"], \")\"}]\). "
>
> One can see that this in-line formatting is based on the set of styles defined in "Styles for Inline Formatting" section of the Core.nb stylesheet. But I have not found any description of these styles as well as any description of the convenient way to add formatting to usage Messages.
>
> What is the convenient way to add in-line formatting to user-defined usage Messages in Mathematica? What are the usage rules of default styles for in-line formatting defined in the Core.nb stylesheet? I would like to add in-line formating for messages in my package just with Mathematica, without installing additional components like Workbench etc.

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web