public DocumentationGenerator(string outputPath, string templatePath, ICommentParser commentParser, EventAggregator eventAggregator) { _outputPath = outputPath; _templatePath = templatePath; _commentParser = commentParser; _eventAggregator = eventAggregator; }
public void ShouldRaiseWarningOnUnexpectedKindInReferenceInType() { var events = new EventAggregator(); var model = new DocumentationModelBuilder(RealParser, events); var members = new IDocumentationMember[] {Type<Second>(@"<member name=""T:Example.Second""><summary><see cref=""G:Whats-a-g"" /></summary></member>")}; string text = string.Empty; events.Subscribe(EventType.Warning, x => text = x); model.CombineToTypeHierarchy(members); Assert.AreEqual("Unsupported documentation member found: 'G:Whats-a-g'", text); }
public void subscribers_handler_should_get_called_when_published() { var wasCalled1 = false; var wasCalled2 = false; var aggregator = new EventAggregator(); aggregator.Subscribe(EventType.Warning, x => { wasCalled1 = true; }); aggregator.Subscribe(EventType.BadFile, x => { wasCalled2 = true; }); aggregator.Publish(EventType.Warning, "Whee!"); wasCalled1.ShouldBeTrue(); wasCalled2.ShouldBeFalse(); }
private static void Main(string[] args) { var arguments = new List<string>(args); Console.WriteLine("-------------------------------"); Console.WriteLine(" docu: simple docs done simply "); Console.WriteLine("-------------------------------"); Console.WriteLine(); if (arguments.Count == 0 || arguments.Contains("--help")) { Console.WriteLine("usuage: docu pattern.dll [pattern.dll ...] [pattern.xml ...]"); Console.WriteLine(); Console.WriteLine(" * One or more dll matching patterns can be specified,"); Console.WriteLine(" e.g. MyProject*.dll or MyProject.dll"); Console.WriteLine(); Console.WriteLine(" * Xml file names can be inferred from the dll patterns"); Console.WriteLine(" or can be explicitly named."); Console.WriteLine(); Console.WriteLine("Switches:"); Console.WriteLine(" --help Shows this message"); Console.WriteLine(" --output=value Sets the output path to value"); return; } string outputPath = "output"; string templatePath = Path.Combine(Path.GetDirectoryName(typeof (DocumentationGenerator).Assembly.Location), "templates"); for (int i = arguments.Count - 1; i >= 0; i--) { if (arguments[i].StartsWith("--output=")) { outputPath = arguments[i].Substring(9).TrimEnd('\\'); arguments.RemoveAt(i); continue; } if (arguments[i].StartsWith("--templates=")) { templatePath = arguments[i].Substring(12).TrimEnd('\\'); arguments.RemoveAt(i); } } string[] assemblies = GetAssembliesFromArgs(arguments); string[] xmls = GetXmlsFromArgs(arguments, assemblies); var eventAggregator = new EventAggregator(); eventAggregator.Subscribe(EventType.Warning, message => Console.WriteLine("WARNING: " + message)); eventAggregator.Subscribe(EventType.BadFile, path => Console.WriteLine("The requested file is in a bad format and could not be loaded: '" + path + "'")); var commentParser = new CommentParser(new ICommentNodeParser[] { new InlineCodeCommentParser(), new InlineListCommentParser(), new InlineTextCommentParser(), new MultilineCodeCommentParser(), new ParagraphCommentParser(), new ParameterReferenceParser(), new SeeCodeCommentParser(), }); var generator = new DocumentationGenerator(outputPath, templatePath, commentParser, eventAggregator); if (Verify(arguments, assemblies, xmls)) { Console.WriteLine("Starting documentation generation"); generator.SetAssemblies(assemblies); generator.SetXmlFiles(xmls); generator.Generate(); Console.WriteLine(); Console.WriteLine("Generation complete"); } }