Correct JavaDoc from doxygen comments indentation
Adds missing JavaDoc indentation for doxygen comments obtained from: - enum values - class methods - constructors - global functions/variables
This commit is contained in:
parent
d22ecafb36
commit
50d7f36f45
5 changed files with 46 additions and 29 deletions
|
|
@ -31,14 +31,33 @@ String *DoxygenTranslator::getDoxygenComment(Node *node) {
|
|||
return Getattr(node, "doxygen");
|
||||
}
|
||||
|
||||
/**
|
||||
* Indent all lines in the comment by given indentation string
|
||||
*/
|
||||
void DoxygenTranslator::extraIndentation(String *comment, const_String_or_char_ptr indentationString) {
|
||||
if (indentationString || Len(indentationString) > 0) {
|
||||
int len = Len(comment);
|
||||
bool trailing_newline = len > 0 && *(Char(comment) + len - 1) == '\n';
|
||||
Insert(comment, 0, indentationString);
|
||||
String *replace = NewStringf("\n%s", indentationString);
|
||||
Replaceall(comment, "\n", replace);
|
||||
if (trailing_newline) {
|
||||
len = Len(comment);
|
||||
Delslice(comment, len - 2, len); // Remove added trailing spaces on last line
|
||||
}
|
||||
Delete(replace);
|
||||
}
|
||||
}
|
||||
|
||||
String *DoxygenTranslator::getDocumentation(Node *node) {
|
||||
String *DoxygenTranslator::getDocumentation(Node *node, const_String_or_char_ptr indentationString) {
|
||||
|
||||
if (!hasDocumentation(node)) {
|
||||
return NewString("");
|
||||
}
|
||||
|
||||
return makeDocumentation(node);
|
||||
String *documentation = makeDocumentation(node);
|
||||
extraIndentation(documentation, indentationString);
|
||||
return documentation;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
* Return the documentation for a given node formated for the correct
|
||||
* documentation system.
|
||||
*/
|
||||
String *getDocumentation(Node *node);
|
||||
String *getDocumentation(Node *node, const_String_or_char_ptr indentationString);
|
||||
|
||||
/*
|
||||
* Returns truem is the specified node has comment attached.
|
||||
|
|
@ -84,6 +84,7 @@ protected:
|
|||
*/
|
||||
void printTree(const DoxygenEntityList &entityList);
|
||||
|
||||
void extraIndentation(String *comment, const_String_or_char_ptr indentationString);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -795,9 +795,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) {
|
|||
|
||||
string translatedStr = indentAndInsertAsterisks(doc);
|
||||
|
||||
String *comment = NewString(translatedStr.c_str());
|
||||
// Append(comment, documentation); Replaceall(comment, "\n", "\n * ");
|
||||
return comment;
|
||||
return NewString(translatedStr.c_str());
|
||||
}
|
||||
|
||||
DoxygenEntityList entityList = parser.createTree(node, documentation);
|
||||
|
|
|
|||
|
|
@ -592,9 +592,9 @@ public:
|
|||
Printf(f_module, "%s\n", module_imports);
|
||||
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0);
|
||||
if (comment_creation_chatter)
|
||||
Printf(f_module, "/* This was generated from top() */");
|
||||
Printf(f_module, "/* This was generated from top() */\n");
|
||||
Printv(f_module, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -1275,10 +1275,9 @@ public:
|
|||
String *typemap_lookup_type = Getattr(n, "name");
|
||||
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
if (comment_creation_chatter) {
|
||||
Printf(enum_code, "/* This was generated from enumDeclaration() */");
|
||||
}
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0);
|
||||
if (comment_creation_chatter)
|
||||
Printf(enum_code, "/* This was generated from enumDeclaration() */\n");
|
||||
Printv(enum_code, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -1307,9 +1306,9 @@ public:
|
|||
} else {
|
||||
// Translate and write javadoc comment for the enum itself if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0);
|
||||
if (comment_creation_chatter)
|
||||
Printf(constants_code, "/* This was generated from enumDeclaration() */");
|
||||
Printf(constants_code, "/* This was generated from enumDeclaration() */\n");
|
||||
Printf(constants_code, "/* Comment for enum %s */\n", Getattr(n, "unnamedinstance") ? "" : symname);
|
||||
Printf(constants_code, Char(doxygen_comments));
|
||||
Printf(constants_code, "\n");
|
||||
|
|
@ -1474,9 +1473,9 @@ public:
|
|||
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, " ");
|
||||
if (comment_creation_chatter)
|
||||
Printf(enum_code, "/* This was generated from enumvalueDeclaration() */");
|
||||
Printf(enum_code, "/* This was generated from enumvalueDeclaration() */\n");
|
||||
Printv(enum_code, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -1559,9 +1558,9 @@ public:
|
|||
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0);
|
||||
if (comment_creation_chatter)
|
||||
Printf(constants_code, "/* This was generated from constantWrapper() */");
|
||||
Printf(constants_code, "/* This was generated from constantWrapper() */\n");
|
||||
Printv(constants_code, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -2008,9 +2007,9 @@ public:
|
|||
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0);
|
||||
if (comment_creation_chatter)
|
||||
Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */");
|
||||
Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n");
|
||||
Printv(proxy_class_def, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -2505,9 +2504,9 @@ public:
|
|||
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, " ");
|
||||
if (comment_creation_chatter)
|
||||
Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */");
|
||||
Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */\n");
|
||||
Printv(function_code, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -2747,11 +2746,11 @@ public:
|
|||
tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node
|
||||
Printf(im_return_type, "%s", tm);
|
||||
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, " ");
|
||||
if (comment_creation_chatter)
|
||||
Printf(function_code, "/* This was generated from constructionhandler() */");
|
||||
Printf(function_code, "/* This was generated from constructionhandler() */\n");
|
||||
Printv(function_code, Char(doxygen_comments), NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
@ -3023,9 +3022,9 @@ public:
|
|||
|
||||
// Translate and write javadoc comment if flagged
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n);
|
||||
String *doxygen_comments = doxygenTranslator->getDocumentation(n, " ");
|
||||
if (comment_creation_chatter)
|
||||
Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */");
|
||||
Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n");
|
||||
Printv(function_code, doxygen_comments, NIL);
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1678,7 +1678,7 @@ public:
|
|||
if (doxygen) {
|
||||
docstr = Getattr(n, "python:docstring");
|
||||
if (!docstr && doxygenTranslator->hasDocumentation(n)) {
|
||||
docstr = doxygenTranslator->getDocumentation(n);
|
||||
docstr = doxygenTranslator->getDocumentation(n, 0);
|
||||
|
||||
// Avoid rebuilding it again the next time: notice that we can't do
|
||||
// this for the combined doc string as autodoc part of it depends on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue