public static int Main(string[] args) { bool show_help = false; bool useRawDoc = false; var mergerOptions = new AppleDocMerger.Options (); var options = new OptionSet () { { "apple-doc-dir=", "{DIRECTORY} for the Apple documentation.", v => mergerOptions.DocBase = Path.Combine (v, "Contents/Resources/Documents/documentation") }, { "reference-assembly=", "{ASSEMBLY} file containing the types to find documentation for.", v => mergerOptions.Assembly = AssemblyDefinition.ReadAssembly (v) }, { "ns-prefix=", "{NAMESPACE} prefix for the types to parse.", v => mergerOptions.BaseAssemblyNamespace = v }, { "import-samples", "If set, the tool will import samples from an external repository", v => mergerOptions.ImportSamples = v != null }, { "samples-repository=", "Tell where to find the sample .zip repository", v => mergerOptions.SamplesRepositoryPath = v}, { "use-raw-doc", "Process uncompiled mdoc documentation rather than a bundle", v => useRawDoc = v != null}, { "v|verbose", "Verbose output", v => mergerOptions.MergingPathCallback = v != null ? p => Console.WriteLine (p) : (Action<string>)null }, { "h|?|help", "Show this help message and exit.", v => show_help = v != null }, }; string monodocPath = null; try { monodocPath = options.Parse (args).FirstOrDefault (); } catch (Exception e) { Console.Error.WriteLine (e.ToString ()); Console.Error.WriteLine ("Use '--help' for more information."); return 1; } if (string.IsNullOrEmpty (monodocPath) || show_help) { ShowHelp (options); return 0; } IMdocArchive mdocArchive = null; if (useRawDoc) mdocArchive = new MDocDirectoryArchive (Path.Combine (monodocPath, "en")); else mdocArchive = MDocZipArchive.ExtractAndLoad (Path.Combine (monodocPath, "MonoTouch-lib.zip")); mergerOptions.MonodocArchive = mdocArchive; var merger = new AppleDocMerger (mergerOptions); merger.MergeDocumentation (); mdocArchive.CommitChanges (); return 0; }
public void LaunchMergeProcess (AppleDocInformation infos, string resourcePath, CancellationToken token) { // TODO: take token into account inside merging if (token.IsCancellationRequested) return; var evtArgs = new AppleDocEventArgs () { Stage = ProcessStage.Merging }; FireAppleDocEvent (evtArgs); var merger = new AppleDocMerger (new AppleDocMerger.Options () { DocBase = Path.Combine (searchPaths.First (), infos.ID + ".docset", "Contents/Resources/Documents/documentation"), Assembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom (MonoTouchLibPath), BaseAssemblyNamespace = "MonoTouch", ImportSamples = true, //SamplesRepositoryPath = Path.Combine (resourcePath, "samples.zip"), MonoDocBaseDir = Path.Combine (MonodocLibPath, "en"), SamplesRepositoryPath = Path.Combine (MonodocLibPath, "samples.zip"), MergingPathCallback = path => { evtArgs.CurrentFile = path; FireAppleDocEvent (evtArgs); } }); merger.MergeDocumentation (); var statusFile = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "macdoc", "merge.status"); File.WriteAllText (statusFile, infos.Version.ToString ()); FireAppleDocEvent (new AppleDocEventArgs () { Stage = ProcessStage.Finished }); }
public void LaunchMergeProcess (AppleDocInformation infos, string resourcePath, CancellationToken token) { if (token.IsCancellationRequested) return; var evtArgs = new AppleDocEventArgs () { Stage = ProcessStage.Merging }; FireAppleDocEvent (evtArgs); var mdocArchive = MDocZipArchive.ExtractAndLoad (Path.Combine (MonodocLibPath, "MonoTouch-lib.zip")); var merger = new AppleDocMerger (new AppleDocMerger.Options () { DocBase = Path.Combine (searchPaths.First (), infos.ID + ".docset", "Contents/Resources/Documents/documentation"), Assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly (MonoTouchLibPath), BaseAssemblyNamespace = "MonoTouch", ImportSamples = true, MonodocArchive = mdocArchive, SamplesRepositoryPath = Path.Combine (resourcePath, "samples.zip"), MergingPathCallback = path => { evtArgs.CurrentFile = path; FireAppleDocEvent (evtArgs); }, CancellationToken = token }); merger.MergeDocumentation (); if (!token.IsCancellationRequested) { mdocArchive.CommitChanges (); var statusDirectory = Path.Combine (baseApplicationPath, "macdoc"); if (!Directory.Exists (statusDirectory)) Directory.CreateDirectory (statusDirectory); var statusFile = Path.Combine (statusDirectory, "merge.status"); File.WriteAllText (statusFile, infos.Version.ToString ()); } FireAppleDocEvent (new AppleDocEventArgs () { Stage = ProcessStage.Finished }); }
public static int Main(string[] args) { bool show_help = false; bool useRawDoc = false; var mergerOptions = new AppleDocMerger.Options(); var options = new OptionSet() { { "apple-doc-dir=", "{DIRECTORY} for the Apple documentation.", v => mergerOptions.DocBase = Path.Combine(v, "Contents/Resources/Documents/documentation") }, { "reference-assembly=", "{ASSEMBLY} file containing the types to find documentation for.", v => mergerOptions.Assembly = AssemblyDefinition.ReadAssembly(v) }, { "ns-prefix=", "{NAMESPACE} prefix for the types to parse.", v => mergerOptions.BaseAssemblyNamespace = v }, { "import-samples", "If set, the tool will import samples from an external repository", v => mergerOptions.ImportSamples = v != null }, { "samples-repository=", "Tell where to find the sample .zip repository", v => mergerOptions.SamplesRepositoryPath = v }, { "use-raw-doc", "Process uncompiled mdoc documentation rather than a bundle", v => useRawDoc = v != null }, { "v|verbose", "Verbose output", v => mergerOptions.MergingPathCallback = v != null ? p => Console.WriteLine(p) : (Action <string>)null }, { "h|?|help", "Show this help message and exit.", v => show_help = v != null }, }; string monodocPath = null; try { monodocPath = options.Parse(args).FirstOrDefault(); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Console.Error.WriteLine("Use '--help' for more information."); return(1); } if (string.IsNullOrEmpty(monodocPath) || show_help) { ShowHelp(options); return(0); } IMdocArchive mdocArchive = null; if (useRawDoc) { mdocArchive = new MDocDirectoryArchive(Path.Combine(monodocPath, "en")); } else { mdocArchive = MDocZipArchive.ExtractAndLoad(Path.Combine(monodocPath, "MonoTouch-lib.zip")); } mergerOptions.MonodocArchive = mdocArchive; var merger = new AppleDocMerger(mergerOptions); merger.MergeDocumentation(); mdocArchive.CommitChanges(); return(0); }
public static int Main(string [] args) { string dir = null; string lib = null; var debug = Environment.GetEnvironmentVariable("DOCFIXER"); bool debugDoc = false; for (int i = 0; i < args.Length; i++) { var arg = args [i]; if (arg == "-h" || arg == "--help") { Help(); return(0); } if (arg == "--appledocs") { mergeAppledocs = true; continue; } if (arg == "--debugdoc") { debugDoc = true; continue; } if (lib == null) { lib = arg; } else { dir = arg; } } if (dir == null) { Help(); return(1); } if (File.Exists(Path.Combine(dir, "en"))) { Console.WriteLine("The directory does not seem to be the root for documentation (missing `en' directory)"); return(1); } assembly_dir = Path.Combine(dir, "en"); assembly = Assembly.LoadFrom(lib); docGenerator = new AppleDocMerger(new AppleDocMerger.Options { DocBase = Path.Combine(docBase, "Contents/Resources/Documents/documentation"), DebugDocs = debugDoc, MonodocArchive = new MDocDirectoryArchive(assembly_dir), Assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly(lib), BaseAssemblyNamespace = ns, ImportSamples = false }); foreach (Type t in assembly.GetTypes()) { if (debugDoc) { string str = docGenerator.GetAppleDocFor(ToCecilType(t)); if (str == null) { Console.WriteLine("Could not find docs for {0}", t); } continue; } if (debug != null && t.FullName != debug) { continue; } var btas = t.GetCustomAttributes(typeof(BaseTypeAttribute), true); ProcessNSO(t, btas.Length > 0 ? (BaseTypeAttribute)btas [0] : null); } foreach (Type notification_event_args in event_args_to_notification_uses.Keys) { var uses = event_args_to_notification_uses [notification_event_args]; } Console.WriteLine("saving"); SaveDocs(); return(0); }