public TagGroupDocumentation(ResourceKeyStack messagePath, ITagGroup tagGroup, IList<Func<ITag, TagDocumentation, bool>> specials)
        {
            _messagePath = messagePath.BranchFor(tagGroup);
            _name = tagGroup.Name;
            _specials = specials;
            _tags = new List<TagDocumentation>();
            var tagGroupType=tagGroup.GetType();
            _description=DescriptionAttribute.Harvest(tagGroupType)?? _messagePath.Description;

            _title = TitleAttribute.HarvestTagLibrary(tagGroupType);
            foreach (ITag _tag in tagGroup)
            {
                _tags.Add(new TagDocumentation(_messagePath, _tag, _specials));
            }
            if (ExampleAttribute.Harvest(tagGroupType))
            {
                _examples.AddRange(ExampleAttribute.HarvestTags(tagGroupType));
            }
            if (HasExample.Has(tagGroupType))
            {
                _examples.Add(new ExampleAttribute(_messagePath.Example));
            }
            if (NoteAttribute.Harvest(tagGroupType))
            {
                _notes.AddRange(NoteAttribute.HarvestTags(tagGroupType));
            }
            if (HasNote.Has(tagGroupType))
            {
                _notes.Add(new NoteAttribute(_messagePath.Note));
            }
        }
 public ExpressionDocumentation(ResourceKeyStack messagePath, IExpressionParser expr, Type type)
 {
     GatherTokens(expr);
     _name = type.Name;
     _messagePath = messagePath.BranchFor(expr);
     _category = CategoryHelper.GetCategory(type);
     _description = _messagePath.Description;
 }
Exemple #3
0
 public ExpressionDocumentation(ResourceKeyStack messagePath, IExpressionParser expr, Type type)
 {
     GatherTokens(expr);
     _name        = type.Name;
     _messagePath = messagePath.BranchFor(expr);
     _category    = CategoryHelper.GetCategory(type);
     _description = _messagePath.Description;
 }
 public PropertyDocumentation(ResourceKeyStack messagePath, PropertyAttribute property)
 {
     _messagePath = messagePath.BranchFor(new AttributeInfo(property.Name, property.DeclaringType));
     _required    = property.Required;
     _default     = property.DefaultValue;
     Description  = property.Description != null ? new DescriptionAttribute(property.Description) : _messagePath.Description;
     _enumValues  = property.DeclaringType.IsEnum ? GetEnumValues(property.DeclaringType) : null;
 }
 public PropertyDocumentation(ResourceKeyStack messagePath, PropertyAttribute property)
 {
     _propertyName = property.Name;
     _messagePath = messagePath.BranchFor(new AttributeInfo(property.Name, property.DeclaringType));
     _required = property.Required;
     _default = property.DefaultValue;
     _description = property.Description != null ? new DescriptionAttribute(property.Description) : _messagePath.Description;
     _enumValues = property.DeclaringType.IsEnum ? GetEnumValues(property.DeclaringType) : null;
 }
 public PropertyDocumentation(ResourceKeyStack messagePath, PropertyInfo property)
 {
     _property = property;
     _messagePath = messagePath.BranchFor(property);
     IsRequired(property);
     DetermineDefault(property);
     _description = DescriptionAttribute.Harvest(property)??_messagePath.Description;
     _enumValues = GetEnumValues(_property.GetCustomAttribute<EnumProperyTypeAttribute>(false)?.EnumType);
 }
 public FunctionDocumentation(string libName, ResourceKeyStack messagePath, IFunctionDefinition func)
 {
     _libName = libName;
     _name = func.Name;
     _arguments = func.Arguments;
     _returnType = func.ReturnType;
     _messagePath = messagePath.BranchFor(func);
     _description=_messagePath.Description;
     _category = CategoryHelper.GetCategory(func.GetType());
 }
Exemple #8
0
 public FunctionDocumentation(string libName, ResourceKeyStack messagePath, IFunctionDefinition func)
 {
     _libName     = libName;
     _name        = func.Name;
     _arguments   = func.Arguments;
     _returnType  = func.ReturnType;
     _messagePath = messagePath.BranchFor(func);
     _description = _messagePath.Description;
     _category    = CategoryHelper.GetCategory(func.GetType());
 }
Exemple #9
0
        public DocumentModel(TagLib subject, bool all, ResourceBundle bundle, IList<Func<ITag, TagDocumentation, bool>> specials=null)
        {
            _expressionlib = new ExpressionLib();

            _subject = subject;
            _all = all;
            _specials = specials??new List<Func<ITag, TagDocumentation, bool>>();
            _additionalResources = new Dictionary<string, string>();
            _resouceKey = new ResourceKeyStack(bundle);
            GatherExpressions();
            GatherFunctions();
            GatherGroups();
        }
 public DocumentModel(TagLib subject, bool all, ResourceBundle bundle, IList <Func <ITag, TagDocumentation, bool> > specials = null)
 {
     _expressionlib       = new ExpressionLib();
     _tagDictionary       = new Dictionary <int, TagDocumentation>();
     _subject             = subject;
     _all                 = all;
     _specials            = specials ?? new List <Func <ITag, TagDocumentation, bool> >();
     _additionalResources = new Dictionary <string, string>();
     _resouceKey          = new ResourceKeyStack(bundle);
     GatherExpressions();
     GatherFunctions();
     GatherGroups();
 }
        public PropertyDocumentation(ResourceKeyStack messagePath, PropertyInfo property)
        {
            _property    = property;
            _messagePath = messagePath.BranchFor(property);
            IsRequired(property);
            DetermineDefault(property);
            Description = DescriptionAttribute.Harvest(property) ?? _messagePath.Description;
            _enumValues = GetEnumValues(_property.GetCustomAttribute <EnumProperyTypeAttribute>(false)?.EnumType);
            DataType    = DetermineDataType(_property);
            Annotations = GetAnnotations(_property);
            var dateAttr = property.GetCustomAttribute <DatePropertyTypeAttribute>();

            if (dateAttr != null)
            {
                DateFormat = dateAttr.Format;
            }
        }
        public TagGroupDocumentation(ResourceKeyStack messagePath, ITagGroup tagGroup, IList <Func <ITag, TagDocumentation, bool> > specials, Dictionary <int, TagDocumentation> tagDictionary)
        {
            _messagePath   = messagePath.BranchFor(tagGroup);
            _name          = tagGroup.Name;
            _specials      = specials;
            _tagDictionary = tagDictionary;
            _tags          = new List <int>();
            var tagGroupType = tagGroup.GetType();

            _description = DescriptionAttribute.Harvest(tagGroupType) ?? _messagePath.Description;

            _title = TitleAttribute.HarvestTagLibrary(tagGroupType);
            foreach (ITag _tag in tagGroup)
            {
                var hash = _tag.GetType().GetHashCode();
                if (!_tagDictionary.ContainsKey(hash))
                {
                    _tagDictionary[hash] = null;
                    var tagDoc = new TagDocumentation(_messagePath, _tag, _specials, _tagDictionary);
                    _tagDictionary[hash] = tagDoc;
                }
                _tags.Add(hash);
            }
            if (ExampleAttribute.Harvest(tagGroupType))
            {
                _examples.AddRange(ExampleAttribute.HarvestTags(tagGroupType));
            }
            if (HasExample.Has(tagGroupType))
            {
                _examples.Add(new ExampleAttribute(_messagePath.Example));
            }
            if (NoteAttribute.Harvest(tagGroupType))
            {
                _notes.AddRange(NoteAttribute.HarvestTags(tagGroupType));
            }
            if (HasNote.Has(tagGroupType))
            {
                _notes.Add(new NoteAttribute(_messagePath.Note));
            }
        }
Exemple #13
0
        public TagDocumentation(ResourceKeyStack messagePath, ITag tag,  IList<Func<ITag, TagDocumentation,bool>> specials)
        {
            _messagePath = messagePath.BranchFor(tag);
            _name = tag.TagName;

            var tagType = tag.GetType();

            _category = CategoryHelper.GetCategory(tagType);

            _list = new List<PropertyDocumentation>();
            _nested = new List<TagDocumentation>();
            _methods = new List<FunctionDocumentation>();
            foreach (var property in tagType.GetCustomAttributes<PropertyAttribute>())
            {
                _list.Add(new PropertyDocumentation(_messagePath, property));
            }

            foreach (var property in tagType.GetProperties(
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.SetProperty |
                BindingFlags.FlattenHierarchy))
            {
                if (Equals(property.PropertyType, typeof(ITagAttribute)) &&
                    !IsInternal(property))
                {
                    _list.Add(new PropertyDocumentation(_messagePath, property));
                }
            }
            var extendingTag = tag as ITagExtendTagLib;
            if (extendingTag != null)
            {
                foreach (var nested in extendingTag.TagLibExtension)
                {
                    _nested.Add(new TagDocumentation(_messagePath, nested, specials));
                }
            }
            var instanceDocumentation = tag as IInstanceTagDocumentation;
            if (instanceDocumentation!=null)
            {
                _description = instanceDocumentation.Description;
                _examples.AddRange(instanceDocumentation.Examples?? new ExampleAttribute[] {});
                _notes.AddRange(instanceDocumentation.Notes ?? new NoteAttribute[] {});
            }
            else
            {
                _description = DescriptionAttribute.Harvest(tagType) ?? _messagePath.Description;

                if (ExampleAttribute.Harvest(tagType))
                {
                    _examples.AddRange(ExampleAttribute.HarvestTags(tagType));
                }
                if (HasExample.Has(tagType))
                {
                    _examples.Add(new ExampleAttribute(_messagePath.Example));
                }
                if (NoteAttribute.Harvest(tagType))
                {
                    _notes.AddRange(NoteAttribute.HarvestTags(tagType));
                }
                if (HasNote.Has(tagType))
                {
                    _notes.Add(new NoteAttribute(_messagePath.Note));
                }
            }
        }
Exemple #14
0
        public TagDocumentation(ResourceKeyStack messagePath, ITag tag, IList <Func <ITag, TagDocumentation, bool> > specials, Dictionary <int, TagDocumentation> tagDictionary)
        {
            _tagDictionary = tagDictionary;
            _messagePath   = messagePath.BranchFor(tag);
            _name          = tag.TagName;

            var tagType = tag.GetType();

            _category = CategoryHelper.GetCategory(tagType);

            _list       = new List <PropertyDocumentation>();
            _nested     = new List <int>();
            _methods    = new List <FunctionDocumentation>();
            TagBodyMode = tag.TagBodyMode;

            foreach (var property in tagType.GetCustomAttributes <PropertyAttribute>())
            {
                _list.Add(new PropertyDocumentation(_messagePath, property));
            }

            foreach (var property in tagType.GetProperties(
                         BindingFlags.Instance |
                         BindingFlags.Public |
                         BindingFlags.SetProperty |
                         BindingFlags.FlattenHierarchy))
            {
                if (Equals(property.PropertyType, typeof(ITagAttribute)) &&
                    !IsInternal(property))
                {
                    _list.Add(new PropertyDocumentation(_messagePath, property));
                }
            }
            var extendingTag = tag as ITagExtendTagLib;

            if (extendingTag != null)
            {
                foreach (var nested in extendingTag.TagLibExtension)
                {
                    var hash = nested.GetType().GetHashCode();
                    if (!_tagDictionary.ContainsKey(hash))
                    {
                        _tagDictionary[hash] = null;
                        var tagDoc = new TagDocumentation(_messagePath, nested, specials, _tagDictionary);
                        _tagDictionary[hash] = tagDoc;
                    }
                    _nested.Add(hash);
                }
            }
            var instanceDocumentation = tag as IInstanceTagDocumentation;

            if (instanceDocumentation != null)
            {
                _description = instanceDocumentation.Description;
                _examples.AddRange(instanceDocumentation.Examples ?? new ExampleAttribute[] {});
                _notes.AddRange(instanceDocumentation.Notes ?? new NoteAttribute[] {});
            }
            else
            {
                _description = DescriptionAttribute.Harvest(tagType) ?? _messagePath.Description;

                if (ExampleAttribute.Harvest(tagType))
                {
                    _examples.AddRange(ExampleAttribute.HarvestTags(tagType));
                }
                if (HasExample.Has(tagType))
                {
                    _examples.Add(new ExampleAttribute(_messagePath.Example));
                }
                if (NoteAttribute.Harvest(tagType))
                {
                    _notes.AddRange(NoteAttribute.HarvestTags(tagType));
                }
                if (HasNote.Has(tagType))
                {
                    _notes.Add(new NoteAttribute(_messagePath.Note));
                }
            }
        }
 public ExpressionDocumentation(ResourceKeyStack messagePath, IExpressionParser expr)
     : this(messagePath, expr, expr.ParsedTypes.Single())
 {
 }
Exemple #16
0
 public ExpressionDocumentation(ResourceKeyStack messagePath, IExpressionParser expr)
     : this(messagePath, expr, expr.ParsedTypes.Single())
 {
 }