I use doxygen to generate xml which then i transform to a custom documentation.
Is there a possibility that doxygen includes the annotation of a field / class / function.
The annotation are ignored in both java and c#.
ex:
class User
{
[Required]
string UserName {get;set;}
}
the "Required" annotation is not parsed/displayed in doxygen.
What I would like to have in the xml / html output of doxygen is all the annotated Annotations of a property / field / class (in the ex. "[Required]").
EXTRACT_ALL=YES is useless in this case. Look at this answer, I think it is good idea:
Doxygen and add a value of an attribute to the output documentation
So you have to create filter (for example in phyton) which will be used by Doxygen to convert annotation to comment. Don’t forget to inform Doxygen about your filter: INPUT_FILTER = doxygenFilter.py
I have the same problem so I modified that example in this way:
#!/usr/bin/env python
import sys
import re
if (len(sys.argv) < 2):
print "No input file"
else:
f = open(sys.argv[1])
line = f.readline()
while line:
re1 = re.compile("\s*\[(.*)]\s*")
re1.search(line)
sys.stdout.write(re1.sub(r"/// <para>Annotation: [\1]</para>\n", line))
#sys.stdout.write(line)
line = f.readline()
f.close()
So code like
[AnyAnnotation()]
Will be converted to:
/// <param> Annotation [AnyAnnotation()] </param>`
So I got very nice result. Tag <param> is to avoid Doxygen put this annotation description to main description. Instead it will put it to remarks section.
I'm not sure what you're asking but I will say a few things that might help you.
Doxygen must be configured to produce documentation for code elements that have no Doxygen comments. In other words, you can tell Doxygen to produce documentation for all functions, variables, macros, etc even if they aren't documented in the code. Set EXTRACT_ALL=YES in your config file.
If you run DoxyWizard you will get a better feel for all of the available options and the effect of each option. DoxyWizard is the GUI front end to Doxygen.
And by the way, bravo for documenting your code!
Related
I want to convert my google protocol object to XML format. In that I would like to keep some fields as attribute.
Instead of :
<field>
<name>ApiFieldHeaderName</name>
<maxLength>50</maxLength>
</field>
I want following :
<field name="ApiFieldHeaderName" maxLength="50" ></field>
My protocol is
string name = 1;
int32 maxLength = 2;
And then I have gone through some forum and used xml_disposition
[(xml_disposition) = ATTRIBUTE]
However, I am getting the error:
Option "(xml_disposition)" unknown.
I am using proto3 and language is Java.
syntax = "proto3";
option optimize_for = SPEED;
I believe you've found xml_disposition from a side discussion on the protobuf newsgroup from 2009. The option mentioned, however, was purely hypothetical. As far as I know: no such xml_disposition custom option exists - and least, not as a standard option - and no code-generator looks for it. No mention of xml_disposition exists in the Google protobuf source, and the current version of protoc (3.5.1) does not recognise it and an inbuilt option.
So:
yes, it is possible to add custom extensions in .proto that you can annotate fields (etc) with
yes, you can write your own codegen tools to check for those custom options and emit additional generated code to implement what you want
but none of this ships by default
Side note: custom options must be defined in "proto2" syntax files, but a "proto3" file can still import and use those custom options from the "proto2" file.
I'm trying to put a custom element (a template name to use for the PKI) in my Certificate request that I generate using bouncycastle library.
The RFC says that you can use an extension that follows :
id-regInfo-utf8Pairs OBJECT IDENTIFIER ::= { id-regInfo 1 }
--with syntax UTF8Pairs ::= UTF8String
The few lines of code concerning this are
CertificateRequestMessageBuilder msgbuilder = new
CertificateRequestMessageBuilder(BigInteger.valueOf(reqId));
msgbuilder.addExtension(new ASN1ObjectIdentifier("1.3.6.1.5.5.7.7.5.2.1"), false, ???);
I can't find any information on what to put in that addExtension function, nor any example to adapt from.
I guess the new ASN1ObjectIdentifier("1.3.6.1.5.5.7.7.5.2.1") is close to what is expected, but the following ASN1Encodable that is supposed to be the value of that field is a mystery to me.
I just want to get something along template:encipherment in that field.
This seems like a pretty simple thing to do but the lack of documentation coupled to my lack of experience with BouncyCastle causes me a lot of problems.
The questions are :
Am I doing what I want the correct way ? (Using the extensions of the CRMF to convey my custom field)
If I do, how do I make this work ?
I use GWT I18N, which relies on annotations for messages with parameters.
Exemple :
#DefaultMessage("Here is a message <br/> with a param:{0}")
String messageToLocalize(String param);
In absence of a localized translation, the default message will be used.
I have some quite long strings to handle, which I would like to type in sevral lines for code readability (I don't speak about multiple lines for the rendered message).
I tried this :
#DefaultMessage("Here is a long \
message <br/> with a \
param:{0}")
String messageToLocalize(String param);
It fails (GWT PlugIn 4.2 and SDK 2.5.1) with an error "Invalid Escape Sequence".
Did I miss something ?
Is it a constraint on Java annotations or GWT ? (I am afraid so but couldn't find anything on that)
Is there a workaround ?
Thanks
Edit : Given first answers, the question must be rephrased : is it possible, and which character should I use to show continuation (if any) ?
The annotation processor obviously needs something to tell him.
I tried "\" because it is the char to use in property file ...
"+" does not work either.
Java doesn't support C-style string-lines representation, so you could not use such multi-line style neither in annotations declarations, neither in other places of code.
If you want multiply lines of single string, you have to do something like this:
#DefaultMessage("Here is a long " +
"message <br/> with a " +
"param:{0}")
As Andremoniy said, it must be cut using Java-style.
But otherwise, I recommend you to have a look at i18nCreator. It allows you to manage your i18n in properties files and have these Messages interfaces files automatically generated:
https://developers.google.com/web-toolkit/doc/latest/RefCommandLineTools#i18nCreator
(There is also a maven plugin: http://mojo.codehaus.org/gwt-maven-plugin/user-guide/i18n.html)
Try string concatenation that is done at compile time, so:
#DefaultMessage("Here is a long"+
"message <br/> with a " +
"param:{0}"")
I have seen the at (#) sign in Groovy files and I don't know if it's a Groovy or Java thing. I have tried to search on Google, Bing, and DuckDuckGo for the mystery at sign, but I haven't found anything. Can anyone please give me a resource to know more about what this operator does?
It's a Java annotation. Read more at that link.
As well as being a sign for an annotation, it's the Groovy Field operator
In Groovy, calling object.field calls the getField method (if one exists). If you actually want a direct reference to the field itself, you use #, ie:
class Test {
String name = 'tim'
String getName() {
"Name: $name"
}
}
def t = new Test()
println t.name // prints "Name: tim"
println t.#name // prints "tim"
'#' is an annotations in java/ Groovy look at the demo :Example with code
Java 5 and above supports the use of annotations to include metadata within programs. Groovy 1.1 and above also supports such annotations.
Annotations are used to provide information to tools and libraries.
They allow a declarative style of providing metadata information and allow it to be stored directly in the source code.
Such information would need to otherwise be provided using non-declarative means or using external files.
It can also be used to access attributes when parsing XML using Groovy's XmlSlurper:
def xml = '''<results><result index="1"/></results>'''
def results = new XmlSlurper().parseText(xml)
def index = results.result[0].#index.text() // prints "1"
http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlSlurper
well... i have a file containing tintin-script. Now i already managed to grab all actions and substitutions from it to show them properly ordered on a website using Ruby, which helps me to keep an overview.
Example TINTIN-script
#substitution {You tell {([a-zA-Z,\-\ ]*)}, %*$}
{<279>[<269> $sysdate[1]<279>, <269>$systime<279> |<219> Tell <279>] <269>to <219>%2<279> : <219>%3}
{4}
#substitution {{([a-zA-Z,\-\ ]*)} tells you, %*$}
{<279>[<269> $sysdate[1]<279>, <269>$systime<279> |<119> Tell <279>] <269>from <119>%2<279> : <119>%3}
{2}
#action {Your muscles suddenly relax, and your nimbleness is gone.}
{
#if {$sw_keepaon}
{
aon;
};
} {5}
#action {xxxxx}
{
#if {$sw_keepfamiliar}
{
familiar $familiar;
};
} {5}
To grab them in my Ruby-App i read my script-file into a varibable 'input' and then use the following pattern to scan the 'input'
pattern = /(?<braces>{([^{}]|\g<braces>)*}){0}^#(?<type>action|substitution)\s*(?<b1>\g<braces>)\s*(?<b2>\g<braces>)\s*(?<b3>\g<braces>)/im
input = ""
File.open("/home/igambin/lmud/lmud.tt") { |file| input = file.read }
input.scan(pattern) { |prio, type, pattern, code|
## here i usually create objects, but for simplicity only output now
puts "Type : #{type}"
puts "Pattern : #{pattern}"
puts "Priority: #{prio}"
puts "Code :\n#{code}"
puts
}
Now my idea was to use the netbeans platform to write a module to not only keep an overview but also to assist editing the tintin script file. So opening the file in an Editor-Window I still need to parse the tintin-file and have all 'actions' and 'substitutions' from the file grabbed and displayed in an eTable, in wich I could dbl-click on one item to open a modification-window.
I've setup the module and got everything ready so far, i just can't figure out how to translate the ruby-regex pattern i've written to a working java-regex-pattern. It seems named-group-capturing and especially the recursive application of these groups is not supported in Java. Without that I seem to be unable to find a working solution...
Here's the ruby pattern again...
pattern = /(?<braces>{([^{}]|\g<braces>)*}){0}^#(?<type>action|substitution)\s*(?<b1>\g<braces>)\s*(?<b2>\g<braces>)\s*(?<b3>\g<braces>)/im
Can anyone help me to create a java pattern that matches the same?
Many thanks in advance for tips/hints/ideas and especially for solutions or (close-to-solution comments)!
Your text format seems pretty simple; it's possible you don't really need recursive matching. This Java-compatible regex matches your sample data correctly, as far as I can tell:
(?s)#(substitution|action)\s*\{(.*?)\}\s*\{(.*?)\}\s*\{(\d+)\}
Would that work for you? If you run Java 7, you can even name the groups. ;)
Can anyone help me to create a java pattern that matches the same?
No, no one can: Java's regex engine does not support recursive patterns (as Ruby 1.9 does).