Hello,
I was thinking it might be a good idea to make it easier for external
projects to add themselves to monodoc.xml
I wanted to be able to do something like:
monodoc --add-node GtkMozEmbed
to automatically add a line like:
<node label="GtkMozEmbed Libraries" name="classlib-gtkmozembed" />
So this is what the attached patch and file do. (Hopefully) you will be
able to add a line to the install of your docs Makefile to have it added
automatically. As an added bonus we could remove the extra libs from
monodoc.xml so they are not displayed until installed.
John
? addnode.diff
? browser/addnode.cs
? browser/browser.gladep
? class/nunit/nunit-docs.tree
? class/nunit/nunit-docs.zip
? class/nunit/tmp
? doctools/DocStatus
? doctools/lib/monodoc.dll
? doctools/valdoc/generated.cs
Index: browser/Makefile.am
===================================================================
RCS file: /cvs/public/monodoc/browser/Makefile.am,v
retrieving revision 1.17
diff -u -r1.17 Makefile.am
--- browser/Makefile.am 26 Jun 2003 05:51:59 -0000 1.17
+++ browser/Makefile.am 3 Jul 2003 00:28:45 -0000
@@ -2,11 +2,16 @@
monodoc_DATA = browser.exe assembler.exe monodoc.xml
CSC=mcs
-shared_sources = $(srcdir)/monohb-provider.cs $(srcdir)/xhtml-provider.cs
$(srcdir)/ecma-provider.cs $(srcdir)/simple-provider.cs $(srcdir)/html-helper.cs
$(srcdir)/provider.cs $(srcdir)/index.cs
+shared_sources = $(srcdir)/monohb-provider.cs $(srcdir)/xhtml-provider.cs
$(srcdir)/ecma-provider.cs $(srcdir)/simple-provider.cs $(srcdir)/html-helper.cs
$(srcdir)/provider.cs $(srcdir)/index.cs $(srcdir)/addnode.cs
assembler_sources = $(srcdir)/assembler.cs $(shared_sources)
dump_sources = $(srcdir)/dump.cs $(shared_sources)
browser_sources = $(srcdir)/browser.cs $(srcdir)/list.cs $(srcdir)/history.cs
$(shared_sources)
-browser_assemblies = -r:gtk-sharp.dll -r:glade-sharp.dll -r:glib-sharp.dll
-r:ICSharpCode.SharpZipLib.dll -r:pango-sharp.dll -r:gdk-sharp.dll
+browser_assemblies = -r:gtk-sharp.dll \
+ -r:glade-sharp.dll \
+ -r:glib-sharp.dll \
+ -r:ICSharpCode.SharpZipLib.dll \
+ -r:pango-sharp.dll \
+ -r:gdk-sharp.dll
EXTRA_DIST = $(assembler_sources) $(dump_sources) $(browser_sources) browser.glade
monodoc.xml mono-ecma.xsl
Index: browser/browser.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/browser.cs,v
retrieving revision 1.33
diff -u -r1.33 browser.cs
--- browser/browser.cs 30 Jun 2003 23:47:11 -0000 1.33
+++ browser/browser.cs 3 Jul 2003 00:28:45 -0000
@@ -27,7 +27,7 @@
"Joshua Tauberer <[EMAIL PROTECTED]",
"Lee Mallabone <[EMAIL PROTECTED]",
"Philip Van Hoof <[EMAIL PROTECTED]",
-
+ "John Luke <[EMAIL PROTECTED]>",
};
Glade.XML ui;
@@ -61,6 +61,9 @@
case "--help":
Console.WriteLine ("Options are:\n"+
"browser [--html TOPIC]
[--make-index] [TOPIC]");
+ return 0;
+ case "--add-node":
+ new AddNode (args[1]);
return 0;
default:
topic = args [i];
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class AddNode
{
public AddNode (string NewLabel)
{
Boolean alreadythere = false;
string NewName = "classlib-" + NewLabel.ToLower ();
NewLabel = NewLabel + " Libraries";
XPathDocument doc = new XPathDocument ("monodoc.xml");
XPathNavigator nav = doc.CreateNavigator ();
XPathNodeIterator xni = nav.Select ("/node/node");
// the root node
System.Text.Encoding utf8 = new System.Text.UTF8Encoding (false, true);
XmlTextWriter writer = new XmlTextWriter ("monodoc.xml", utf8);
writer.Formatting = Formatting.Indented;
writer.WriteStartDocument ();
writer.WriteStartElement (null,"node", null);
writer.WriteStartAttribute (null, "label", null);
writer.WriteRaw ("Mono Documentation");
writer.WriteEndAttribute ();
writer.WriteStartAttribute (null, "name", null);
writer.WriteRaw ("root:");
writer.WriteEndAttribute ();
for (int i = 0; i < xni.Count; i++)
{
xni.MoveNext ();
XmlNode node = ((IHasXmlNode) xni.Current).GetNode ();
XmlAttributeCollection attr = node.Attributes;
string label = attr["label"].Value;
string name = attr["name"].Value;
// do not write a path twice
if (NewName == name)
alreadythere = true;
// the original values
writer.WriteStartElement (null,"node", null);
writer.WriteStartAttribute (null, "label", null);
writer.WriteRaw (label);
writer.WriteEndAttribute ();
writer.WriteStartAttribute (null, "name", null);
writer.WriteRaw (name);
writer.WriteEndAttribute ();
writer.WriteEndElement ();
}
// the new node
if (alreadythere != true)
{
writer.WriteStartElement (null,"node", null);
writer.WriteStartAttribute (null, "label", null);
writer.WriteRaw (NewLabel);
writer.WriteEndAttribute ();
writer.WriteStartAttribute (null, "name", null);
writer.WriteRaw (NewName);
writer.WriteEndAttribute ();
writer.WriteEndElement ();
}
writer.WriteEndElement ();
writer.WriteEndDocument ();
writer.Flush ();
writer.Close ();
}
}