Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
r142258 - in trunk/mcs/tools/mdoc: . Mono.Documentation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jonathan Pryor  
View profile  
 More options Sep 19, 1:34 pm
From: "Jonathan Pryor" <mono-patches-l...@lists.ximian.com>
Date: Sat, 19 Sep 2009 13:34:16 -0400 (EDT)
Local: Sat, Sep 19 2009 1:34 pm
Subject: r142258 - in trunk/mcs/tools/mdoc: . Mono.Documentation
Author: jonpryor
Date: 2009-09-19 13:34:16 -0400 (Sat, 19 Sep 2009)
New Revision: 142258

Modified:
   trunk/mcs/tools/mdoc/ChangeLog
   trunk/mcs/tools/mdoc/Makefile
   trunk/mcs/tools/mdoc/Mono.Documentation/monodocs2html.cs
Log:
        * Mono.Documentation/monodocs2html.cs: By request of Edd Dumbill, add
          --with-version=VERSION option.  This will generate HTML
          documentation for ONLY those types/members which exist within
          VERSION.  This makes it easy to generate HTML that will show e.g.
          only MonoTouch docs (and not the full class library docs).
        * Makefile: Add test for 'mdoc export-html --with-version=VERSION'.
          Somewhat brain-dead, as it only checks for added types (and not
          added members), but better than nothing...

Modified: trunk/mcs/tools/mdoc/ChangeLog
===================================================================
--- trunk/mcs/tools/mdoc/ChangeLog      2009-09-19 17:00:08 UTC (rev 142257)
+++ trunk/mcs/tools/mdoc/ChangeLog      2009-09-19 17:34:16 UTC (rev 142258)
@@ -1,3 +1,14 @@
+2009-09-19  Jonathan Pryor <jpr...@novell.com>
+
+       * Mono.Documentation/monodocs2html.cs: By request of Edd Dumbill, add
+         --with-version=VERSION option.  This will generate HTML
+         documentation for ONLY those types/members which exist within
+         VERSION.  This makes it easy to generate HTML that will show e.g.
+         only MonoTouch docs (and not the full class library docs).
+       * Makefile: Add test for 'mdoc export-html --with-version=VERSION'.
+         Somewhat brain-dead, as it only checks for added types (and not
+         added members), but better than nothing...
+
 2009-09-09  Jonathan Pryor <jpr...@novell.com>

        * Mono.Documentation/monodocs2html.cs: Fix behavior when multiple

Modified: trunk/mcs/tools/mdoc/Makefile
===================================================================
--- trunk/mcs/tools/mdoc/Makefile       2009-09-19 17:00:08 UTC (rev 142257)
+++ trunk/mcs/tools/mdoc/Makefile       2009-09-19 17:34:16 UTC (rev 142258)
@@ -155,6 +155,16 @@
                Test/en.expected.importslashdoc
        diff --exclude=.svn -rup Test/html.expected Test/html.actual

+check-mdoc-export-html-with-version: mdoc.exe
+       rm -Rf Test/html.actual.v0 Test/html.actual.since-with-v0 .v0.txt .v2.txt
+       $(MONO) mdoc.exe export-html -o Test/html.actual.v0 \
+               Test/en.expected
+       $(MONO) mdoc.exe export-html -o Test/html.actual.since-with-v0 \
+               Test/en.expected.since -with-version 0.0.0.0
+       (cd Test/html.actual.v0            && find . -type f) | sort > .v0.txt
+       (cd Test/html.actual.since-with-v0 && find . -type f) | sort > .v2.txt
+       diff -rup .v0.txt .v2.txt   # assert no types added
+
 check-md-html-dir: mdoc.exe
        rm -Rf Test/html.actual
        $(MONO) mdoc.exe export-html -dest:Test/html.actual $(DIR)
@@ -201,6 +211,7 @@
        check-monodocer-importslashdoc \
        check-monodocer \
        check-mdoc-export-html \
+       check-mdoc-export-html-with-version \
        check-mdoc-export-msxdoc \
        check-mdoc-validate

Modified: trunk/mcs/tools/mdoc/Mono.Documentation/monodocs2html.cs
===================================================================
--- trunk/mcs/tools/mdoc/Mono.Documentation/monodocs2html.cs    2009-09-19 17:00:08 UTC (rev 142257)
+++ trunk/mcs/tools/mdoc/Mono.Documentation/monodocs2html.cs    2009-09-19 17:34:16 UTC (rev 142258)
@@ -25,6 +25,7 @@
        public string template;
        public bool   dumptemplate;
        public bool   forceUpdate;
+       public List<string> versions = new List<string> ();
 }

 class MDocToHtmlConverter : MDocCommand {
@@ -53,6 +54,12 @@
                                        "files.  If not specified, uses the template generated by " +
                                        "--default-template.",
                                v => opts.template = v },
+                       { "with-version=",
+                               "The assembly VERSION to generate documentation for.  This allows " +
+                                       "display of a subset of types/members that correspond to the given " +
+                                       "assembly version.  May be specified multiple times.  " +
+                                       "If not specified, all versions are displayed.",
+                               v => opts.versions.Add (v) }
                };
                List<string> extra = Parse (p, args, "export-html",
                                "[OPTIONS]+ DIRECTORIES",
@@ -158,6 +165,7 @@

                                XmlDocument typexml = new XmlDocument();
                                typexml.Load(typefile);
+                               PreserveMembersInVersions (typexml);
                                if (extensions != null) {
                                        DocLoader loader = CreateDocLoader (overview);
                                        XmlDocUtils.AddExtensionMethods (typexml, extensions, loader);
@@ -364,13 +372,37 @@
                                dest.AppendChild (nsd);
                        }
                        foreach (XmlNode t in ns.ChildNodes) {
+                               if (!TypeInVersions (sourceDirectory, n, t))
+                                       continue;
                                var c = dest.OwnerDocument.ImportNode (t, true);
                                AddAttribute (c, "SourceDirectory", sourceDirectory);
                                nsd.AppendChild (c);
                        }
+                       if (nsd.ChildNodes.Count == 0)
+                               dest.RemoveChild (nsd);
                }
        }

+       static bool TypeInVersions (string sourceDirectory, string ns, XmlNode type)
+       {
+               if (opts.versions.Count == 0)
+                       return true;
+               var file = Path.Combine (Path.Combine (sourceDirectory, ns), type.Attributes ["Name"].Value + ".xml");
+               if (!File.Exists (file))
+                       return false;
+               XPathDocument doc;
+               using (var s = File.OpenText (file))
+                       doc = new XPathDocument (s);
+               return MemberInVersions (doc.CreateNavigator ().SelectSingleNode ("/Type"));
+       }
+
+       static bool MemberInVersions (XPathNavigator nav)
+       {
+               return nav.Select ("AssemblyInfo/AssemblyVersion")
+                       .Cast<object> ()
+                       .Any (v => opts.versions.Contains (v.ToString ()));
+       }
+
        static void AddAttribute (XmlNode self, string name, string value)
        {
                var a = self.OwnerDocument.CreateAttribute (name);
@@ -383,6 +415,20 @@
                return !opts.forceUpdate && File.Exists (dest) &&
                        File.GetLastWriteTime (source) < File.GetLastWriteTime (dest);
        }
+
+       private static void PreserveMembersInVersions (XmlDocument doc)
+       {
+               if (opts.versions.Count == 0)
+                       return;
+               var remove = new List<XmlNode>();
+               foreach (XmlNode m in doc.SelectNodes ("/Type/Members/Member")) {
+                       if (!MemberInVersions (m.CreateNavigator ()))
+                               remove.Add (m);
+               }
+               XmlNode members = doc.SelectSingleNode ("/Type/Members");
+               foreach (var m in remove)
+                       members.RemoveChild (m);
+       }
 }

 }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google