GtkSharp/doc/scan-deprecations.cs
Mike Kestner 0c3d27b0c1 2003-02-26 Mike Kestner <mkestner@ximian.com>
* scan-deprecations.cs : little xpath tool to inspect deprecates.

svn path=/trunk/gtk-sharp/; revision=23499
2004-02-26 19:32:04 +00:00

71 lines
2 KiB
C#

namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class ScanDeprecations {
public static int Main (string[] args)
{
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
foreach (string arg in args) {
try {
Stream stream = File.OpenRead (arg);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
string ignores = "";
string kills = "";
string nonstubs = "";
ArrayList kill_elems = new ArrayList ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Members/Member[@Deprecated='true']");
while (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
string member_type = elem["MemberType"].InnerText;
switch (member_type) {
case "Field":
string summary = elem["Docs"]["summary"].InnerText;
string remarks = elem["Docs"]["remarks"].InnerText;
if (summary == "To be added" && remarks == "To be added") {
kills += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
kill_elems.Add (elem);
} else
nonstubs += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
break;
default:
ignores += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
break;
}
}
foreach (XmlNode node in kill_elems)
node.ParentNode.RemoveChild (node);
api_doc.Save (arg);
if (ignores != "" || kills != "" || nonstubs != "") {
Console.WriteLine (arg + ":");
if (ignores != "")
Console.WriteLine (" Ignored:" + ignores);
if (kills != "")
Console.WriteLine (" Killed:" + kills);
if (nonstubs != "")
Console.WriteLine (" Non-stubbed deprecates:" + nonstubs);
}
}
return 0;
}
}
}