Adding a custom command in doxygen [duplicate] - documentation

This question already has answers here:
Custom tags with Doxygen
(3 answers)
Closed 5 years ago.
I'd like to add a custom command to my doxygen documentation. Basically for each C function I'm writing doc for, I need to write which global variables are "touched" in read mode or write mode. It's like the "See also" list, just with a different caption.
In my file I'd like to write something like this:
/*
* \read-globals #var1, #var2
*
* \write-globals #var3
*/
I tried with an alias like this:
read-globals = \par <b>Globals read</b>\n
It works but I fear that it's style sheet independent: If tomorrow I'll want to change css, then this custom command will generate output which looks different from seealso, author and all other sections.
Basically I just want to copy the format from other standard commands.
Another option is to use to the \xrefitem command, which works too, but it requires to introduce a section as second parameter which is totally useless in my case (maybe it can be hidden somehow?).
Is there a "right way" to achieve my goal?

You can combine \xrefitem and ALIASES if you want to hide the second parameter. Here is an example I use for requirements:
ALIASES += "req=\xrefitem req \"Requirement\" \"Requirements\" "
Then in documented code:
/// \req #42 The system shall work in any situation
(from my answer to that question: Custom tags with Doxygen)

Related

regex limitations within live template / can use live-template functions as replacement?

I'm removing builder pattern on multiple places. Following example would help me with the task, but mainly I'd like to learn how to use live templates more.
Preexisting code:
Something s = s.builder
.a(...)
.b(bbb)
.build();
and I'd like to remove it to:
Something s = new Something();
s.setA(...);
s.setB(bbb);
part of it can be trivially done using intellij regex, pattern: \.(.*)$ and replacement .set\u$1. Well it could be improved, but lets keep it simple.
I can create surround live template using variable:
regularExpression(SELECTION, "\\.(.*)", "\\u$1")
but \\u will be evaluated as u.
question 1: is it possible to get into here somehow \u functionality?
but I might get around is differently, so why not try to use live temlate variable:
regularExpression(SELECTION, "\\.(.)(.*)", concat(capitalize($1), "$2"))
but this does not seem to work either. .abc is replaced to bc
question 2: why? How would correct template look like? And probably, if it worked, this would behave incorrectly for multiline input. How to make it working and also for multiline inputs?
sorry for questions, I didn't find any harder examples of live templates than trivial replacements.
No, there is no \u functionality in the regularExpression() Live Template macro. It is just a way to call String.replaceAll(), which doesn't support \u.
You can create a Live Template like this:
set$VAR$
And set the following expression for the $VAR$ variable:
capitalize(regularExpression(SELECTION, "\\.(.*)", "$1"))

Include preferences from a topic

How to include preferences from another topic in Foswiki 1.1.9? This approach doesn't work for me:
Sandbox.MyPreferences
* Set FOO = 1
Sandbox.UseFoo
%INCLUDE{"Sandbox.MyPreferences"}%
Value for FOO is %FOO%
Output of Sandbox.UseFoo
Value for FOO is %FOO%
Another possibility would be to use SpreadSheet variables to accomplish something similar. Unlike Foswiki Preferences, spreadsheet variables can be set in an included topic and then used in the including topic. I've seen this used to centralize a number of calculations into a separate include topic which can then be referenced in a number of topics.
I wrote up an example from a past life. See http://foswiki.org/Support/BestPracticeTip33
No, that's not possible. * Set lists can't be %INCLUDed. However the upcoming Foswiki-1.2.0 will have a macro-equivalent to * Set which in fact will
allow you to %INCLUDE them as you described. See http://foswiki.org/Development/SettingAndGettingVariablesUsingMacros.

Add JSF components at runtime that you don't know during compile time [duplicate]

This question already has answers here:
How to dynamically add JSF components
(3 answers)
Closed 6 years ago.
I couldn't find a solution for this in other posts, so here is my problem.
(In advance, I use JSF 2 with Mojarra implementation and Primefaces 3.2 on a JBoss 7.1 AS)
I am building a search-mask that should be generated dynamically during runtime. I know from another post that I should use a dataTable for that. That is what I will do.
But the search-mask consists of 3 parts, the search-criterion (e.g. name, birthday,...), the operator (is, is not, larger than, in range,...) and the operand (what the user will give as search-input).
My goal is to get the search-mask get generated dynamically, BUT the type of input field is dependent on what criterion+operator has been choosen by the user.
So if the user chose criterion: "name" and operator: "is not" from the dropdown boxes, then the input field for the operand should be just a simple p:inputText.
But if the user chose criterion "birthday" and operator: "before", then the input field should be a datepicker like p:calendar.
My idea was to use a p:dataTable for a List of "SearchRow" objects where every object has an array of criteria and operands to use them in a h:selectOneMenu.
Then I add a valueChangeListener to the selectMenues and in there I calculate and create the right type of UIComponent I need as inputfield.
But I have no idea how to add that UICOmponent as the 3rd column inside the dataTable.
So is my idea any good and is there a way at all to solve my problem?
Thanks in advance!
Same solution as to the Problem described here. The article from #BalusC explains very nicely how to add components from the bean.

Execute coldfusion code stored in a string dynamically?

I have an email body stored as a string in a database, something like this:
This is an email body containing lots of different variables. Dear #name#, <br/> Please contact #representativeName# for further details.
I pull this field from the database using a stored proc, and then I want to evaluate it on the coldfusion side, so that instead of "#name#", it will insert the value of the name variable.
I've tried using evaluate, but that only seems to work if there's just a variable name. It throws an error because of the other text.
(I can't just use placeholders and a find/replace like this - Resolving variables inside a Coldfusion string, because the whole point of storing this in a database is that the variables used to build the string are dynamic. For example, in one case the name field can be called "name" and in another it could be "firstName", etc.)
I would loop over each #variableName# reference and replace it with the evaluated version.
A regex will be able to find them all and then a loop to go over them all and just evaluate them one by one.
You need to write it to a file and CFINCLUDE it. This will incur a compilation overhead, but that's unavoidable.
Can you not save the code to the file system and just store a reference to where it is in the DB? That way it'll only get recompiled when it changes, rather than every time you come to use it?
<!--- pseudo code --->
<cfquery name="q">
SELECT fileContent // [etc]
</cfquery>
<cfset fileWrite(expandPath("/path/to/file/to/write/code.cfm"), q.fileContent)>
<cfinclude template="/path/to/file/to/write/code.cfm">
<cfset fileDelete(expandPath("/path/to/file/to/write/code.cfm"))>
That's the basic idea: get the code, write the code, include the code, delete the code. Although you'll want to make sure the file that gets created doesn't collide with any other file (use a UUID as the file name, or something, as per someone else's suggestion).
You're also gonna want to load test this. I doubt it'll perform very well. Others have suggested using the virtual file system, but I am not so sure there'll be much of a gain there: it's the compilation process that takes the time, not the actual file ops. But it's worth investigating.
Are you using ColdFusion 9 or Railo? If yes, writing to and including in-memory files may be quick and simple solution. Just generate file name with something like CreateUUID() to avoid collisions.
So basically, after researching and reading the answers, it seems that these are my options:
Have separate fields in the table for each variable and evaluate them individually. e.g. nameVariable, reprNameVariable, and then I can build the body with code like this:
This is an email body containing lots of different variables. Dear #evaluate(nameVariable)#, <br/> Please contact #evaluate(reprNameVariable)# for further details.
Have an "emailBody" field with all the text and applicable field names, and write it to a temporary file and cfinclude it. (As suggested by Adam Cameron, and I think that's what Sergii's getting at)
Have an "emailBody" field and write code to loop over it, find all coldfusion variables, and replace them with their "evaluate"d version. (As suggested by Dale Fraser)
Have small template files, one for each report type, with the email body, and have a field "emailBodyTemplate" that indicates which template to include. (As suggested by Adam Cameron)
Now I just have to decide which to use :) When I do, I'll accept the answer of the person who suggested that method (unless it's one that wasn't suggested, in which case I'll probably accept this, or if someone comes up with another method that makes more sense)
It's been a while since you posted this - but it's EXACTLY what I do. I found your question while looking for something else.
I've simply created my own simple syntax for variables when I write my emails into the database:
Hello ~FirstName~ ~LastName~,
Then, in my sending cfm file, I pull the email text from the database, and save it to a variable:
<cfset EmailBody = mydatabasequery.HTMLBody>
Then I quickly strip my own syntax with my variables (from another query called RecipientList):
<cfset EmailBody = ReplaceNoCase(EmailBody, "~FirstName~", "#RecipientList.First#", "ALL")>
<cfset EmailBody = ReplaceNoCase(EmailBody, "~LastName~", "#RecipientList.Last#", "ALL")>
Then I simply send my email:
<cfmail ....>#EmailBody#</cfmail>
I hope you manage to see this. If you control the authoring of the email messages, which I suspect you do, this should work well.
Russell

Is there any way I can define a variable in LaTeX?

In LaTeX, how can I define a string variable whose content is used instead of the variable in the compiled PDF?
Let's say I'm writing a tech doc on a software and I want to define the package name in the preamble or somewhere so that if its name changes, I don't have to replace it in a lot of places but only in one place.
add the following to you preamble:
\newcommand{\newCommandName}{text to insert}
Then you can just use \newCommandName{} in the text
For more info on \newcommand, see e.g. wikibooks
Example:
\documentclass{article}
\newcommand\x{30}
\begin{document}
\x
\end{document}
Output:
30
Use \def command:
\def \variable {Something that's better to use as a variable}
Be aware that \def overrides preexisting macros without any warnings and therefore can cause various subtle errors. To overcome this either use namespaced variables like my_var or fall back to \newcommand, \renewcommand commands instead.
For variables describing distances, you would use \newlength (and manipulate the values with \setlength, \addlength, \settoheight, \settolength and \settodepth).
Similarly you have access to \newcounter for things like section and figure numbers which should increment throughout the document. I've used this one in the past to provide code samples that were numbered separatly of other figures...
Also of note is \makebox which allows you to store a bit of laid-out document for later re-use (and for use with \settolength...).
If you want to use \newcommand, you can also include \usepackage{xspace} and define command by \newcommand{\newCommandName}{text to insert\xspace}.
This can allow you to just use \newCommandName rather than \newCommandName{}.
For more detail, http://www.math.tamu.edu/~harold.boas/courses/math696/why-macros.html
I think you probably want to use a token list for this purpose:
to set up the token list
\newtoks\packagename
to assign the name:
\packagename={New Name for the package}
to put the name into your output:
\the\packagename.