Esempio n. 1
0
        private void WriteSourceSection(UdnWriter Writer)
        {
            if (Entity.BodyFile != null)
            {
                DoxygenSourceFile SourceFile = Entity.Module.FindSourceFile(Entity.BodyFile);
                if (SourceFile != null)
                {
                    int BodyStart = Math.Min(Math.Max(Entity.BodyStart - 1, 0), SourceFile.Lines.Count - 1);
                    int BodyEnd   = Math.Min(Math.Max(Entity.BodyEnd, BodyStart), SourceFile.Lines.Count);
                    if (BodyEnd > BodyStart)
                    {
                        Writer.EnterSection("source", "Source");
                        Writer.EnterRegion("simplecode");

                        List <string> Lines     = new List <string>();
                        int           MinPrefix = int.MaxValue;

                        for (int LineIdx = BodyStart; LineIdx < BodyEnd; LineIdx++)
                        {
                            XmlNode Node         = SourceFile.Lines[LineIdx];
                            string  MarkdownLine = (Node == null)? "" : Markdown.ParseXmlCodeLine(Node, ResolveDoxygenLink);

                            int Prefix = 0;
                            while (Prefix < MarkdownLine.Length && MarkdownLine[Prefix] == ' ')
                            {
                                Prefix++;
                            }

                            if (Prefix < MarkdownLine.Length && Prefix < MinPrefix)
                            {
                                MinPrefix = Prefix;
                            }

                            Lines.Add(MarkdownLine);
                        }

                        for (int Idx = 0; Idx < Lines.Count; Idx++)
                        {
                            int TextIdx = Math.Min(MinPrefix, Lines[Idx].Length);
                            if (TextIdx == Lines[Idx].Length)
                            {
                                Writer.Write("&nbsp;");
                            }
                            while (TextIdx < Lines[Idx].Length && Lines[Idx][TextIdx] == ' ')
                            {
                                Writer.Write("&nbsp;");
                                TextIdx++;
                            }
                            Writer.WriteLine(Lines[Idx].Substring(TextIdx) + "  ");
                        }

                        Writer.LeaveRegion();
                        Writer.LeaveSection();
                    }
                }
            }
        }
Esempio n. 2
0
        public override void WritePage(UdnManifest Manifest, string OutputPath)
        {
            using (UdnWriter Writer = new UdnWriter(OutputPath))
            {
                Writer.WritePageHeader(Name, PageCrumbs, BriefDescription);

                Writer.EnterTag("[OBJECT:Variable]");

                // Write the brief description
                Writer.EnterTag("[PARAM:briefdesc]");
                if (!Utility.IsNullOrWhitespace(BriefDescription) && BriefDescription != FullDescription)
                {
                    Writer.WriteLine(BriefDescription);
                }
                Writer.LeaveTag("[/PARAM]");

                // Write the warnings
                Writer.EnterTag("[PARAM:warnings]");
                if (Warnings.Count > 0)
                {
                    Writer.EnterTag("[REGION:warning]");
                    Writer.WriteLine("**Warnings**");
                    foreach (string Warning in Warnings)
                    {
                        Writer.WriteLine("* " + Warning);
                    }
                    Writer.LeaveTag("[/REGION]");
                }
                Writer.LeaveTag("[/PARAM]");

                // Write the syntax
                Writer.EnterTag("[PARAM:syntax]");
                Writer.EnterSection("syntax", "Syntax");
                Writer.EnterTag("[REGION:simplecode_api]");
                if (MetadataDirective != null) Writer.WriteLine(MetadataDirective.ToMarkdown() + "  ");
                if (IsStatic) Writer.Write("static ");
                if (IsMutable) Writer.Write("mutable ");
                Writer.Write(Type + " " + Name);
                if (Bitfield != "") Writer.Write(": " + Bitfield);
                Writer.WriteLine("  ");
                Writer.LeaveTag("[/REGION]");
                Writer.LeaveSection();
                Writer.LeaveTag("[/PARAM]");

                // Write the metadata
                Writer.EnterTag("[PARAM:meta]");
                if (MetadataDirective != null)
                {
                    MetadataDirective.WriteListSection(Writer, "metadata", "Metadata", MetadataLookup.PropertyTags);
                }
                Writer.LeaveTag("[/PARAM]");

                // Write the description
                Writer.EnterTag("[PARAM:description]");
                if (!Utility.IsNullOrWhitespace(FullDescription))
                {
                    Writer.EnterSection("description", "Remarks");
                    Writer.WriteLine(FullDescription);
                    Writer.LeaveSection();
                }
                Writer.LeaveTag("[/PARAM]");

                // Leave the object tag
                Writer.LeaveTag("[/OBJECT]");
            }
        }
Esempio n. 3
0
        private void WriteSourceSection(UdnWriter Writer)
        {
            if(Entity.BodyFile != null)
            {
                DoxygenSourceFile SourceFile = Entity.Module.FindSourceFile(Entity.BodyFile);
                if(SourceFile != null)
                {
                    int BodyStart = Math.Min(Math.Max(Entity.BodyStart - 1, 0), SourceFile.Lines.Count - 1);
                    int BodyEnd = Math.Min(Math.Max(Entity.BodyEnd, BodyStart), SourceFile.Lines.Count);
                    if(BodyEnd > BodyStart)
                    {
                        Writer.EnterSection("source", "Source");
                        Writer.EnterRegion("simplecode");

                        List<string> Lines = new List<string>();
                        int MinPrefix = int.MaxValue;

                        for (int LineIdx = BodyStart; LineIdx < BodyEnd; LineIdx++)
                        {
                            XmlNode Node = SourceFile.Lines[LineIdx];
                            string MarkdownLine = (Node == null)? "" : Markdown.ParseXmlCodeLine(Node, ResolveDoxygenLink);

                            int Prefix = 0;
                            while (Prefix < MarkdownLine.Length && MarkdownLine[Prefix] == ' ') Prefix++;

                            if(Prefix < MarkdownLine.Length && Prefix < MinPrefix)
                            {
                                MinPrefix = Prefix;
                            }

                            Lines.Add(MarkdownLine);
                        }

                        for (int Idx = 0; Idx < Lines.Count; Idx++)
                        {
                            int TextIdx = Math.Min(MinPrefix, Lines[Idx].Length);
                            if(TextIdx == Lines[Idx].Length)
                            {
                                Writer.Write("&nbsp;");
                            }
                            while(TextIdx < Lines[Idx].Length && Lines[Idx][TextIdx] == ' ')
                            {
                                Writer.Write("&nbsp;");
                                TextIdx++;
                            }
                            Writer.WriteLine(Lines[Idx].Substring(TextIdx) + "  ");
                        }

                        Writer.LeaveRegion();
                        Writer.LeaveSection();
                    }
                }
            }
        }