improved commands for escaped characters
This commit is contained in:
parent
20cc685e8a
commit
32f34e16be
5 changed files with 53 additions and 21 deletions
|
|
@ -33,8 +33,9 @@ void backslashA()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Output of escaped symbols below in doxygen generated HTML:
|
// Output of escaped symbols below in doxygen generated HTML:
|
||||||
// Rendered: Escaped symbols: $ @ \ & < > # % " \. ::
|
// Rendered: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text
|
||||||
// HTML source: Escaped symbols: $ @ \ & < > # % " \. ::
|
// HTML source: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Doxy command without trailing \cspace space is ignored - nothing appears
|
* Doxy command without trailing \cspace space is ignored - nothing appears
|
||||||
|
|
@ -46,8 +47,8 @@ void backslashA()
|
||||||
* double quotes: "d:\xyz\c\myfile", "@something". single quotes do not help:
|
* double quotes: "d:\xyz\c\myfile", "@something". single quotes do not help:
|
||||||
* 'd:\xyz\c\myfile'. Escaping works: d:\\xyz\\c\\myfile. Unix
|
* 'd:\xyz\c\myfile'. Escaping works: d:\\xyz\\c\\myfile. Unix
|
||||||
* paths of course have no such problems: /xyz/c/myfile
|
* paths of course have no such problems: /xyz/c/myfile
|
||||||
* Escaped symbols:
|
* Commands for escaped symbols:
|
||||||
* \$ \@ \\ \& \~ \< \> \# \% \" \. \::
|
* \$ \@ \\ \& \~ \< \> \# \% \" \. \:: \@text \::text
|
||||||
*/
|
*/
|
||||||
void backslashB()
|
void backslashB()
|
||||||
{}
|
{}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@ import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
public class commentParser {
|
public class commentParser {
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
||||||
|
|
@ -56,10 +61,29 @@ public class commentParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!actualStr.equals(wantedStr)) {
|
if (!actualStr.equals(wantedStr)) {
|
||||||
System.out.println("Documentation comments for " + e.getKey() + " do not match: ");
|
System.out.println("Documentation comments for " + e.getKey() + " do not match!");
|
||||||
|
String expectedFileName = "expected.txt";
|
||||||
|
String gotFileName = "got.txt";
|
||||||
|
System.out.println("Output is also saved to files '" + expectedFileName +
|
||||||
|
"' and '" + gotFileName + "'");
|
||||||
// here we print original strings, for nicer output
|
// here we print original strings, for nicer output
|
||||||
System.out.println("\n\n---\nexpected:\n" + wantedComments.get(e.getKey()));
|
System.out.println("\n\n---\nexpected:\n" + wantedComments.get(e.getKey()));
|
||||||
System.out.println("\n\n---\ngot:\n" + e.getValue());
|
System.out.println("\n\n---\ngot:\n" + e.getValue());
|
||||||
|
|
||||||
|
try {
|
||||||
|
// write expected string to file
|
||||||
|
BufferedWriter expectedFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(expectedFileName)));
|
||||||
|
expectedFile.write(wantedComments.get(e.getKey()));
|
||||||
|
expectedFile.close();
|
||||||
|
|
||||||
|
// write translated string to file
|
||||||
|
BufferedWriter gotFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(gotFileName)));
|
||||||
|
gotFile.write(e.getValue());
|
||||||
|
gotFile.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
System.out.println("Error when writing output to file: " + ex);
|
||||||
|
}
|
||||||
|
|
||||||
errorCount++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionInd
|
||||||
|
|
||||||
/* All of the doxygen commands divided up by how they are parsed */
|
/* All of the doxygen commands divided up by how they are parsed */
|
||||||
const char *simpleCommands[] = {
|
const char *simpleCommands[] = {
|
||||||
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond",
|
// the first line are escaped chars, except \~, which is a language ID command.
|
||||||
|
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::",
|
||||||
|
"endcond",
|
||||||
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
|
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
|
||||||
"nosubgrouping", "public", "publicsection", "private", "privatesection",
|
"nosubgrouping", "public", "publicsection", "private", "privatesection",
|
||||||
"protected", "protectedsection", "tableofcontents"};
|
"protected", "protectedsection", "tableofcontents"};
|
||||||
|
|
|
||||||
|
|
@ -1114,19 +1114,26 @@ size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line)
|
||||||
size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
|
size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
|
||||||
{
|
{
|
||||||
switch (line[pos]) {
|
switch (line[pos]) {
|
||||||
case '\\': // process doxy command or escaped char
|
case '\\':
|
||||||
/* switch (line[pos + 1]) {
|
|
||||||
case '$':
|
|
||||||
case '@':
|
|
||||||
case '\':
|
|
||||||
case '&':
|
|
||||||
case '~':
|
|
||||||
case '<':
|
|
||||||
case '>':
|
|
||||||
case '#': \% \" \. \::
|
|
||||||
}
|
|
||||||
TODO break case if any of escaped chars */
|
|
||||||
case '@': {
|
case '@': {
|
||||||
|
// process doxy commands for escaped characters - handling this separately
|
||||||
|
// supports documentation text like \@someText
|
||||||
|
if ((pos + 1) < line.size()) {
|
||||||
|
string escapedChars = "$@\\&~<>#%\".";
|
||||||
|
if (escapedChars.find(line[pos + 1]) != string::npos) {
|
||||||
|
addDoxyCommand(m_tokenList, line.substr(pos + 1, 1));
|
||||||
|
pos += 2;
|
||||||
|
break;
|
||||||
|
} else if ((pos + 2) < line.size() &&
|
||||||
|
line[pos + 1] == ':' && line[pos + 2] == ':') {
|
||||||
|
// add command \:: - handling this separately supports documentation
|
||||||
|
// text like \::someText
|
||||||
|
addDoxyCommand(m_tokenList, line.substr(pos + 1, 2));
|
||||||
|
pos += 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// handle word commands and \f[, \f$, ... commands
|
||||||
pos++;
|
pos++;
|
||||||
// characters '$[]{}' are used in commands \f$, \f[, ...
|
// characters '$[]{}' are used in commands \f$, \f[, ...
|
||||||
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz$[]{}", pos);
|
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz$[]{}", pos);
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,6 @@ void JavaDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translated
|
||||||
translatedComment += arg;
|
translatedComment += arg;
|
||||||
else
|
else
|
||||||
translatedComment += tag.typeOfEntity;
|
translatedComment += tag.typeOfEntity;
|
||||||
translatedComment += " ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles tags which are the same in Doxygen and Javadoc.
|
// handles tags which are the same in Doxygen and Javadoc.
|
||||||
|
|
@ -394,10 +393,9 @@ void JavaDocConverter::handleTagParam(DoxygenEntity& tag,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
translatedComment += "@param ";
|
translatedComment += "@param ";
|
||||||
translatedComment += tag.entityList.begin()->data + " ";
|
translatedComment += tag.entityList.begin()->data;
|
||||||
tag.entityList.pop_front();
|
tag.entityList.pop_front();
|
||||||
handleParagraph(tag, translatedComment, dummy);
|
handleParagraph(tag, translatedComment, dummy);
|
||||||
printf("cmd: %s\n", translatedComment.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue