/// <summary> /// Initializes a new instance of the <see cref="BaseReflectionDocumenter"/> class. /// </summary> /// <param name="config">Documenter setting</param> protected BaseReflectionDocumenter( IDocumenterConfig config ) : base( config ) { }
/// <summary>Clears the project.</summary> public void Clear() { _AssemblySlashDocs.Clear(); if (_namespaces != null) _namespaces = new Namespaces(); if (_referencePaths != null) _referencePaths = new ReferencePathCollection(); // cache the current active info object IDocumenterInfo currentInfo = null; if ( this._currentConfig != null ) currentInfo = _currentConfig.DocumenterInfo; // create a new configs collection populated with new configs for each type Hashtable newConfigs = new Hashtable(); foreach ( IDocumenterConfig config in _configs.Values ) newConfigs.Add( config.DocumenterInfo.Name, config.DocumenterInfo.CreateConfig( this ) ); _configs = newConfigs; // reset the active config if ( currentInfo != null ) _currentConfig = _configs[currentInfo.Name] as IDocumenterConfig; IsDirty = false; ProjectFile = ""; }
public static int Main(string[] args) { try { WriteLogoBanner(); project = new Project(); IDocumenterInfo info = InstalledDocumenters.GetDocumenter("MSDN"); if (info == null) { //MSDN documenterConfig not found, pick the first one available. if (InstalledDocumenters.Documenters.Count > 0) { info = (IDocumenterInfo)InstalledDocumenters.Documenters[0]; } else { throw new ApplicationException("Could not find any documenter assemblies."); } } project.ActiveDocumenter = info; documenterConfig = project.ActiveConfig; int maxDepth = 20; //to limit recursion depth bool propertiesSet = false; bool projectSet = false; if (args.Length==0) { WriteUsage(); return 1; } if (args[0].ToLower().StartsWith("-help")) { WriteHelp(args); return 1; } foreach (string arg in args) { if (arg.StartsWith("-")) { if (string.Compare(arg, "-verbose", true) == 0) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); } else { string[] pair = arg.Split('='); if (pair.Length == 2) { string name = pair[0].Substring(1); string val = pair[1]; switch (name.ToLower()) { case "documenter": if (propertiesSet) { throw new ApplicationException("The documenter name must be specified before any documenter specific options."); } if (projectSet) { throw new ApplicationException("The documenter name must be specified before the project file."); } info = InstalledDocumenters.GetDocumenter(val.Replace("_"," ")); if (info == null) { throw new ApplicationException("The specified documenter name is invalid."); } project.ActiveDocumenter = info; documenterConfig = project.ActiveConfig; break; case "project": if (propertiesSet) { throw new ApplicationException("The project file must be specified before any documenter specific options."); } Console.WriteLine("using project file " + val); project.Read(val); project.ActiveDocumenter = info; documenterConfig = project.ActiveConfig; projectSet = true; Directory.SetCurrentDirectory(Path.GetDirectoryName(val)); Debug.WriteLine(Directory.GetCurrentDirectory()); break; case "recurse": string[] recPair = val.Split(','); if (2 == recPair.Length) { maxDepth = Convert.ToInt32(recPair[1]); } RecurseDir(recPair[0], maxDepth); break; case "namespacesummaries": using(StreamReader streamReader = new StreamReader(val)) { XmlTextReader reader = new XmlTextReader(streamReader); reader.MoveToContent(); project.Namespaces.Read(reader); reader.Close(); streamReader.Close(); } break; case "referencepath": project.ReferencePaths.Add(new ReferencePath(val)); break; default: documenterConfig.SetValue(name, val); propertiesSet = true; break; } } } } else if (arg.IndexOf(',') != -1) { string[] pair = arg.Split(','); if (pair.Length == 2) { project.AssemblySlashDocs.Add( new AssemblySlashDoc(pair[0], pair[1])); } } else { string doc = Path.ChangeExtension(arg, ".xml"); if (File.Exists(doc)) { project.AssemblySlashDocs.Add( new AssemblySlashDoc(arg, doc)); } else { project.AssemblySlashDocs.Add( new AssemblySlashDoc(arg, "")); } } } if (project.AssemblySlashDocs.Count == 0) { Console.WriteLine("[Error] Build cannot proceed; No assemblies were specified, or none could be found."); //WriteUsage(); return 1; } else { startDateTime = DateTime.UtcNow; IDocumenter documenter = documenterConfig.CreateDocumenter(); documenter.DocBuildingStep += new DocBuildingEventHandler(DocBuildingStepHandler); documenter.Build(project); TimeSpan ts = DateTime.UtcNow - startDateTime; Console.WriteLine(String.Format("Total build time {0:f1} s", ts.TotalSeconds)); return 0; } } catch( Exception except ) { string errorText= BuildExceptionText(except); Console.WriteLine(errorText); System.Diagnostics.Trace.WriteLine(errorText); return 2; } }
private static void WriteHelpDocParameter(IDocumenterConfig documenterConfig,string propertyName) { PropertyInfo foundProperty=null; foreach (PropertyInfo property in documenterConfig.GetProperties()) { if (string.Compare(property.Name, propertyName, true) == 0) { foundProperty=property; break; } } if (foundProperty==null) { Console.WriteLine("{0} is not a property of the {1} documenterConfig...", propertyName, documenterConfig.DocumenterInfo.Name); Console.WriteLine(""); WriteHelpAvailableDocParameters(documenterConfig); } else { WriteHelpPropertyDetails(foundProperty); } }
private static void WriteHelpAvailableDocParameters(IDocumenterConfig documenterConfig) { Console.WriteLine("available properties with the {0} documenterConfig:", documenterConfig.DocumenterInfo.Name); foreach (PropertyInfo property in documenterConfig.GetProperties()) { if (!property.IsDefined(typeof(NonPersistedAttribute),true)) { Console.WriteLine(" " + property.Name); } } }
/// <summary>Initializes a new instance of the <see cref="BaseDocumenter"/> class.</summary> /// <param name="config_">settings</param> protected BaseDocumenter( IDocumenterConfig config_ ) { Debug.Assert( config_ != null ); config = config_; }