doc/sod.sty, doc/runtime.tex: Improve comment typesetting in code.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 22 Jul 2017 17:13:30 +0000 (18:13 +0100)
  * 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.

doc/runtime.tex
doc/sod.sty

index b357f75..0490763 100644 (file)
@@ -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}
 
index 9c9aaf8..d6a8a65 100644 (file)
 \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