[
https://issues.apache.org/jira/browse/AVRO-886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13104739#comment-13104739
]
George Fletcher commented on AVRO-886:
--------------------------------------
So I believe I've got code working against 1.6.0-SNAPSHOT (revision 1170735) to
handle doc strings for protocol and message entities. I'll submit a patch.
I ran into a couple interesting issues that are probably undiscovered bugs in
the existing implementations.
1. The SpecificCompiler.java javaEscape() method is currently escaping
double-quotes even if they are already escaped in the string. I changed the
replace() call with replaceAll("([^\\\\])\"", "$1\\\\\"").replaceFirst("^\"",
"\\\\\"") which basically will replace a double-quote with \" as long as it is
not already escaped.
2. JSON doc strings need newlines to be escaped. If a doc string was multi-line
and contained newlines, the JSON parser complained. I fixed these by escaping
the newlines when ever generated the JSON objects (e.g. toJson()).
> Support doc strings in IDL for protocols and message interfaces
> ---------------------------------------------------------------
>
> Key: AVRO-886
> URL: https://issues.apache.org/jira/browse/AVRO-886
> Project: Avro
> Issue Type: Improvement
> Affects Versions: 1.5.2
> Reporter: George Fletcher
>
> I would like to be able to add documentation to the IDL that will get parsed
> with more types than Enum, Fixed and Record. Specifically, I'd like to
> support doc strings for protocols and message interfaces. One purpose is to
> be able to write the documentation into the generated code.
> The specific use case is to use information in the documentation strings to
> auto generate java annotations in the generated Java code. This is done with
> our own specifics compiler.
> Here is an example 'marked up' IDL file...
> /** class=@AccessControl(group="normal") */
> @namespace("com.aol.interfaces.echo")
> protocol EchoService {
> import idl "Errors.avdl";
> /** Message structure for the echo service */
> record Message {
> /** the string to be echo'd */
> string echome;
> map<string> echoes;
> }
> /** method=@AccessControl(source="MyService") */
> string echoString(string msg) throws
> com.aol.interfaces.error.ServiceError;
> Message echoMessage(Message msg) throws
> com.aol.interfaces.error.ServiceError;
> void publishMessage(string msg) oneway;
> }
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira