mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-08 21:40:51 +00:00
[Bind] Use DocumentationParameter instead of KeyValuePair
This commit is contained in:
parent
bd9f760f4b
commit
243f41b83f
|
@ -307,7 +307,7 @@ namespace Bind
|
||||||
{
|
{
|
||||||
Summary = String.Empty,
|
Summary = String.Empty,
|
||||||
Parameters = f.Parameters.Select(p =>
|
Parameters = f.Parameters.Select(p =>
|
||||||
new KeyValuePair<string, string>(p.Name, String.Empty)).ToList()
|
new DocumentationParameter(p.Name, String.Empty)).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
string warning = String.Empty;
|
string warning = String.Empty;
|
||||||
|
@ -341,28 +341,37 @@ namespace Bind
|
||||||
length = String.Format("[length: {0}]", param.ComputeSize);
|
length = String.Format("[length: {0}]", param.ComputeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (docs.Parameters.Count > i)
|
// Try to match the correct parameter from documentation:
|
||||||
{
|
// - first by name
|
||||||
var doc = docs.Parameters[i];
|
// - then by index
|
||||||
|
var docparam =
|
||||||
|
(docs.Parameters
|
||||||
|
.Where(p => p.Name == param.RawName)
|
||||||
|
.FirstOrDefault()) ??
|
||||||
|
(docs.Parameters.Count > i ?
|
||||||
|
docs.Parameters[i] : null);
|
||||||
|
|
||||||
if (doc.Key != param.Name)
|
if (docparam != null)
|
||||||
|
{
|
||||||
|
if (docparam.Name != param.RawName)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(
|
Console.Error.WriteLine(
|
||||||
"[Warning] Parameter '{0}' in function '{1}' has incorrect doc name '{2}'",
|
"[Warning] Parameter '{0}' in function '{1}' has incorrect doc name '{2}'",
|
||||||
param.Name, f.Name, doc.Key);
|
param.Name, f.Name, docparam.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note: we use param.Name, because the documentation sometimes
|
// Note: we use param.Name, because the documentation sometimes
|
||||||
// uses different names than the specification.
|
// uses different names than the specification.
|
||||||
sw.WriteLine("/// <param name=\"{0}\">{1} {2}</param>",
|
sw.WriteLine("/// <param name=\"{0}\">{1} {2}</param>",
|
||||||
param.Name, length, doc.Value);
|
param.Name, length, docparam.Documentation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(
|
Console.Error.WriteLine(
|
||||||
"[Warning] Parameter '{0}' in function '{1}' not found in '{2}'",
|
"[Warning] Parameter '{0}' in function '{1}' not found in '{2}: {{{3}}}'",
|
||||||
param.Name, f.Name, docfile);
|
param.Name, f.Name, docfile,
|
||||||
|
String.Join(",", docs.Parameters.Select(p => p.Name).ToArray()));
|
||||||
sw.WriteLine("/// <param name=\"{0}\">{1}</param>",
|
sw.WriteLine("/// <param name=\"{0}\">{1}</param>",
|
||||||
param.Name, length);
|
param.Name, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -703,7 +703,7 @@ typedef const char* GLstring;
|
||||||
{
|
{
|
||||||
Summary = String.Empty,
|
Summary = String.Empty,
|
||||||
Parameters = f.Parameters.Select(p =>
|
Parameters = f.Parameters.Select(p =>
|
||||||
new KeyValuePair<string, string>(p.Name, String.Empty)).ToList()
|
new DocumentationParameter(p.Name, String.Empty)).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
string warning = "[deprecated: v{0}]";
|
string warning = "[deprecated: v{0}]";
|
||||||
|
@ -733,7 +733,7 @@ typedef const char* GLstring;
|
||||||
var param = f.WrappedDelegate.Parameters[i];
|
var param = f.WrappedDelegate.Parameters[i];
|
||||||
if (param.ComputeSize != String.Empty)
|
if (param.ComputeSize != String.Empty)
|
||||||
{
|
{
|
||||||
docs.Parameters[i].Value.Insert(0,
|
docs.Parameters[i].Documentation.Insert(0,
|
||||||
String.Format("[length: {0}]", param.ComputeSize));
|
String.Format("[length: {0}]", param.ComputeSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -743,8 +743,8 @@ typedef const char* GLstring;
|
||||||
foreach (var p in docs.Parameters)
|
foreach (var p in docs.Parameters)
|
||||||
{
|
{
|
||||||
sw.Write(@"/// \param ");
|
sw.Write(@"/// \param ");
|
||||||
sw.Write(p.Key);
|
sw.Write(p.Name);
|
||||||
sw.WriteLine(p.Value);
|
sw.WriteLine(p.Documentation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace Bind
|
||||||
((IEnumerable)doc.XPathEvaluate("*[name()='refentry']/*[name()='refsect1'][@id='parameters']/*[name()='variablelist']/*[name()='varlistentry']"))
|
((IEnumerable)doc.XPathEvaluate("*[name()='refentry']/*[name()='refsect1'][@id='parameters']/*[name()='variablelist']/*[name()='varlistentry']"))
|
||||||
.Cast<XNode>()
|
.Cast<XNode>()
|
||||||
.Select(p =>
|
.Select(p =>
|
||||||
new KeyValuePair<string, string>(
|
new DocumentationParameter(
|
||||||
p.XPathSelectElement("*[name()='term']/*[name()='parameter']").Value.Trim(),
|
p.XPathSelectElement("*[name()='term']/*[name()='parameter']").Value.Trim(),
|
||||||
Cleanup(p.XPathSelectElement("*[name()='listitem']").Value)))
|
Cleanup(p.XPathSelectElement("*[name()='listitem']").Value)))
|
||||||
.ToList()
|
.ToList()
|
||||||
|
|
|
@ -354,7 +354,7 @@ namespace Bind
|
||||||
{
|
{
|
||||||
Summary = String.Empty,
|
Summary = String.Empty,
|
||||||
Parameters = f.Parameters.Select(p =>
|
Parameters = f.Parameters.Select(p =>
|
||||||
new KeyValuePair<string, string>(p.Name, String.Empty)).ToList()
|
new DocumentationParameter(p.Name, String.Empty)).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
string warning = "[deprecated: v{0}]";
|
string warning = "[deprecated: v{0}]";
|
||||||
|
@ -384,7 +384,7 @@ namespace Bind
|
||||||
var param = f.WrappedDelegate.Parameters[i];
|
var param = f.WrappedDelegate.Parameters[i];
|
||||||
if (param.ComputeSize != String.Empty)
|
if (param.ComputeSize != String.Empty)
|
||||||
{
|
{
|
||||||
docs.Parameters[i].Value.Insert(0,
|
docs.Parameters[i].Documentation.Insert(0,
|
||||||
String.Format("[length: {0}]", param.ComputeSize));
|
String.Format("[length: {0}]", param.ComputeSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ namespace Bind
|
||||||
sw.WriteLine("/// <summary>{0}</summary>", docs.Summary);
|
sw.WriteLine("/// <summary>{0}</summary>", docs.Summary);
|
||||||
foreach (var p in docs.Parameters)
|
foreach (var p in docs.Parameters)
|
||||||
{
|
{
|
||||||
sw.WriteLine("/// <param name=\"{0}\">{1}</param>", p.Key, p.Value);
|
sw.WriteLine("/// <param name=\"{0}\">{1}</param>", p.Name, p.Documentation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -32,10 +32,22 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Bind.Structures
|
namespace Bind.Structures
|
||||||
{
|
{
|
||||||
public class Documentation
|
class Documentation
|
||||||
{
|
{
|
||||||
public string Summary { get; set; }
|
public string Summary { get; set; }
|
||||||
public List<KeyValuePair<string, string>> Parameters { get; set; }
|
public List<DocumentationParameter> Parameters { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class DocumentationParameter
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Documentation { get; set; }
|
||||||
|
|
||||||
|
public DocumentationParameter(string name, string doc)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Documentation = doc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue