I am looking for a way to have a readable documentation of a macro signature (probably not the correct wording, but I mean the same thing as a function signature) in the source code and in the output file.
A macro signature can be printed using for example the \cmd command from the ltxdoc package, e.g.
\cmd{\myCommand[my optional argument]{my mandatory argument}}
which is quite readable in the source code, but prints as
\myCommand[my optional argument]my mandatory argument
in the output file. This can, of course, be changed into
\cmd{\myCommand[my optional argument]\{my mandatory argument\}}
which gets printed as
\myCommand[my optional argument]{my mandatory argument}
but the source code readability is decreased, especially if there are many mandatory arguments. There are more commands defined in ltxdoc, but they all decrease source code readability and do not solve the problem.
Is there a way to define a macro \command to have both a readable source code and the correct output? For a readable source code, I think
\command{\myCommand[my optional argument]{my mandatory argument}}
would be the preferred way. But all trivial approaches to write such a macro fail, as the braces are already lost, when \command gets called.
Is there some way to change some catcode or something locally, so that the braces do not get lost? Is there some other clever syntax to achieve readability without problematic braces? Ideally, the command would support all possible definition when using xparse.


futureletand why it seem to have only two arguments. – Patrick Häcker Oct 01 '12 at 20:57