示例#1
0
        public Task <int> Execute()
        {
            return(ConsoleTask.ExecuteAsync(this, async(console) =>
            {
                foreach (var file in GetMatchingFiles(InputFile))
                {
                    console.Write("Generating doc for ");
                    console.WriteLine(file);

                    var metadata = PackageMetadataProvider.FromFile(file);
                    var outputPath = Output.Replace("*", CleanFileName(metadata.Title));
                    var writer = new DocumentationWriter();
                    var extension = Path.GetExtension(outputPath).ToUpperInvariant().TrimStart('.');
                    switch (extension)
                    {
                    case "PUML":
                    case "TXT":
                        writer.Format = DiagramFormat.PlantUml;
                        writer.Output = DocumentOutput.Diagram;
                        break;

                    case "SVG":
                    case "PNG":
                        writer.Format = (DiagramFormat)Enum.Parse(typeof(DiagramFormat), extension, true);
                        writer.Output = DocumentOutput.Diagram;
                        break;

                    case "MD":
                        writer.Format = DiagramFormat.PlantUml;
                        writer.Output = DocumentOutput.Markdown;
                        break;
                    }

                    try
                    {
                        using (var stream = File.OpenWrite(outputPath))
                            await writer.WriteAsync(metadata, stream);
                    }
                    catch (Exception ex)
                    {
                        console.WriteLine("Error documenting " + file);
                        console.WriteLine(ex.ToString());
                    }
                }
            }));
        }