tools/qdoc3/cppcodemarker.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   143     if (node->name().isEmpty()) {
   143     if (node->name().isEmpty()) {
   144 	return "global";
   144 	return "global";
   145     }
   145     }
   146     else {
   146     else {
   147 	QString fullName;
   147 	QString fullName;
   148 	for (;;) {
   148 	while (node) {
   149 	    fullName.prepend(plainName(node));
   149 	    fullName.prepend(plainName(node));
   150 	    if (node->parent() == relative || node->parent()->name().isEmpty())
   150 	    if (node->parent() == relative || node->parent()->name().isEmpty())
   151 		break;
   151 		break;
   152 	    fullName.prepend("::");
   152 	    fullName.prepend("::");
   153 	    node = node->parent();
   153 	    node = node->parent();
   480         const ClassNode *classe = static_cast<const ClassNode *>(inner);
   480         const ClassNode *classe = static_cast<const ClassNode *>(inner);
   481 
   481 
   482         if (style == Summary) {
   482         if (style == Summary) {
   483 	    FastSection privateFunctions(classe,
   483 	    FastSection privateFunctions(classe,
   484                                          "Private Functions",
   484                                          "Private Functions",
       
   485                                          "",
   485                                          "private function",
   486                                          "private function",
   486 				         "private functions");
   487 				         "private functions");
   487 	    FastSection privateSlots(classe, "Private Slots", "private slot", "private slots");
   488 	    FastSection privateSlots(classe, "Private Slots", "", "private slot", "private slots");
   488 	    FastSection privateTypes(classe, "Private Types", "private type", "private types");
   489 	    FastSection privateTypes(classe, "Private Types", "", "private type", "private types");
   489 	    FastSection protectedFunctions(classe,
   490 	    FastSection protectedFunctions(classe,
   490                                            "Protected Functions",
   491                                            "Protected Functions",
       
   492                                            "",
   491                                            "protected function",
   493                                            "protected function",
   492 				           "protected functions");
   494 				           "protected functions");
   493 	    FastSection protectedSlots(classe,
   495 	    FastSection protectedSlots(classe,
   494                                        "Protected Slots",
   496                                        "Protected Slots",
       
   497                                        "",
   495                                        "protected slot",
   498                                        "protected slot",
   496                                        "protected slots");
   499                                        "protected slots");
   497 	    FastSection protectedTypes(classe,
   500 	    FastSection protectedTypes(classe,
   498                                        "Protected Types",
   501                                        "Protected Types",
       
   502                                        "",
   499                                        "protected type",
   503                                        "protected type",
   500                                        "protected types");
   504                                        "protected types");
   501 	    FastSection protectedVariables(classe,
   505 	    FastSection protectedVariables(classe,
   502                                            "Protected Variables",
   506                                            "Protected Variables",
       
   507                                            "",
   503                                            "protected type",
   508                                            "protected type",
   504                                            "protected variables");
   509                                            "protected variables");
   505 	    FastSection publicFunctions(classe,
   510 	    FastSection publicFunctions(classe,
   506                                         "Public Functions",
   511                                         "Public Functions",
       
   512                                         "",
   507                                         "public function",
   513                                         "public function",
   508                                         "public functions");
   514                                         "public functions");
   509 	    FastSection publicSignals(classe, "Signals", "signal", "signals");
   515 	    FastSection publicSignals(classe, "Signals", "", "signal", "signals");
   510 	    FastSection publicSlots(classe, "Public Slots", "public slot", "public slots");
   516 	    FastSection publicSlots(classe, "Public Slots", "", "public slot", "public slots");
   511 	    FastSection publicTypes(classe, "Public Types", "public type", "public types");
   517 	    FastSection publicTypes(classe, "Public Types", "", "public type", "public types");
   512 	    FastSection publicVariables(classe,
   518 	    FastSection publicVariables(classe,
   513                                         "Public Variables",
   519                                         "Public Variables",
   514                                         "public type",
   520                                         "",
       
   521                                         "public variable",
   515                                         "public variables");
   522                                         "public variables");
   516 	    FastSection properties(classe, "Properties", "property", "properties");
   523 	    FastSection properties(classe, "Properties", "", "property", "properties");
   517 	    FastSection relatedNonMembers(classe,
   524 	    FastSection relatedNonMembers(classe,
   518                                           "Related Non-Members",
   525                                           "Related Non-Members",
       
   526                                           "",
   519                                           "related non-member",
   527                                           "related non-member",
   520                                           "related non-members");
   528                                           "related non-members");
   521 	    FastSection staticPrivateMembers(classe,
   529 	    FastSection staticPrivateMembers(classe,
   522                                              "Static Private Members",
   530                                              "Static Private Members",
       
   531                                              "",
   523                                              "static private member",
   532                                              "static private member",
   524 					     "static private members");
   533 					     "static private members");
   525 	    FastSection staticProtectedMembers(classe,
   534 	    FastSection staticProtectedMembers(classe,
   526                                                "Static Protected Members",
   535                                                "Static Protected Members",
       
   536                                                "",
   527 					       "static protected member",
   537 					       "static protected member",
   528                                                "static protected members");
   538                                                "static protected members");
   529 	    FastSection staticPublicMembers(classe,
   539 	    FastSection staticPublicMembers(classe,
   530                                             "Static Public Members",
   540                                             "Static Public Members",
       
   541                                             "",
   531                                             "static public member",
   542                                             "static public member",
   532 					    "static public members");
   543 					    "static public members");
   533             FastSection macros(inner, "Macros", "macro", "macros");
   544             FastSection macros(inner, "Macros", "", "macro", "macros");
   534 
   545 
   535 	    NodeList::ConstIterator r = classe->relatedNodes().begin();
   546 	    NodeList::ConstIterator r = classe->relatedNodes().begin();
   536             while (r != classe->relatedNodes().end()) {
   547             while (r != classe->relatedNodes().end()) {
   537                 if ((*r)->type() == Node::Function) {
   548                 if ((*r)->type() == Node::Function) {
   538                     FunctionNode *func = static_cast<FunctionNode *>(*r);
   549                     FunctionNode *func = static_cast<FunctionNode *>(*r);
   664 	    append(sections, staticPrivateMembers);
   675 	    append(sections, staticPrivateMembers);
   665 	    append(sections, relatedNonMembers);
   676 	    append(sections, relatedNonMembers);
   666             append(sections, macros);
   677             append(sections, macros);
   667         }
   678         }
   668         else if (style == Detailed) {
   679         else if (style == Detailed) {
   669 	    FastSection memberFunctions(classe,"Member Function Documentation");
   680 	    FastSection memberFunctions(classe,"Member Function Documentation","func","member","members");
   670 	    FastSection memberTypes(classe,"Member Type Documentation");
   681 	    FastSection memberTypes(classe,"Member Type Documentation","types","member","members");
   671 	    FastSection memberVariables(classe,"Member Variable Documentation");
   682 	    FastSection memberVariables(classe,"Member Variable Documentation","vars","member","members");
   672 	    FastSection properties(classe,"Property Documentation");
   683 	    FastSection properties(classe,"Property Documentation","prop","member","members");
   673 	    FastSection relatedNonMembers(classe,"Related Non-Members");
   684 	    FastSection relatedNonMembers(classe,"Related Non-Members","relnonmem","member","members");
   674 	    FastSection macros(classe,"Macro Documentation");
   685 	    FastSection macros(classe,"Macro Documentation","macros","member","members");
   675 
   686 
   676 	    NodeList::ConstIterator r = classe->relatedNodes().begin();
   687 	    NodeList::ConstIterator r = classe->relatedNodes().begin();
   677             while (r != classe->relatedNodes().end()) {
   688             while (r != classe->relatedNodes().end()) {
   678                 if ((*r)->type() == Node::Function) {
   689                 if ((*r)->type() == Node::Function) {
   679                     FunctionNode *func = static_cast<FunctionNode *>(*r);
   690                     FunctionNode *func = static_cast<FunctionNode *>(*r);
   715 	    append(sections, memberVariables);
   726 	    append(sections, memberVariables);
   716 	    append(sections, relatedNonMembers);
   727 	    append(sections, relatedNonMembers);
   717 	    append(sections, macros);
   728 	    append(sections, macros);
   718         }
   729         }
   719         else {
   730         else {
   720 	    FastSection all(classe);
   731 	    FastSection all(classe,"","","member","members");
   721 
   732 
   722 	    QStack<const ClassNode *> stack;
   733 	    QStack<const ClassNode *> stack;
   723 	    stack.push(classe);
   734 	    stack.push(classe);
   724 
   735 
   725 	    while (!stack.isEmpty()) {
   736 	    while (!stack.isEmpty()) {
   745     }
   756     }
   746     else {
   757     else {
   747         if (style == Summary || style == Detailed) {
   758         if (style == Summary || style == Detailed) {
   748 	    FastSection namespaces(inner,
   759 	    FastSection namespaces(inner,
   749                                    "Namespaces",
   760                                    "Namespaces",
       
   761                                    style == Detailed ? "nmspace" : "",
   750                                    "namespace",
   762                                    "namespace",
   751                                    "namespaces");
   763                                    "namespaces");
   752             FastSection classes(inner,
   764             FastSection classes(inner,
   753                                 "Classes",
   765                                 "Classes",
       
   766                                 style == Detailed ? "classes" : "",
   754                                 "class",
   767                                 "class",
   755                                 "classes");
   768                                 "classes");
   756             FastSection types(inner,
   769             FastSection types(inner,
   757                               style == Summary ?
   770                               style == Summary ? "Types" : "Type Documentation",
   758                               "Types" : "Type Documentation",
   771                               style == Detailed ? "types" : "",
   759                               "type",
   772                               "type",
   760 			      "types");
   773 			      "types");
   761             FastSection functions(inner,
   774             FastSection functions(inner,
   762                                   style == Summary ?
   775                                   style == Summary ?
   763                                   "Functions" : "Function Documentation",
   776                                   "Functions" : "Function Documentation",
       
   777                                   style == Detailed ? "func" : "",
   764 			          "function",
   778 			          "function",
   765                                   "functions");
   779                                   "functions");
   766             FastSection macros(inner,
   780             FastSection macros(inner,
   767                                style == Summary ?
   781                                style == Summary ?
   768                                "Macros" : "Macro Documentation",
   782                                "Macros" : "Macro Documentation",
       
   783                                style == Detailed ? "macros" : "",
   769                                "macro",
   784                                "macro",
   770                                "macros");
   785                                "macros");
   771 
   786 
   772 	    NodeList nodeList = inner->childNodes();
   787 	    NodeList nodeList = inner->childNodes();
   773             nodeList += inner->relatedNodes();
   788             nodeList += inner->relatedNodes();
   879     static QRegExp classX("[:,][ \n]*(?:p(?:ublic|r(?:otected|ivate))[ \n]+)?"
   894     static QRegExp classX("[:,][ \n]*(?:p(?:ublic|r(?:otected|ivate))[ \n]+)?"
   880                           "([a-zA-Z_][a-zA-Z_0-9]*)");
   895                           "([a-zA-Z_][a-zA-Z_0-9]*)");
   881     static QRegExp globalX("[\n{()=] *([a-zA-Z_][a-zA-Z_0-9]*)[ \n]*\\(");
   896     static QRegExp globalX("[\n{()=] *([a-zA-Z_][a-zA-Z_0-9]*)[ \n]*\\(");
   882     static QRegExp multiLineComment("/(?:( )?\\*(?:[^*]+|\\*(?! /))*\\*\\1/)");
   897     static QRegExp multiLineComment("/(?:( )?\\*(?:[^*]+|\\*(?! /))*\\*\\1/)");
   883     multiLineComment.setMinimal(true);
   898     multiLineComment.setMinimal(true);
   884     static QRegExp singleLineComment("//(?!!)[^!\n]*");
   899     static QRegExp singleLineComment("[^:]//(?!!)[^!\\n]*");
   885     static QRegExp preprocessor("(?:^|\n)(#[ \t]*(?:include|if|elif|endif|error|pragma|define"
   900     static QRegExp preprocessor("(?:^|\n)(#[ \t]*(?:include|if|elif|endif|error|pragma|define"
   886                                 "|warning)(?:(?:\\\\\n|\\n#)[^\n]*)*)");
   901                                 "|warning)(?:(?:\\\\\n|\\n#)[^\n]*)*)");
   887     static QRegExp literals("&quot;(?:[^\\\\&]|\\\\[^\n]|&(?!quot;))*&quot;"
   902     static QRegExp literals("&quot;(?:[^\\\\&]|\\\\[^\n]|&(?!quot;))*&quot;"
   888                             "|'(?:[^\\\\]|\\\\(?:[^x0-9']|x[0-9a-f]{1,4}|[0-9]{1,3}))'");
   903                             "|'(?:[^\\\\]|\\\\(?:[^x0-9']|x[0-9a-f]{1,4}|[0-9]{1,3}))'");
   889 
   904 
  1065         if (slpos == -1) {
  1080         if (slpos == -1) {
  1066             pos = mlpos;
  1081             pos = mlpos;
  1067             len = multiLineComment.matchedLength();
  1082             len = multiLineComment.matchedLength();
  1068         }
  1083         }
  1069         else if (mlpos == -1) {
  1084         else if (mlpos == -1) {
  1070             pos = slpos;
  1085             pos = slpos + 1;
  1071             len = singleLineComment.matchedLength();
  1086             len = singleLineComment.matchedLength() - 1;
  1072         }
  1087         }
  1073         else {
  1088         else {
  1074             if (slpos < mlpos) {
  1089             if (slpos < mlpos) {
  1075                 pos = slpos;
  1090                 pos = slpos + 1;
  1076                 len = singleLineComment.matchedLength();
  1091                 len = singleLineComment.matchedLength() - 1;
  1077             }
  1092             }
  1078             else {
  1093             else {
  1079                 pos = mlpos;
  1094                 pos = mlpos;
  1080                 len = multiLineComment.matchedLength();
  1095                 len = multiLineComment.matchedLength();
  1081             }
  1096             }
  1114     QList<Section> sections;
  1129     QList<Section> sections;
  1115     if (qmlClassNode) {
  1130     if (qmlClassNode) {
  1116         if (style == Summary) {
  1131         if (style == Summary) {
  1117 	    FastSection qmlproperties(qmlClassNode,
  1132 	    FastSection qmlproperties(qmlClassNode,
  1118                                       "Properties",
  1133                                       "Properties",
       
  1134                                       "",
  1119                                       "property",
  1135                                       "property",
  1120                                       "properties");
  1136                                       "properties");
  1121 	    FastSection qmlattachedproperties(qmlClassNode,
  1137 	    FastSection qmlattachedproperties(qmlClassNode,
  1122                                               "Attached Properties",
  1138                                               "Attached Properties",
       
  1139                                               "",
  1123                                               "property",
  1140                                               "property",
  1124                                               "properties");
  1141                                               "properties");
  1125 	    FastSection qmlsignals(qmlClassNode,
  1142 	    FastSection qmlsignals(qmlClassNode,
  1126                                 "Signals",
  1143                                    "Signals",
  1127                                 "signal",
  1144                                    "",
  1128                                 "signals");
  1145                                    "signal",
       
  1146                                    "signals");
  1129 	    FastSection qmlattachedsignals(qmlClassNode,
  1147 	    FastSection qmlattachedsignals(qmlClassNode,
  1130                                            "QML Attached Signals",
  1148                                            "Attached Signals",
       
  1149                                            "",
  1131                                            "signal",
  1150                                            "signal",
  1132                                            "signals");
  1151                                            "signals");
  1133 	    FastSection qmlmethods(qmlClassNode,
  1152 	    FastSection qmlmethods(qmlClassNode,
  1134                                    "Methods",
  1153                                    "Methods",
       
  1154                                    "",
  1135                                    "method",
  1155                                    "method",
  1136                                    "methods");
  1156                                    "methods");
  1137 	    FastSection qmlattachedmethods(qmlClassNode,
  1157 	    FastSection qmlattachedmethods(qmlClassNode,
  1138                                            "QML Attached Methods",
  1158                                            "Attached Methods",
       
  1159                                            "",
  1139                                            "method",
  1160                                            "method",
  1140                                            "methods");
  1161                                            "methods");
  1141 
  1162 
  1142             NodeList::ConstIterator c = qmlClassNode->childNodes().begin();
  1163             NodeList::ConstIterator c = qmlClassNode->childNodes().begin();
  1143             while (c != qmlClassNode->childNodes().end()) {
  1164             while (c != qmlClassNode->childNodes().end()) {
  1177 	    append(sections,qmlattachedsignals);
  1198 	    append(sections,qmlattachedsignals);
  1178 	    append(sections,qmlmethods);
  1199 	    append(sections,qmlmethods);
  1179 	    append(sections,qmlattachedmethods);
  1200 	    append(sections,qmlattachedmethods);
  1180         }
  1201         }
  1181         else if (style == Detailed) {
  1202         else if (style == Detailed) {
  1182             FastSection qmlproperties(qmlClassNode, "Property Documentation");
  1203             FastSection qmlproperties(qmlClassNode, "Property Documentation","qmlprop","member","members");
  1183 	    FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation");
  1204 	    FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation","qmlattprop",
  1184             FastSection qmlsignals(qmlClassNode,"Signal Documentation");
  1205                                               "member","members");
  1185 	    FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation");
  1206             FastSection qmlsignals(qmlClassNode,"Signal Documentation","qmlsig","member","members");
  1186             FastSection qmlmethods(qmlClassNode,"Method Documentation");
  1207 	    FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation","qmlattsig",
  1187 	    FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation");
  1208                                            "member","members");
       
  1209             FastSection qmlmethods(qmlClassNode,"Method Documentation","qmlmeth","member","members");
       
  1210 	    FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation","qmlattmeth",
       
  1211                                            "member","members");
  1188 	    NodeList::ConstIterator c = qmlClassNode->childNodes().begin();
  1212 	    NodeList::ConstIterator c = qmlClassNode->childNodes().begin();
  1189 	    while (c != qmlClassNode->childNodes().end()) {
  1213 	    while (c != qmlClassNode->childNodes().end()) {
  1190                 if ((*c)->subType() == Node::QmlPropertyGroup) {
  1214                 if ((*c)->subType() == Node::QmlPropertyGroup) {
  1191                     const QmlPropGroupNode* pgn = static_cast<const QmlPropGroupNode*>(*c);
  1215                     const QmlPropGroupNode* pgn = static_cast<const QmlPropGroupNode*>(*c);
  1192                     if (pgn->isAttached())
  1216                     if (pgn->isAttached())