From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: doc/sod.sty, doc/runtime.tex: Improve comment typesetting in code. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/888d5e58c8cff289ff56a9282608c153b402191c?ds=inline doc/sod.sty, doc/runtime.tex: Improve comment typesetting in code. * Don't typeset the initial `;' as commentary; handle multiple initial `;;' in sequence. * Add new commands for general inside-comment typesetting, and for C-style `/* ... */' comments. Maybe there should be a thing for C++-style comments, but I don't tend to use them anyway. * Highlight code text in commentary. --- diff --git a/doc/runtime.tex b/doc/runtime.tex index b357f75..0490763 100644 --- a/doc/runtime.tex +++ b/doc/runtime.tex @@ -572,11 +572,12 @@ particular keyword argument. kw_unkhook = oldunk; \- @\\ \\ \} while (0) \\+ - /* Example of use */ \\ + @/* Example of use */ \\ int f; \\ KW_TEST(f, somefunc(1, "two", 3, KWARGS_TEST("shiny", 68.7))); \\ - /\=* now f is nonzero if `somefunc' accepts the `shiny' keyword \+ \\ - {}* (which we hope wants a double argument) \\ + /\=* \comment{now @|f| is nonzero if @|somefunc| accepts the + @|shiny| keyword} \+ \\ + {}* \comment{(which we hope wants a @|double| argument)} \\ {}*/ \end{prog} diff --git a/doc/sod.sty b/doc/sod.sty index 9c9aaf8..d6a8a65 100644 --- a/doc/sod.sty +++ b/doc/sod.sty @@ -119,7 +119,11 @@ \atdef -#1{\if>#1\hbox{--\raisebox{.4pt}{>}}\penalty200\relax\fi} %% Comment setting. -\atdef ;#1\\{\normalfont\itshape;#1\\} +\def\comment#1{\mbox{\normalfont\itshape\/#1\/}} +\atdef /*#1*/{/*\comment{#1}*/} +\def\@semis{\@ifnextchar;{;\@semis}\@semicomment} +\def\@semicomment#1\\{\comment{#1}\\} +\atdef ;#1\\{;\@semis} %% Environment for setting programs. Newlines are explicit, because %% otherwise I need comments in weird places to make the vertical spacing