[Mono-docs-list] Update on Web based MonoDoc...
Philippe Desaulniers
filou@histrion.org
08 Jul 2003 23:09:11 -0400
--=-KiPeNQwrT4LmC6QEpLeG
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hello,
Here it is with modifications after your comments. I've added a helper
class 'WwwGenerator', that performs the href prepending. This class
will probably prove useful for Tree generation as well, I haven't
taken a look at that yet.
Added bonus: if someone ever cares about implementing a separate
assembly for web output, the helper class will be usable as is.
Included: diffs on Makefile.am and browser.cs, plus new wwwgenerator.cs
file.
Comments welcome...
phil
--=-KiPeNQwrT4LmC6QEpLeG
Content-Disposition: attachment; filename=Makefile.am.diff.txt
Content-Type: text/x-patch; name=Makefile.am.diff.txt; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Index: Makefile.am
===================================================================
RCS file: /mono/monodoc/browser/Makefile.am,v
retrieving revision 1.17
diff -u -r1.17 Makefile.am
--- Makefile.am 26 Jun 2003 05:51:59 -0000 1.17
+++ Makefile.am 9 Jul 2003 02:58:50 -0000
@@ -5,18 +5,18 @@
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
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_sources = $(srcdir)/browser.cs $(srcdir)/wwwgenerator.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
-EXTRA_DIST = $(assembler_sources) $(dump_sources) $(browser_sources) browser.glade monodoc.xml mono-ecma.xsl
+EXTRA_DIST = $(assembler_sources) $(dump_sources) $(browser_sources) browser.glade monodoc.xml mono-ecma.xsl mono-hrefreplace.xsl
monodoc_FILES = browser.exe assembler.exe
assembler.exe: $(assembler_sources)
$(CSC) /debug /out:assembler.exe $(assembler_sources) -r:ICSharpCode.SharpZipLib.dll
-browser.exe: $(browser_sources) browser.glade mono-ecma.xsl $(srcdir)/../monodoc.png
- $(CSC) /debug /out:browser.exe $(browser_sources) /resource:$(srcdir)/../monodoc.png,monodoc.png /resource:$(srcdir)/browser.glade,browser.glade /resource:$(srcdir)/mono-ecma.xsl,mono-ecma.xsl $(browser_assemblies)
+browser.exe: $(browser_sources) browser.glade mono-ecma.xsl mono-hrefreplace.xsl $(srcdir)/../monodoc.png
+ $(CSC) /debug /out:browser.exe $(browser_sources) /resource:$(srcdir)/../monodoc.png,monodoc.png /resource:$(srcdir)/browser.glade,browser.glade /resource:$(srcdir)/mono-ecma.xsl,mono-ecma.xsl /resource:$(srcdir)/mono-hrefreplace.xsl,mono-hrefreplace.xsl $(browser_assemblies)
dump.exe: $(dump_sources)
$(CSC) /debug /out:dump.exe $(dump_sources) -r:ICSharpCode.SharpZipLib.dll
--=-KiPeNQwrT4LmC6QEpLeG
Content-Disposition: attachment; filename=browser.cs.diff.txt
Content-Type: text/x-patch; name=browser.cs.diff.txt; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Index: browser.cs
===================================================================
RCS file: /mono/monodoc/browser/browser.cs,v
retrieving revision 1.34
diff -u -r1.34 browser.cs
--- browser.cs 9 Jul 2003 01:56:11 -0000 1.34
+++ browser.cs 9 Jul 2003 03:00:08 -0000
@@ -17,6 +17,8 @@
using Glade;
using System;
using System.IO;
+using System.Xml;
+using System.Xml.Xsl;
using System.Reflection;
using System.Collections;
@@ -31,15 +33,41 @@
for (int i = 0; i < args.Length; i++){
switch (args [i]){
case "--html":
- if (i+1 == args.Length){
- Console.WriteLine ("--html needed argument");
- return 1;
+ case "--www":
+ string processor_url = null;
+
+ if (args [i] == "--html") {
+ if (i+1 == args.Length){
+ Console.WriteLine ("--html needed argument");
+ return 1;
+ }
+
+ else {
+ topic = args [i+1];
+ }
}
-
+
+ else if (args [i] == "--www") {
+ if (i+2 >= args.Length){
+ Console.WriteLine ("--www needs two arguments");
+ return 1;
+ }
+
+ else {
+ processor_url = args [i+1];
+ topic = args [i+2];
+ }
+ }
+
Node n;
RootTree help_tree = RootTree.LoadTree ();
- string res = help_tree.RenderUrl (args [i+1], out n);
+
+ string res = help_tree.RenderUrl (topic, out n);
if (res != null){
+ if (args [i] == "--www") {
+ res = WwwGenerator.HrefReplace(res, processor_url);
+ }
+
Console.WriteLine (res);
return 0;
} else {
@@ -51,7 +79,7 @@
case "--help":
Console.WriteLine ("Options are:\n"+
- "browser [--html TOPIC] [--make-index] [TOPIC]");
+ "browser [--html TOPIC] [--www PROCESSOR_URL TOPIC] [--make-index] [TOPIC]");
return 0;
default:
topic = args [i];
--=-KiPeNQwrT4LmC6QEpLeG
Content-Disposition: attachment; filename=wwwgenerator.cs
Content-Type: text/plain; name=wwwgenerator.cs; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
//
// wwwgenerator.cs: Helper class to generate MonoDoc Web output.
//
// Author:
// Philippe Desaulniers
//
// (C) 2003 Philippe Desaulniers.
//
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Reflection;
class WwwGenerator {
//
// HrefReplace: Prepend all MonoDoc URLs in a Provider output string with a given processor name.
//
public static string HrefReplace ( string providerOutput, string processorName )
{
// Provider output is not valid XML, need to add XML header and a root node.
// ...this will break when Providers start outputing other encodings than UTF-8
providerOutput = "<?xml version=\"1.0\" ?>\n<monodoc-provider-output>\n"
+ providerOutput
+ "\n</monodoc-provider-output>";
XsltArgumentList xsl_args = new XsltArgumentList();
xsl_args.AddParam("processorurl", "", processorName);
XslTransform hrefreplace_transform = new XslTransform ();
Assembly assembly = System.Reflection.Assembly.GetCallingAssembly ();
Stream stream = assembly.GetManifestResourceStream ("mono-hrefreplace.xsl");
XmlReader xml_reader = new XmlTextReader (stream);
hrefreplace_transform.Load (xml_reader);
XmlDocument source = new XmlDocument();
source.LoadXml(providerOutput);
StringWriter output = new StringWriter ();
hrefreplace_transform.Transform (source, xsl_args, output);
return output.ToString();
}
}
--=-KiPeNQwrT4LmC6QEpLeG--