Skip to content

Commit f5ede4a

Browse files
committed
Updated the generation of documentation for Qt 5.6.1.
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
1 parent abb0481 commit f5ede4a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

QtSharp/DocGeneration/Documentation.cs

+14-10
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void CollectIndices(string docsPath, string module)
4949
{
5050
while (xmlReader.Read())
5151
{
52-
if (xmlReader.NodeType == XmlNodeType.Element)
52+
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.GetAttribute("lineno") != null)
5353
{
5454
switch (xmlReader.Name)
5555
{
@@ -254,15 +254,16 @@ public void DocumentFunction(Function function)
254254
var node = functions.Find(
255255
f => f.Location == function.TranslationUnit.FileName &&
256256
(f.LineNumber == lineStart || f.LineNumber == lineEnd));
257+
var @params = function.Parameters.Where(p => p.Kind == ParameterKind.Regular).ToList();
257258
// HACK: functions in qglobal.h have weird additional definitions just for docs
258259
if ((node == null || node.HRef == null) && function.TranslationUnit.FileName == "qglobal.h")
259260
{
260261
node = functions.Find(
261262
c => c.Location == function.TranslationUnit.FileName &&
262-
c.Name == function.OriginalName);
263+
(c.FullName == function.QualifiedOriginalName || c.Name == function.OriginalName) &&
264+
c.Access != "private" && c.ParametersModifiers.Count == @params.Count);
263265
}
264266
// HACK: some functions are "located" in a cpp, go figure...
265-
var @params = function.Parameters.Where(p => p.Kind == ParameterKind.Regular).ToList();
266267
if ((node == null || node.HRef == null) && function.Signature != null)
267268
{
268269
var qualifiedOriginalName = function.GetQualifiedName(decl => decl.OriginalName,
@@ -323,17 +324,18 @@ public void DocumentFunction(Function function)
323324
var docs = this.membersDocumentation[file][key];
324325
var i = 0;
325326
// HACK: work around bugs of the type of https://bugreports.qt.io/browse/QTBUG-46148
326-
if ((function.OperatorKind == CXXOperatorKind.Greater && function.Namespace.Name == "QLatin1String" &&
327-
@params[0].Type.ToString() == "QtCore.QLatin1String") ||
328-
((function.OriginalName == "flush" || function.OriginalName == "reset") &&
329-
function.Namespace.Name == "QTextStream" && @params.Count > 0))
327+
if (function.Namespace.Name == "QByteArray" &&
328+
((function.OriginalName == "qCompress" && @params.Count == 2) ||
329+
(function.OriginalName == "qUncompress" && @params.Count == 1)))
330330
{
331331
docs = this.membersDocumentation[file][key + "-hack"];
332332
}
333-
foreach (Match match in Regex.Matches(docs[0].InnerHtml, @"<i>\s*(.+?)\s*</i>"))
333+
foreach (Match match in regexParameters.Matches(docs[0].InnerHtml))
334334
{
335-
@params[i].Name = Helpers.SafeIdentifier(match.Groups[1].Value);
336-
i++;
335+
// variadic and void "parameters" are invalid
336+
if (function.IsVariadic && @params.Count == i || match.Groups[1].Value == "void")
337+
break;
338+
@params[i++].Name = Helpers.SafeIdentifier(match.Groups[1].Value);
337339
}
338340
// TODO: create links in the "See Also" section
339341
function.Comment = new RawComment
@@ -793,5 +795,7 @@ private static void AddObsoleteAttribute(Declaration function)
793795
private readonly List<DocIndexNode> classNodes = new List<DocIndexNode>();
794796
private readonly List<DocIndexNode> enumNodes = new List<DocIndexNode>();
795797
private readonly List<DocIndexNode> variableNodes = new List<DocIndexNode>();
798+
799+
private Regex regexParameters = new Regex(@"<i>\s*(.+?)\s*</i>", RegexOptions.Compiled);
796800
}
797801
}

0 commit comments

Comments
 (0)