void Parse() { string BlockText; string sName, S, S2; bool IsNameTypeTag; int Index; // parse name tags (they are all multi-line) foreach (string NameTag in Tags.NameTags) { BlockText = GetMultiLineTagValue(NameTag); if (!string.IsNullOrWhiteSpace(BlockText)) { sName = string.Empty; if (NameTag == Tags.Constructor) { sName = BlockText.Trim(); if (!string.IsNullOrWhiteSpace(sName)) { // member of + description Index = sName.IndexOfAny(new char[] { '\r', '\n', ' ' }); if (Index == -1) { MemberOf = sName; } else { MemberOf = sName.Substring(0, Index); S = sName.Remove(0, MemberOf.Length).Trim(); if (!string.IsNullOrWhiteSpace(S)) { Description = S.TrimStart(new char[] { ' ', '-' }); } } } break; } IsNameTypeTag = Tags.IsNameTypeTag(NameTag); // type if (IsNameTypeTag) { // @tag {Type} [MemberOf]Name [Description] S = string.Empty; S2 = Sys.ExtractBracketedString(BlockText, out S); IsNameTypeTag = !string.IsNullOrWhiteSpace(S); if (IsNameTypeTag) { if (!string.IsNullOrWhiteSpace(S)) { Type = S; } if (!string.IsNullOrWhiteSpace(S2)) { sName = S2.Trim(); } } } if (!IsNameTypeTag) { // @tag [MemberOf]Name [Description] sName = BlockText.Trim(); } // name + description Index = sName.IndexOfAny(new char[] { '\r', '\n', ' ' }); if (Index == -1) { Name = sName; } else { Name = sName.Substring(0, Index); S = sName.Remove(0, Name.Length).Trim(); //S = sName.Substring(Index); if (!string.IsNullOrWhiteSpace(S)) { Description = S.TrimStart(new char[] { ' ', '-' }); } } break; } } // description if (string.IsNullOrWhiteSpace(Description)) { Description = GetMultiLineTagValue(Tags.Description); } if (!string.IsNullOrWhiteSpace(Description)) { string[] Parts = Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder SB = new StringBuilder(); foreach (string s in Parts) { SB.AppendLine(s.TrimStart(new char[] { ' ', '*' })); } Description = SB.ToString(); } // name if (string.IsNullOrWhiteSpace(Name)) { Name = GetSingleLineTagValue(Tags.Name); } // name + memberof if (!string.IsNullOrWhiteSpace(Name)) { Index = Name.LastIndexOf('.'); if (Index != -1) { S = Name; Name = S.Substring(Index + 1); MemberOf = S.Substring(0, Index); } } // memberof if (string.IsNullOrWhiteSpace(MemberOf)) { MemberOf = GetSingleLineTagValue(Tags.MemberOf); } // type if (string.IsNullOrWhiteSpace(Type)) { Type = GetSingleLineTagValue(Tags.Type); } // ensure memberof if (string.IsNullOrWhiteSpace(MemberOf)) { if (ItemType == DocItemType.Namespace || ItemType == DocItemType.Callback || ItemType == DocItemType.Interface) { MemberOf = "global"; } else { MemberOf = Parser.Global.ContextName; } } // default Default = GetSingleLineTagValue(Tags.Default); if (ItemType == DocItemType.Class || ItemType == DocItemType.Enum) { // extends foreach (string NameTag in Tags.ExtendsTags) { if (string.IsNullOrWhiteSpace(Extends)) { Extends = GetSingleLineTagValue(NameTag); } } // events Events = GetEvents(); // implements Implements = GetImplements(); } // category if (ItemType == DocItemType.Class || this.ItemType == DocItemType.Function) { Category = GetSingleLineTagValue(Tags.Category); } // access S = GetSingleLineTagValue(Tags.Access); if (!string.IsNullOrWhiteSpace(S)) { if (S.IsSameText("private")) { Access = Access.Private; } else if (S.IsSameText("protected")) { Access = Access.Protected; } else if (S.IsSameText("public")) { Access = Access.Public; } } // flags IsReadOnly = DocLet.Find(Tags.ReadOnly) != null; IsStatic = DocLet.Find(Tags.Static) != null; IsDeprecated = DocLet.Find(Tags.Deprecated) != null; IsBitField = DocLet.Find(Tags.BitField) != null; IsFunction = DocLet.Find(Tags.Function) != null; // when is namespace or enum and has a callable function with the same name IsEventArgs = DocLet.Find(Tags.EventArgs) != null; // is function IsFunction = (ItemType == DocItemType.Function || ItemType == DocItemType.Constructor || ItemType == DocItemType.Callback) || ((ItemType == DocItemType.Namespace || ItemType == DocItemType.Enum) && (DocLet.Find(Tags.Function) != null)); // Params + Return if (IsFunction) { Params = GetParams(); if (ItemType != DocItemType.Constructor) { Return = GetReturn(); } } // Throws if (IsFunction || ItemType == DocItemType.Property) { Throws = GetThrows(); } ParseExamples(); ParseTutorials(); ParseSee(); }
string GetMultiLineTagValue(string TagName) { Block B = DocLet.Find(TagName); return(GetMultiLineBlockValue(B)); }
bool SingleLineTagExists(string TagName) { Block B = DocLet.Find(TagName); return(B != null); }
void ParseDocLet(DocLet DocLet) { DocItem Item = null; if (DocLet.Find(Tags.Namespace) != null) { Item = new DocItem(this, DocLet, DocItemType.Namespace); } else if (DocLet.Find(Tags.Class) != null) { Item = new DocItem(this, DocLet, DocItemType.Class); } else if (DocLet.Find(Tags.Interface) != null) { Item = new DocItem(this, DocLet, DocItemType.Interface); } else if (DocLet.Find(Tags.Enum) != null) { Item = new DocItem(this, DocLet, DocItemType.Enum); } else if (DocLet.Find(Tags.Constructor) != null) { Item = new DocItem(this, DocLet, DocItemType.Constructor); } else if (DocLet.Find(Tags.Field) != null) { Item = new DocItem(this, DocLet, DocItemType.Field); } else if (DocLet.Find(Tags.Constant) != null) { Item = new DocItem(this, DocLet, DocItemType.Constant); } else if (DocLet.Find(Tags.Property) != null) { Item = new DocItem(this, DocLet, DocItemType.Property); } else if (DocLet.Find(Tags.Function) != null) { if (DocLet.Find(Tags.Namespace) == null && DocLet.Find(Tags.Enum) == null) { Item = new DocItem(this, DocLet, DocItemType.Function); } } else if (DocLet.Find(Tags.Callback) != null) { Item = new DocItem(this, DocLet, DocItemType.Callback); } if (Item != null) { string Name = Item.Name; Global.AddToFlatList(Item); } }