Exemplo n.º 1
0
        public void GenerateDocs()
        {
            var list = DocGenerator.Generate();

            Assert.IsTrue(list.Count > 0);

            Assert.IsFalse(list.Any(x => x.Description == null));
        }
Exemplo n.º 2
0
        public void Generate_WhenInvokedWithoutSettingsAltered_PublicMethodsAreIncluded()
        {
            var generator = new DocGenerator(_document);
            Type type = typeof(TestClass);
            ClassDescription description = generator.Generate(type);

            Assert.AreEqual(4, description.PublicMethods.Count);
        }
Exemplo n.º 3
0
        public void Invoke(CompositionContainer container)
        {
            var traceListener = new ConsolidatedConsoleTraceListener(new Dictionary <string, string>
            {
                { "LostDoc.Core.DocGenerator", "Build" },
            });

            TraceSources.GeneratorSource.Listeners.Add(traceListener);

            try
            {
                SetTraceLevel();

                if (!File.Exists(this.Path))
                {
                    Console.WriteLine("File not found: '{0}'", this.Path);
                    return;
                }

                this.Output = BuildOutputFilePath();

                DocGenerator gen = new DocGenerator(container);

                gen.AssetFilters.AddRange(
                    BuildAssetFilters());

                gen.Enrichers.AddRange(
                    BuildEnrichers());

                gen.AddAssembly(this.Path);

                XDocument rawDoc = gen.Generate();


                //StringWriter output = new StringWriter();
                //try
                //{
                //    using (
                //        XmlWriter writer = XmlWriter.Create(output,
                //                                            new XmlWriterSettings
                //                                                {
                //                                                    CheckCharacters = true,
                //                                                    Encoding = Encoding.ASCII
                //                                                }))
                //        rawDoc.Save(writer);
                //}
                //catch
                //{

                //}

                rawDoc.Save(this.Output);
            }
            finally
            {
                TraceSources.GeneratorSource.Listeners.Remove(traceListener);
            }
        }
Exemplo n.º 4
0
        public void Generate_WhenInvokedAndSettingsAreAltered_PublicMethodsAreNotIncluded()
        {
            var generator = new DocGenerator(_document);
            generator.MethodsToInclude = null;

            Type type = typeof(TestClass);
            ClassDescription description = generator.Generate(type);

            Assert.AreEqual(0, description.PublicMethods.Count);
        }
Exemplo n.º 5
0
        public void Invoke(CompositionContainer container)
        {
            var traceListener = new ConsolidatedConsoleTraceListener(new Dictionary<string, string>
                                                                         {
                                                                             {"LostDoc.Core.DocGenerator", "Build"},
                                                                         });

            TraceSources.GeneratorSource.Listeners.Add(traceListener);

            try
            {
                SetTraceLevel();
                
                if (!File.Exists(this.Path))
                {
                    Console.WriteLine("File not found: '{0}'", this.Path);
                    return;
                }

                this.Output = BuildOutputFilePath();

                DocGenerator gen = new DocGenerator(container);

                gen.AssetFilters.AddRange(
                    BuildAssetFilters());

                gen.Enrichers.AddRange(
                    BuildEnrichers());

                gen.AddAssembly(this.Path);
                
                XDocument rawDoc = gen.Generate();

                
                //StringWriter output = new StringWriter();
                //try
                //{
                //    using (
                //        XmlWriter writer = XmlWriter.Create(output,
                //                                            new XmlWriterSettings
                //                                                {
                //                                                    CheckCharacters = true,
                //                                                    Encoding = Encoding.ASCII
                //                                                }))
                //        rawDoc.Save(writer);
                //}
                //catch
                //{
                    
                //}

                rawDoc.Save(this.Output);

            }
            finally
            {
                TraceSources.GeneratorSource.Listeners.Remove(traceListener);
            }
        }
Exemplo n.º 6
0
        public override void Invoke(CompositionContainer container)
        {
            var traceListener = new ConsolidatedConsoleTraceListener
                                {
                                    { TraceSources.GeneratorSource, "Build" },
                                    { TraceSources.AssemblyLoader, "Loader" },
                                    { TraceSources.AssetResolverSource, "Resolver" },
                                };

            using (traceListener)
            {
                this.ConfigureTraceLevels(traceListener);

                DocGenerator gen = new DocGenerator(container);
                gen.AssetFilters.Add(new ComObjectTypeFilter());
                gen.AssetFilters.Add(new CompilerGeneratedFilter());
                if (!this.IncludeNonPublic.IsPresent)
                    gen.AssetFilters.Add(new PublicTypeFilter());

                gen.AssetFilters.Add(new PrivateImplementationDetailsFilter());
                gen.AssetFilters.Add(new DynamicallyInvokableAttributeFilter());
                gen.AssetFilters.Add(new CompilerGeneratedFilter());
                gen.AssetFilters.Add(new LogicalMemberInfoVisibilityFilter());
                gen.AssetFilters.Add(new SpecialNameMemberInfoFilter());

                if (!string.IsNullOrWhiteSpace(this.Filter))
                    gen.AssetFilters.Add(new AssetGlobFilter { Include = this.Filter });

                XmlDocEnricher docEnricher = new XmlDocEnricher();
                gen.Enrichers.Add(docEnricher);


                if (!string.IsNullOrEmpty(this.NamespaceDocPath))
                {
                    var namespaceEnricher = new ExternalNamespaceDocEnricher();
                    if (System.IO.Path.IsPathRooted(this.NamespaceDocPath))
                        namespaceEnricher.Load(this.NamespaceDocPath);
                    else if (
                        File.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path),
                                                           this.NamespaceDocPath)))
                        namespaceEnricher.Load(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path),
                                                                      this.NamespaceDocPath));
                    else
                        namespaceEnricher.Load(this.NamespaceDocPath);

                    gen.Enrichers.Add(namespaceEnricher);
                }


                if (!File.Exists(this.Path))
                {
                    Console.WriteLine("File not found: '{0}'", this.Path);
                    return;
                }

                if (this.IncludeBclDocComments.IsPresent)
                {
                    string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                    string bclDocPath = System.IO.Path.Combine(winPath, @"microsoft.net\framework\",
                                                               string.Format("v{0}.{1}.{2}",
                                                                             Environment.Version.Major,
                                                                             Environment.Version.Minor,
                                                                             Environment.Version.Build),
                                                               @"en\");


                    docEnricher.AddPath(bclDocPath);

                    bclDocPath = System.IO.Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
                        @"Reference Assemblies\Microsoft\Framework\.NETFramework",
                        string.Format("v{0}.{1}",
                                      Environment.Version.Major,
                                      Environment.Version.Minor));

                    docEnricher.AddPath(bclDocPath);
                }


                var assemblyName = AssemblyName.GetAssemblyName(this.Path);

                XDocument rawDoc = gen.Generate(this.Path);

                string fileName = System.IO.Path.Combine(this.Output ?? System.IO.Path.GetDirectoryName(this.Path),
                                                         string.Format("{0}_{1}.ldoc",
                                                                       System.IO.Path.GetFileName(this.Path),
                                                                       assemblyName.Version));

                this.Output = System.IO.Path.GetFullPath(fileName);

                if (!Directory.Exists(System.IO.Path.GetDirectoryName(fileName)))
                    Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fileName));

                rawDoc.Save(fileName);

            }

        }