+2009-09-19 Jonathan Pryor <jpryor@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 <jpryor@novell.com>
* Mono.Documentation/monodocs2html.cs: Fix behavior when multiple
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)
check-monodocer-importslashdoc \
check-monodocer \
check-mdoc-export-html \
+ check-mdoc-export-html-with-version \
check-mdoc-export-msxdoc \
check-mdoc-validate
public string template;
public bool dumptemplate;
public bool forceUpdate;
+ public List<string> versions = new List<string> ();
}
class MDocToHtmlConverter : MDocCommand {
"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",
XmlDocument typexml = new XmlDocument();
typexml.Load(typefile);
+ PreserveMembersInVersions (typexml);
if (extensions != null) {
DocLoader loader = CreateDocLoader (overview);
XmlDocUtils.AddExtensionMethods (typexml, extensions, loader);
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);
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);
+ }
}
}