Пример #1
0
        private static void BuildDocumentation(string content, List <string> matches, string schemaName)
        {
            PGSchema schema = SchemaProcessor.GetSchema(schemaName);

            content = content.Replace("[DBName]", Program.Database.ToUpperInvariant());
            content = content.Replace("[SchemaName]", schemaName);

            content = SequenceParser.Parse(content, matches, SequenceProcessor.GetSequences(schemaName));
            content = TableParser.Parse(content, matches, schema.Tables);
            content = ViewParser.Parse(content, matches, schema.Views);
            content = SequenceParser.Parse(content, matches, schema.Sequences);
            content = MaterializedViewParser.Parse(content, matches, schema.MaterializedViews);
            content = FunctionParser.Parse(content, matches, schema.Functions);
            content = FunctionParser.ParseTriggers(content, matches, schema.TriggerFunctions);
            content = TypeParser.Parse(content, matches, schema.Types);

            foreach (PgTable table in schema.Tables)
            {
                Console.WriteLine("Generating documentation for table \"{0}\".", table.Name);
                TableRunner.Run(table);
            }


            foreach (PgFunction function in schema.Functions)
            {
                Console.WriteLine("Generating documentation for function \"{0}\".", function.Name);
                FunctionRunner.Run(function);
            }

            foreach (PgFunction function in schema.TriggerFunctions)
            {
                Console.WriteLine("Generating documentation for trigger function \"{0}\".", function.Name);
                FunctionRunner.Run(function);
            }

            foreach (PgMaterializedView materializedView in schema.MaterializedViews)
            {
                Console.WriteLine("Generating documentation for materialized view \"{0}\".", materializedView.Name);
                MaterializedViewRunner.Run(materializedView);
            }

            foreach (PgView view in schema.Views)
            {
                Console.WriteLine("Generating documentation for view \"{0}\".", view.Name);
                ViewRunner.Run(view);
            }
            foreach (PgType type in schema.Types)
            {
                Console.WriteLine("Generating documentation for type \"{0}\".", type.Name);
                TypeRunner.Run(type);
            }

            string targetPath = System.IO.Path.Combine(OutputPath, schemaName + ".html");

            FileHelper.WriteFile(content, targetPath);
        }