How to use \addtogroup with an ALIASES command? - doxygen

I'm trying to create a custom command for easier group handling. The idea is in general...
ALIASES += opengroup{1}="^^* \addtogroup \1_GROUP ^^ * \{ ^^"
ALIASES += close="\}"
...to use in code file as...
/** \opengroup{LEVEL_1} */
// ...code statements...
/** \close */ // opengroup
...to get the doxygen result comment:
/**
* \addtogroup LEVEL_1_GROUP
* \{
*/
// ...code statements...
/** \} */ // opengroup
I tried with Doxygen 1.8.14. Unfortunately, this doesn't work. Any ideas?
Edit:
I think the root problem is the \addtogroup command with its syntax. My hope was to clear this with inserting '^^' to force a new line, but it seems to me doxygen is parsing the command in one line instead of resolving the '^^' new line in a pre-step...

A bit weird. With the alias:
ALIASES += opengroup{1}="^^* \addtogroup \1_GROUP ^^ * \\{ ^^"
so with a double backslash (\\) before the curly bracket open ({) I got it working.
I also get it working with:
ALIASES += opengroup{1}="^^* \addtogroup \1_GROUP ^^ * #{ ^^"
so it looks like the extra backslash is eaten at an unexpected place. The \ and # should be synonyms, but as \ is also an escape character so it is quite often tricky.
Note:
I used doxygen -d commentscan to see the replacement
Might change in the future as I think this might be a bug.
Problem is caused due to the fact that ALIASES can be nested and after a change the new string is seen as input. When needing a literal {, } or , in the expanded output one has to escape them with a \ and the \ is removed at the en. Problem here arises with the commands \{ and \} as here the \ serves as 'command indicator'. Best to use #{ and #} in case the 'block commands' are needed. the \} in \close doesn't have the problem as it is not re-evaluated.

Related

POSTGRESQL Dollar Quotes in Where Clause

For people who tried or needed a solution to escape every special character (even $) in a WHERE CLAUSE in POSTGRESQL, here is how it should be use
the documentation can be somehow hard to understand, and there is no proper example of it so here is mine
e.g : if you want to make a request looking as
SELECT
*
FROM
<TableName>
WHERE
<ColumnName> = 'string with ' character';
it will throw an error cause "character'" is outside the string
So here is how it should be written:
SELECT
*
FROM
<TableName>
WHERE
<ColumnName> = $$string with ' character$$;
The WHERE CONDITION will take the string literally; the interface may look broken but the following instruction will still be interpreted as expected.
SELECT
*
FROM
<TableName>
WHERE
<ColumnName> = $$string with ' character$$ AND <OtherColumnName> IS NOT NULL;
This could even be another escaped string with $$.
For details about dollar quoting, look at the documentation.

doxygen alias to struct, class, etc

I want to create some alias that that internally creates \struct command that refers to some specific struct and adds some additional commands:
ALIASES += "thing{2}=\struct \2 \n \n \xrefitem thingList\"\" \"List of Things\" \2 this thing belongs to that \ref \1"
the alias is invoked in some normal doxy-comment:
/**
*
* \thing{SomeThing, SomeThingStruct}
*
* \brief ..sdfsdf
*/
typedef struct sSomeTag SomeThingStruct;
It mainly does that it should and also the xrefitem list is generated correctly, but i get the error:
warning: the name `\_linebr' supplied as the argument of the \class, \struct, \union, or \include command is not an input file
because it interprets the \n in the alias as second argument to the \struct keyword
How can i define my alias that it does not produce this warning?
See documentation about ALIASES in the doxygen documentation.
A few points directly from the documentation:
ALIASES This tag can be used to specify a number of aliases that act
as commands in the documentation. An alias has the form: name=value
For example adding "sideeffect=#par Side Effects:\n" will allow you to
put the command \sideeffect (or #sideeffect) in the documentation,
which will result in a user-defined paragraph with heading "Side
Effects:". You can put \n's in the value part of an alias to insert
newlines (in the resulting output). You can put ^^ in the value part
of an alias to insert a newline as if a physical newline was in the
original file.
We see here the usage of the equal sign (=) (corrected in the mean time, had been forgotten during copying)
the use of upper case <-> lowercase (you should now have a message: warning: Found unknown command\thing'` (corrected in the mean time)
usage of \n might be ^^
SO the alias should read:
ALIASES += thing{2}="\struct \2 ^^ ^^ \xrefitem thingList\"\" \"List of Things\" \2 this thing belongs to that \ref \1"

Prevent powershell script arguments with asterisk from expanding into separate file names when passed to Java program [duplicate]

I wrote a program in Java that accepts input via command line arguments.
I get an input of two numbers and an operator from the command line.
To multiply two numbers, I have to give input as e.g. 5 3 *, but it's not working as written.
Why is it not accepting * from the command line?
That's because * is a shell wildcard: it has a special meaning to the shell, which expands it before passing it on to the command (in this case, java).
Since you need a literal *, you need to escape it from the shell. The exact way of escaping varies depending on your shell, but you can try:
java ProgramName 5 3 "*"
Or:
java ProgramName 5 3 \*
By the way, if you want to know what the shell does with the *, try printing the content of String[] args to your main method. You'll find that it will contain names of the files in your directory.
This can be handy if you need to pass some filenames as command line arguments.
See also
Wikipedia: glob
For example, if a directory contains two files, a.log and b.log then the command cat *.log will be expanded by the shell to cat a.log b.log
Wikipedia: Escape character
In Bourne shell (sh), the asterisk (*) and question mark (?) characters are wildcard characters expanded via globbing. Without a preceding escape character, an * will expand to the names of all files in the working directory that don't start with a period if and only if there are such files, otherwise * remains unexpanded. So to refer to a file literally called "*", the shell must be told not to interpret it in this way, by preceding it with a backslash (\).
Under MS WINDOWS not quite true: "java.exe" silently expands command line arguments with the wildcards
*
?
[abc]
, but only in the last component, so
a/*/*
does not work as you may expect.
It also ignores the entries "." and "..", but does honor other file names starting with ".".
To avoid misunderstandings: If I look at the command line of the running JAVA process with PROCEXP, I see the unexpanded args!
I found no way to work around this. In other words: As long as you have at least one file or directory in the current directory, "java Calc 3 * 7" will NOT work!
This is VERY ugly, and seems to always having been there in all JRE versions up to and including Java 8.
Does anybody have an idea how to disable Java's nasty command line expansion?
* has special meaning in shell interpreters. How to get a * literally is depending on what shell interpreter you are using. For Bash, you should put single quotes around the *, i.e. '*', instead of double quotes like "*".
Try surrounding the * with quotes like "*". The star is a reserved symbol on the command line.
Use single quotes:
java FooBar 5 3 '*'
This works with most of the popular shells (including bash and ksh).
Expanding on #Arno Unkrig's answer:
On Windows, some JVMs definitely do expand the "*" character, and it is not the shell expanding the path. You can confirm this by writing a small Java program that prints out the arguments:
public class TestArgs {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
System.out.println("Arg " + i + ": " + args[i]);
}
}
}
The good news is, there is a workaround! You can use #filename as an argument to JVM like this:
java #args.txt where args.txt is a text file that contains the arguments for each line. Example content:
TestArgs
*
This is equivalent to calling java with two arguments TestArgs and *. Most importantly, * is not expanded when it is included using the #filename method. I was able to find the details from this page.

doxygen: how to output backticks in a code section

i was wondering if it is possible to output backticks whithin a doxygen' code section.
~~~~~~~~~~
for file in `ls dir/*.filter`
do
done
~~~~~~~~~~
I get no output at all. And this seems to be caused by the backtick "`" i've inserted into my code section.
Does anyone had the same issue. Any suggestion?
many thanks
` is used to create an inline code block. Instead, use \code, \endcode rather than a markdown code block.
for example
\code
this is an inline `code block with ` characters
\endcode
renders with the ` characters included.
When a pair of `s is encountered in the code, doxygen will not process whatever is between.
The following will render correctly:
\code
for file in `ls dir/*.filter`
do
done
\endcode

Is there a noop command in Doxygen?

I have a aliased command that I'm using to generate an xrefitem page in my doxygen configuration.
ALIASES += "satisfy{2}=\xrefitem satisfy \"Satisfies\" \"Bottom up traceability\" requirement \1 in section: \ref \2"
If I want a second configuration that does not generate this page, and take out that alias I'm going to get a warning:
Warning: Found unknown command `\satisfy'
Is there a different alias I could enter that makes an essentially noop command?
I tried:
ALIASES += "satisfy{2}= \ref \2 Satisfies requirement \1
And:
ALIASES += "satisfy{2}= Satisfies requirement
But this resulted in the output just echoing the arguments.
{1114,intro1}
Any suggestions? Looking at the documentation for ALIASES, I'm not even sure how the original alias parameters work, the \1, \2 syntax isn't documented there.
Just to be clear I'm understanding the question. You have in your code text like
\satisfy Foo Bah. In the configuration without the xrefitem, you are still parsing the text but don't have the alias defined?
I believe you can have overloaded aliases, so does defining the following (with no parameters) help?
ALIASES += satisfy="Satisfies"
...but I'm unsure what you want to happen with the parameters in the non-cross-referenced case.
Alternatively, as written, I think you may have a typo (location of ") in the syntax of your later ALIAS definitions. I'd have expected:
ALIASES += satisfy{2}="\ref \2 Satisfies requirement \1"
Another alternative might be to define a NOOP with another alias:
ALIASES += noop{1}="\cond \1 \endcond"
or simply
ALIASES += satisfy{2}="\cond \2 \1 \endcond"
I just had the syntax wrong. Note the missing close quotes in the samples in my question.
Noop:
ALIASES += "satisfy{2}="
If you want plain text output:
ALIASES += "satisfy{2}=\2 satisfies \1"