Example #1
0
        /* construction */
        /// <summary>
        /// Constructor
        /// </summary>
        public Error(DocItem Parent, string Text)
        {
            //this.Parent = Parent;


            string S;

            // @throws {Type} Description
            Description = Sys.ExtractBracketedString(Text, out S);
            Type        = S;
        }
Example #2
0
        /* construction */
        /// <summary>
        /// Constructor
        /// </summary>
        public FuncReturn(DocItem Parent, string Text)
        {
            //this.Parent = Parent;
            //this.Text = Text;

            if (!string.IsNullOrWhiteSpace(Text))
            {
                //@return {String} The description of the return
                string S;
                Description = Sys.ExtractBracketedString(Text, out S);
                Type        = S;
            }
        }
Example #3
0
        /* construction */
        /// <summary>
        /// Constructor
        /// </summary>
        public Event(DocItem Parent, string Text)
        {
            // @fires {Type|Name} Description
            //this.Parent = Parent;
            //this.Text = Text;

            string S;

            Description = Sys.ExtractBracketedString(Text, out S);

            string[] Parts = S.Split('|');
            if (Parts.Length > 0)
            {
                Type = Parts[0];
            }

            if (Parts.Length > 1)
            {
                Name = Parts[1];
            }
        }
Example #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        public FuncParam(DocItem Parent, string Text)
        {
            //this.Parent = Parent;

            if (!string.IsNullOrWhiteSpace(Text))
            {
                //@param {String|Element} Selector - A selector or an element
                string S;


                var S2 = Sys.ExtractBracketedString(Text, out S);

                Type = S;
                if (!string.IsNullOrWhiteSpace(Type))
                {
                    if (Type.StartsWith("..."))
                    {
                        IsRepeatable = true;
                        Type         = Type.Remove(0, 3);
                    }
                }


                if (!string.IsNullOrWhiteSpace(S2))
                {
                    S2 = S2.Trim();
                    int Index = S2.IndexOf(' ');
                    if (Index == -1)
                    {
                        Name = S2;
                    }
                    else
                    {
                        Name        = S2.Substring(0, Index);
                        Description = S2.Substring(Index);
                        Description = Description.TrimStart(new char[] { ' ', '-' });
                    }

                    if (!string.IsNullOrWhiteSpace(Name))
                    {
                        Name = Name.Trim();
                        if (Name.StartsWith("["))
                        {
                            IsOptional = true;

                            Name = Name.Remove(0, 1).TrimStart();


                            if (Name.EndsWith("]"))
                            {
                                Name = Name.Remove(Name.Length - 1, 1);
                            }

                            string[] Parts = Name.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                            if (Parts.Length == 2)
                            {
                                Name    = Parts[0];
                                Default = Parts[1];
                            }
                        }

                        if (Name.StartsWith("..."))
                        {
                            IsRepeatable = true;
                            Name         = Name.Remove(0, 3).TrimStart();
                        }
                    }
                }
            }
        }
Example #5
0
        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();
        }