Is there a noop command in Doxygen? - 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"

Related

Forcing the order of arguments in function generated for a "alias"

When I create an alias like:
alias "myA" "PREFIX $argv SUFFIX"
fish genarates a function with body equivalent to: "PREFIX SUFFIX $argv.
Is there a trick/hack/legitimate way to force the shell so that the call myA 1234 is executed as PREFIX 1234 SUFFIX?
I know how to do that by writing a function. I generate about 15+ of these, on the fly, and the PREFIX, SUFFIX strings keep changing very frequently. So it is not practical to write a function.
Thanks!
Cheers; 'best,
shankar
You seem to have misunderstood what the alias command does. It does define a function. But it does not do the transformation you imply. It only appears to do so because you double-quoted the alias definition. Which means that $argv is interpolated before the function is created. If, as is likely to be the case, $argv is undefined (or the empty array) then "PREFIX $argv SUFFIX" is equivalent to "PREFIX SUFFIX".
To answer your question: No, there is no way to do what you want using the alias command. Honestly, I think alias should never have been added to fish as it isn't needed and simply confuses people migrating from bash where the concept of an "alias" is very different. It's trivial to replace
alias myA "PREFIX $argv SUFFIX"
with
function myA; PREFIX $argv SUFFIX; end

What is the Powershell ${^} variable?

I recently learned that you can use special characters in PowerShell variables, e.g.: ${hello world!}, but then I stumbled across this:
${^}
What does it do? I first thought it referenced the newest created variable, but it does other stuff I haven't really figured out.
The documentation says:
Contains the first token in the last line received by the session.
Examples:
dir c:\windows 🡒 dir
0..9 🡒 0
&{ dir } 🡒 &
It was likely introduced to get the last command used (dir, copy, rm, ...), but in reality that will only work for the most simplest cases, and thus it's not very useful.
The corresponding $$ returns the last token from the last line.
Note: The curly braces {} are only necessary for variable names containing characters which are not allowed in variables, except automatic variables (look here). In this case, you can omit them:
$^
It shows the first word/token in the last executed command.

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.

Uppercasing filename in Makefile using sed

I try to convert a filename such as foo/bar/baz.proto into something like foo/bar/Baz.java in my Makefile. For this purpose, I thought I could use sed. However, it seems that the command does not work as expected:
uppercase_file = $(shell echo "$(1)" | sed 's/\(.*\/\)\(.*\)/\1\u\2/')
# generated Java sources
PROTO_JAVA_TARGETS := ${PROTO_SPECS:$(SRCDIR)/%.proto=$(JAVAGEN)/$(call uppercase_file,%).java}
When I try to run the sed command on the command line it seems to work:
~$ echo "foo/bar/baz" | sed 's/\(.*\/\)\(.*\)/\1\u\2/'
foo/bar/Baz
Any ideas why this does not work inside the Makefile?
UPDATE:
The java files are generated with the following target:
$(JAVAGEN)/%.java: $(SRCDIR)/%.proto
How can I apply the substitution also for targets?
GNU Make does not replace % character in the replacement part of a substitution reference (which is basically a syntactic sugar for patsubst) if it is part of a variable reference. I have not found this behavior described in the documentation, but you can look it implemented in the source code (the relevant function I believe is find_char_unquote).
I suggest moving the call out of the substitution reference, since uppercase_file obviously works properly on any file path:
PROTO_JAVA_TARGETS := $(call uppercase_file,${PROTO_SPECS:$(SRCDIR)/%.proto=$(JAVAGEN)/%.java})
If $(PROTO_SPECS) resolves not to a single element, but rather to a list of elements, you can use foreach to call the function on every elements of a processed list:
PROTO_JAVA_TARGETS := $(foreach JAVA,${PROTO_SPECS:$(SRCDIR)/%.proto=$(JAVAGEN)/%.java},$(call uppercase_file,$(JAVA)))
The java files are generated with the following target: $(JAVAGEN)/%.java: $(SRCDIR)/%.proto
How can I apply the substitution also for targets?
Since Make matches targets first, and there is no way to run sed backwards, what you need here is either define an inverse function, or generate multiple explicit rules. I will show the latter approach.
define java_from_proto
$(call uppercase_file,$(1:$(SRCDIR)/%.proto=$(JAVAGEN)/%.java)): $1
# Whatever recipe you use.
# Use `$$#`, `$$<` and so on instead of `$#` or `$<`.
endef
$(foreach PROTO,$(PROTO_SPECS),$(eval $(call java_from_proto,$(PROTO))))
We basically generate one rule per file in $(PROTO_SPEC) using a multiline variable syntax, and then use eval to install that rule. There is also a very similar example on this documentation page that can be helpful.