IfcDoc.DocumentationISO.GenerateTemplate C# (CSharp) Method

GenerateTemplate() private static method

Generates documentation for template and all sub-templates recursively.
private static GenerateTemplate ( DocProject docProject, DocTemplateDefinition docTemplate, DocObject>.Dictionary mapEntity, string>.Dictionary mapSchema, bool>.Dictionary included, int indexpath, List listFigures, List listTables, DocPublication docPublication, string path ) : void
docProject DocProject
docTemplate DocTemplateDefinition
mapEntity DocObject>.Dictionary
mapSchema string>.Dictionary
included bool>.Dictionary
indexpath int
listFigures List
listTables List
docPublication DocPublication
path string
return void
        private static void GenerateTemplate(
            DocProject docProject, 
            DocTemplateDefinition docTemplate, 
            Dictionary<string, DocObject> mapEntity, 
            Dictionary<string, string> mapSchema, 
            Dictionary<DocObject, bool> included, 
            int[] indexpath, 
            List<ContentRef> listFigures, 
            List<ContentRef> listTables,
            DocPublication docPublication,
            string path)
        {
            string pathTemplate = path + @"\schema\templates\" + MakeLinkName(docTemplate) + ".htm";
            using (FormatHTM htmTemplate = new FormatHTM(pathTemplate, mapEntity, mapSchema, included))
            {
                htmTemplate.WriteHeader(docTemplate.Name, 2, docPublication.Header);

                string indexer = "";
                foreach (int part in indexpath)
                {
                    if (indexer.Length != 0)
                    {
                        indexer += ".";
                    }
                    indexer += part.ToString();
                }

                htmTemplate.WriteLine(
                     "\r\n" +
                     "<script type=\"text/javascript\">\r\n" +
                     "<!--\r\n" +
                     "    parent.index.location.replace(\"../toc-4.htm#" + indexer + "\");\r\n" +
                     "//-->\r\n" +
                     "</script>\r\n");

                string tag = "h" + indexpath.Length.ToString(); // e.g. <h3>
                string id = MakeLinkName(docTemplate);
                htmTemplate.WriteLine("<" + tag + " class=\"std\">" + indexer + " " + docTemplate.Name + "</" + tag + ">");

                string doc = FormatTemplate(docProject, docTemplate, listFigures, listTables, mapEntity, mapSchema, included, path);
                htmTemplate.WriteDocumentationMarkup(doc, docTemplate, docPublication);

                // write formatted mvdXML
                //htmTemplate.WriteLine("<details open=\"open\">");
                //htmTemplate.WriteLine("<summary>mvdXML</summary>");

                ConceptTemplate mvdTemplate = new ConceptTemplate();
                Program.ExportMvdTemplate(mvdTemplate, docTemplate, included, false);
                XmlSerializer ser = new XmlSerializer(typeof(ConceptTemplate));
                StringBuilder mvdOutput = new StringBuilder();
                using (System.IO.Stream streamMVD = new System.IO.MemoryStream())
                {
                    ser.Serialize(streamMVD, mvdTemplate, null);
                    streamMVD.Position = 0;
                    using(System.IO.StreamReader reader = new System.IO.StreamReader(streamMVD))
                    {
                        while(!reader.EndOfStream)
                        {
                            string mvdLine = reader.ReadLine();

                            int pos = 0;
                            while(pos < mvdLine.Length && mvdLine[pos] == ' ')
                            {
                                mvdOutput.Append("\t");
                                pos++;
                            }

                            // replace any leading spaces with tabs for proper formatting
                            string mvdMark = mvdLine.Substring(pos, mvdLine.Length - pos);
                            mvdOutput.AppendLine(mvdMark);
                        }
                    }
                }

                htmTemplate.WriteSummaryHeader("mvdXML Specification", false);
                htmTemplate.WriteLine("<div class=\"xsd\"><code class=\"xsd\">");
                htmTemplate.WriteExpression(mvdOutput.ToString()); //... need to use tabs...
                htmTemplate.WriteLine("</code></div>");
                htmTemplate.WriteSummaryFooter();

                //htmTemplate.WriteLine("</details>");

                if (docProject.Examples != null)
                {
                    List<DocExample> listExample = new List<DocExample>();
                    foreach (DocExample docExample in docProject.Examples)
                    {
                        BuildExampleList(listExample, docExample, docTemplate, included);
                    }
                    if (listExample.Count > 0)
                    {
                        htmTemplate.WriteLine("<p class=\"spec-head\">Examples:</p>");
                        htmTemplate.WriteLine("<ul>");
                        foreach (DocExample docExample in listExample)
                        {
                            if (docExample.Name != null)
                            {
                                htmTemplate.Write("<li><a href=\"../../annex/annex-e/");
                                htmTemplate.Write(MakeLinkName(docExample));
                                htmTemplate.Write(".htm\">");
                                htmTemplate.Write(docExample.Name);
                                htmTemplate.Write("</a></li>");
                                htmTemplate.WriteLine("");
                            }
                        }
                        htmTemplate.WriteLine("</ul>");
                    }
                }

                // write url for incoming page link
                htmTemplate.WriteLinkTo(docTemplate);

                htmTemplate.WriteFooter(docPublication.Footer);
            }

            // recurse
            int iTemplate = 0;
            foreach (DocTemplateDefinition docSubTemplate in docTemplate.Templates)
            {
                if (included == null || included.ContainsKey(docSubTemplate))
                {
                    iTemplate++;
                    int[] subindexpath = new int[indexpath.Length + 1];
                    indexpath.CopyTo(subindexpath, 0);
                    subindexpath[subindexpath.Length - 1] = iTemplate;
                    GenerateTemplate(docProject, docSubTemplate, mapEntity, mapSchema, included, subindexpath, listFigures, listTables, docPublication, path);
                }
            }
        }