void WriteDocumentation(BindStreamWriter sw, Function f)
{
var docs = f.Documentation;
try
{
string warning = "[deprecated: v{0}]";
string category = "[requires: {0}]";
if (f.Deprecated)
{
warning = String.Format(warning, f.DeprecatedVersion);
docs.Summary = docs.Summary.Insert(0, warning);
}
if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category))
{
category = String.Format(category, f.Category);
docs.Summary = docs.Summary.Insert(0, category);
}
else if (!String.IsNullOrEmpty(f.Version))
{
if (f.Category.StartsWith("VERSION"))
{
category = String.Format(category, "v" + f.Version);
}
else
{
category = String.Format(category, "v" + f.Version + " and " + f.Category);
}
docs.Summary = docs.Summary.Insert(0, category);
}
for (int i = 0; i < f.WrappedDelegate.Parameters.Count; i++)
{
var param = f.WrappedDelegate.Parameters[i];
if (param.ComputeSize != String.Empty)
{
docs.Parameters[i].Documentation.Insert(0,
String.Format("[length: {0}]", param.ComputeSize));
}
}
sw.Write("/// \brief ");
sw.WriteLine(docs.Summary);
foreach (var p in docs.Parameters)
{
sw.Write(@"/// \param ");
sw.Write(p.Name);
sw.WriteLine(p.Documentation);
}
}
catch (Exception e)
{
Console.WriteLine("[Warning] Error documenting function {0}: {1}", f.WrappedDelegate.Name, e.ToString());
}
}