diff options
Diffstat (limited to 'src/tools/qdoc/generator.cpp')
-rw-r--r-- | src/tools/qdoc/generator.cpp | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index 99dec06233..2fdba5483a 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -419,6 +419,59 @@ QString Generator::fileName(const Node* node) const return name; } +QString Generator::cleanRef(const QString& ref) +{ + QString clean; + + if (ref.isEmpty()) + return clean; + + clean.reserve(ref.size() + 20); + const QChar c = ref[0]; + const uint u = c.unicode(); + + if ((u >= 'a' && u <= 'z') || + (u >= 'A' && u <= 'Z') || + (u >= '0' && u <= '9')) { + clean += c; + } else if (u == '~') { + clean += "dtor."; + } else if (u == '_') { + clean += "underscore."; + } else { + clean += QLatin1Char('A'); + } + + for (int i = 1; i < (int) ref.length(); i++) { + const QChar c = ref[i]; + const uint u = c.unicode(); + if ((u >= 'a' && u <= 'z') || + (u >= 'A' && u <= 'Z') || + (u >= '0' && u <= '9') || u == '-' || + u == '_' || u == ':' || u == '.') { + clean += c; + } else if (c.isSpace()) { + clean += QLatin1Char('-'); + } else if (u == '!') { + clean += "-not"; + } else if (u == '&') { + clean += "-and"; + } else if (u == '<') { + clean += "-lt"; + } else if (u == '=') { + clean += "-eq"; + } else if (u == '>') { + clean += "-gt"; + } else if (u == '#') { + clean += QLatin1Char('#'); + } else { + clean += QLatin1Char('-'); + clean += QString::number((int)u, 16); + } + } + return clean; +} + QMap<QString, QString>& Generator::formattingLeftMap() { return fmtLeftMaps[format()]; @@ -521,10 +574,10 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir) return fullDocumentLocation(functionNode->associatedProperty()); else if (functionNode->overloadNumber() > 1) - anchorRef = QLatin1Char('#') + functionNode->name() + anchorRef = QLatin1Char('#') + cleanRef(functionNode->name()) + QLatin1Char('-') + QString::number(functionNode->overloadNumber()); else - anchorRef = QLatin1Char('#') + functionNode->name(); + anchorRef = QLatin1Char('#') + cleanRef(functionNode->name()); break; } /* |