/// <summary>
        /// Creates a readme to list which model groups are being generated.
        /// </summary>
        public static void UpdateMainReadme(Assembly executingAssembly, List <List <Manifest> > manifests, string savePath, string[] testGroupName)
        {
            // Use the manifest list to build a table of contents.
            var newTableOfContents = new StringBuilder();
            var testGroupNameIndex = 0;

            foreach (var manifest in manifests)
            {
                newTableOfContents.AppendLine("");
                newTableOfContents.AppendLine($"## {testGroupName[testGroupNameIndex]} Tests");
                foreach (var modelgroup in manifest)
                {
                    string ReadableFolderName = ReadmeStringHelper.GenerateNameWithSpaces(modelgroup.Folder, true);
                    newTableOfContents.AppendLine($"- [{ReadableFolderName}](Output/{testGroupName[testGroupNameIndex]}/{modelgroup.Folder}/README.md)");
                }
                testGroupNameIndex++;
            }

            // Reads the readme file template.
            string template;

            using (Stream stream = executingAssembly.GetManifestResourceStream("AssetGenerator.ReadmeTemplates.Page_Main.md"))
                using (var streamReader = new StreamReader(stream))
                {
                    template = streamReader.ReadToEnd();
                }

            // Find and replace the table of contents section with the newly built one.
            template = template.Replace($"~~TableOfContents~~", newTableOfContents.ToString());

            // Write out the readme file.
            string readmeFilePath = Path.Combine(savePath, "README.md");

            File.WriteAllText(readmeFilePath, template);
        }
Beispiel #2
0
        static public void UpdateMainReadme(Assembly executingAssembly, string outputFolder, List <Manifest> manifests)
        {
            // Use the main manifest to build an updated table of contents
            StringBuilder newTableOfContents = new StringBuilder();

            foreach (var modelgroup in manifests)
            {
                newTableOfContents.AppendLine(string.Format("- [{0}](Output/{1}/README.md)",
                                                            ReadmeStringHelper.GenerateNameWithSpaces(modelgroup.folder, true), modelgroup.folder));
            }

            // Reads the readme file template
            string template;
            string templatePath = "AssetGenerator.ReadmeTemplates.README.md";

            using (Stream stream = executingAssembly.GetManifestResourceStream(templatePath))
                using (var streamReader = new StreamReader(stream))
                {
                    template = streamReader.ReadToEnd();
                }

            // Find and replace the table of contents section with the newly built one
            template = template.Replace("~~TableOfContents~~", newTableOfContents.ToString());

            // Write out the readme file
            string readmeFilePath = Path.Combine(Directory.GetParent(outputFolder).ToString(), "README.md");

            File.WriteAllText(readmeFilePath, template);
        }
 public Property(PropertyName enumName, object displayValue)
 {
     Name             = enumName;
     ReadmeColumnName = ReadmeStringHelper.GenerateNameWithSpaces(enumName.ToString());
     ReadmeValue      = ReadmeStringHelper.ConvertValueToString(displayValue);
 }
Beispiel #4
0
        public void SetupHeader(ModelGroup test)
        {
            // Setup the log file header
            if (test.requiredProperty != null)
            {
                // List attributes that are set in every generated model (prerequisites)
                readmePrereqs.Add(new List <string>()); // First line of table must be blank
                readmePrereqs.Add(new List <string>
                {
                    "Property", // First cells are a static label
                    "**Values**"
                });
                readmePrereqs.Add(new List <string>
                {
                    ":---:", // Hyphens for row after header
                    ":---:",
                });
                for (int i = 0; i < test.requiredProperty.Count; i++)
                {
                    string attributeName;
                    attributeName = test.requiredProperty[i].name.ToString();
                    attributeName = ReadmeStringHelper.GenerateNameWithSpaces(attributeName);
                    readmePrereqs.Add(new List <string>
                    {
                        attributeName,
                        ReadmeStringHelper.ConvertTestValueToString(test.requiredProperty[i])
                    });
                }
            }

            // Now start the table for generated models
            readme.Add(new List <string>()); // First line of table must be blank
            readme.Add(new List <string>
            {
                " ",
                "Reference Image"     // First cell is empty, the second is a static header name
            });
            readme.Add(new List <string>
            {
                ":---:",     // Hyphens for rows after header
                ":---:"
            });
            for (int i = 0; i < test.properties.Count; i++)
            {
                string attributeName;
                if (test.properties[i].prerequisite != Propertyname.Undefined && test.properties[i].propertyGroup == 0)
                {
                    attributeName = test.properties[i].prerequisite.ToString() + test.properties[i].name.ToString();
                }
                else
                {
                    attributeName = test.properties[i].name.ToString();
                }
                attributeName = ReadmeStringHelper.GenerateNameWithSpaces(attributeName);
                if (attributeName != lastName) // Skip duplicate names caused by non-binary attributes
                {
                    lastName = attributeName;
                    readme[1].Add(attributeName);
                    readme[2].Add(":---:");
                }
            }
        }