protected override void establish_context()
 {
     sut = new XmlDocParser(XDocument.Load(@"AssemblyUnderTest\Bindable.Linq.xml"), Constants.str_targetType)
     {
         TargetAssembly = Assembly.LoadFrom(@"AssemblyUnderTest\Bindable.Linq.dll")
     };
 }
Beispiel #2
0
 private static void Main(string[] args)
 {
     try
     {
         Arguments arguments = Arguments.ProcessArguments(args, new FileSystemService( ));
         Trace.TraceInformation("Beginning documentation generation run at {0}".Inject(DateTime.Now.ToShortTimeString( )));
         var parser = new XmlDocParser(arguments.XmlDocs, arguments.TargetType)
         {
             TargetAssembly = arguments.TargetAssembly
         };
         IEnumerable <XDocument> cleanedDocs = parser.Parse( );
         var writer = new BatchWriter(cleanedDocs);
         writer.Write(arguments.OutputDirectory);
         Trace.TraceInformation("Finished documentation generation run at {0}".Inject(DateTime.Now.ToShortTimeString( )));
     }
     catch (ArgumentException e)
     {
         Console.WriteLine(e.Message);
     }
     catch (Exception e)
     {
         Trace.TraceInformation("Documentation generation run failed at {0}".Inject(DateTime.Now.ToShortTimeString( )));
         Trace.TraceError(e.Message);
         throw;
     }
     //finally
     //{
     //    Console.ReadLine();
     //}
 }
Beispiel #3
0
        public void Should_return_correct_declaration_simple_declaration()
        {
            var type       = typeof(TestClass);
            var methodInfo = type.GetMethods()[1];
            var decl       = XmlDocParser.GetDeclarationFor(methodInfo);

            decl.MustEqual(str_simple_declaration);
        }
        public AssemblyParser(
            string assemblyPath,
            string projectPath,
            string parentName,
            Action <NodeData> nodeCallback,
            Action <LinkData> linkCallback,
            bool isReadSymbols)
        {
            ProjectPath       = projectPath;
            this.assemblyPath = assemblyPath;
            this.parentName   = parentName;
            this.nodeCallback = nodeCallback;

            XmlDocParser xmlDockParser = new XmlDocParser(assemblyPath);

            linkHandler = new LinkHandler(linkCallback);

            assemblyReferencesParser = new AssemblyReferencesParser(linkHandler, nodeCallback);
            typeParser   = new TypeParser(linkHandler, xmlDockParser, nodeCallback);
            memberParser = new MemberParser(linkHandler, xmlDockParser, nodeCallback);

            assembly = new Lazy <AssemblyDefinition>(() => GetAssembly(isReadSymbols));
        }
Beispiel #5
0
        /// <summary>
        /// Parse the files.
        /// </summary>
        private static void Parse()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var location    = Directory.GetCurrentDirectory();
            var versionPath = Path.Combine(location, VersionInfo);

            Console.WriteLine($"Retrieving version info from {versionPath}...");
            var    versionDoc = JsonDocument.Parse(File.ReadAllText(versionPath));
            string version    = versionDoc.RootElement.GetProperty(nameof(version)).GetString();

            Console.WriteLine($"Docs version is {version}");
            var fileChecker = new FileHelper(location);
            var xmlParser   = new XmlDocParser(fileChecker);
            var markdown    = new DocsToMarkdownParser();
            var writer      = new FileWriter(
                rootDir.StartsWith("..") ? Path.Combine(location, rootDir) : rootDir,
                version);

            Console.WriteLine("Parsing assemblies (pass 1)...");
            var assemblies = new List <(DocAssembly doc, AssemblyParser parser)>();

            foreach (var type in ExampleTypes)
            {
                var parser = new AssemblyParser(type.Assembly);
                var doc    = parser.Parse();
                assemblies.Add((doc, parser));
            }

            WriteSuccess($"Parsed {ExampleTypes.Length} assemblies. Starting pass 2...");

            int  fileCount = 0;
            long elapsed   = 0;

            bool deleted = false;

            foreach (var(doc, parser) in assemblies)
            {
                parser.Parse(doc);
                Console.WriteLine($"Checking {doc.Name}...");
                var docName = $"{doc.Name}.xml";
                Console.Write($"Documentation file: {docName} exists? ");
                if (fileChecker.FileExists(docName))
                {
                    WriteSuccess("YES");
                }
                else
                {
                    WriteWarning("NO");
                }

                Console.WriteLine("Parsing XML documents...");
                xmlParser.ParseComments(docName, doc);
                Console.WriteLine("Transforming to markdown...");
                var docFile = markdown.Parse(doc);
                if (deleted == false)
                {
                    Console.WriteLine("Purging existing docs....");
                    writer.Purge();
                    deleted = true;
                }

                Console.WriteLine("Writing documentation...");
                writer.Write(docFile);
                stopwatch.Stop();
                elapsed   += stopwatch.ElapsedMilliseconds;
                fileCount += docFile.FileCount;
                WriteSuccess("Success.");
            }

            WriteSuccess($"Processed {TypeCache.Cache.TypeCount} types and generated {fileCount} files in {elapsed}ms.");
        }