static void GetTypePaths(MDocToHtmlConverterOptions opts, XmlElement type, out string typename, out string srcfile, out string destfile) { srcfile = null; destfile = null; string nsname = type.ParentNode.Attributes ["Name"].Value; string typefilebase = type.GetAttribute("Name"); string sourceDir = type.GetAttribute("SourceDirectory"); typename = type.GetAttribute("DisplayName"); if (typename.Length == 0) { typename = typefilebase; } if (opts.onlytype != null && !(nsname + "." + typename).StartsWith(opts.onlytype)) { return; } srcfile = CombinePath(sourceDir, nsname, typefilebase + ".xml"); if (srcfile == null) { return; } destfile = CombinePath(opts.dest, nsname, typefilebase + "." + opts.ext); }
static bool ShouldRegenIndexes(MDocToHtmlConverterOptions opts, XmlDocument overview, List <string> sourceDirectories) { string overviewDest = opts.dest + "/index." + opts.ext; if (sourceDirectories.Any( d => !DestinationIsNewer(Path.Combine(d, "index.xml"), overviewDest))) { return(true); } foreach (XmlElement type in overview.SelectNodes("Overview/Types/Namespace/Type")) { string _, srcfile, destfile; GetTypePaths(opts, type, out _, out srcfile, out destfile); if (srcfile == null || destfile == null) { continue; } if (DestinationIsNewer(srcfile, destfile)) { return(true); } } return(false); }
public override void Run (IEnumerable<string> args) { opts = new MDocToHtmlConverterOptions (); var p = new OptionSet () { { "default-template", "Writes the default XSLT to stdout.", v => opts.dumptemplate = v != null }, { "ext=", "The file {EXTENSION} to use for created files. "+ "This defaults to \"html\".", v => opts.ext = v }, { "force-update", "Always generate new files. If not specified, will only generate a " + "new file if the source .xml file is newer than the current output " + "file.", v => opts.forceUpdate = v != null }, { "o|out=", "The {DIRECTORY} to place the generated files and directories.", v => opts.dest = v }, { "template=", "An XSLT {FILE} to use to generate the created " + "files.If not specified, uses the template generated by " + "--default-template.", v => opts.template = v }, { "with-profile=", "The .NET {PROFILE} to generate documentation for. This is " + "equivalent to using --with-version for all of the " + "versions that a profile uses. Valid profiles are:\n " + string.Join ("\n ", profiles.Keys.OrderBy (v => v).ToArray ()), v => { if (!profiles.ContainsKey (v)) throw new ArgumentException (string.Format ("Unsupported profile '{0}'.", v)); foreach (var ver in profiles [v.ToLowerInvariant ()]) opts.versions.Add (ver); } }, { "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", "Export mdoc documentation within DIRECTORIES to HTML."); if (extra == null) return; if (opts.dumptemplate) DumpTemplate (); else ProcessDirectories (extra); opts.onlytype = "ignore"; // remove warning about unused member }
public override void Run(IEnumerable <string> args) { opts = new MDocToHtmlConverterOptions(); var p = new OptionSet() { { "default-template", "Writes the default XSLT to stdout.", v => opts.dumptemplate = v != null }, { "ext=", "The file {EXTENSION} to use for created files. " + "This defaults to \"html\".", v => opts.ext = v }, { "force-update", "Always generate new files. If not specified, will only generate a " + "new file if the source .xml file is newer than the current output " + "file.", v => opts.forceUpdate = v != null }, { "o|out=", "The {DIRECTORY} to place the generated files and directories.", v => opts.dest = v }, { "template=", "An XSLT {FILE} to use to generate the created " + "files.If not specified, uses the template generated by " + "--default-template.", v => opts.template = v }, { "with-profile=", "The .NET {PROFILE} to generate documentation for. This is " + "equivalent to using --with-version for all of the " + "versions that a profile uses. Valid profiles are:\n " + string.Join("\n ", profiles.Keys.OrderBy(v => v).ToArray()), v => { if (!profiles.ContainsKey(v)) { throw new ArgumentException(string.Format("Unsupported profile '{0}'.", v)); } foreach (var ver in profiles[v.ToLowerInvariant()]) { opts.versions.Add(ver); } } }, { "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", "Export mdoc documentation within DIRECTORIES to HTML."); if (extra == null) { return; } if (opts.dumptemplate) { DumpTemplate(); } else { ProcessDirectories(extra); } opts.onlytype = "ignore"; // remove warning about unused member }
static void GetTypePaths (MDocToHtmlConverterOptions opts, XmlElement type, out string typename, out string srcfile, out string destfile) { srcfile = null; destfile = null; string nsname = type.ParentNode.Attributes ["Name"].Value; string typefilebase = type.GetAttribute("Name"); string sourceDir = type.GetAttribute("SourceDirectory"); typename = type.GetAttribute("DisplayName"); if (typename.Length == 0) typename = typefilebase; if (opts.onlytype != null && !(nsname + "." + typename).StartsWith(opts.onlytype)) return; srcfile = CombinePath (sourceDir, nsname, typefilebase + ".xml"); if (srcfile == null) return; destfile = CombinePath (opts.dest, nsname, typefilebase + "." + opts.ext); }
static bool ShouldRegenIndexes (MDocToHtmlConverterOptions opts, XmlDocument overview, List<string> sourceDirectories) { string overviewDest = opts.dest + "/index." + opts.ext; if (sourceDirectories.Any ( d => !DestinationIsNewer (Path.Combine (d, "index.xml"), overviewDest))) return true; foreach (XmlElement type in overview.SelectNodes("Overview/Types/Namespace/Type")) { string _, srcfile, destfile; GetTypePaths (opts, type, out _, out srcfile, out destfile); if (srcfile == null || destfile == null) continue; if (DestinationIsNewer (srcfile, destfile)) return true; } return false; }