Inheritance: IDocumentationGenerator
Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        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");
            }
        }