Inheritance: BaseDocumentationElement, IReferencable
Beispiel #1
0
 public DeclaredType(TypeIdentifier name, Namespace ns)
     : base(name)
 {
     Namespace = ns;
     Summary = new List<IComment>();
     Interfaces = new List<IReferencable>();
 }
        private void AddMatch(string outputPath, string templatePath, ViewData data, Namespace ns)
        {
            var clone = data.Clone();

            clone.Namespace = ns;

            AddMatch(outputPath, templatePath, clone);
        }
        private void AddMatch(string outputPath, string templatePath, ViewData data, Namespace ns, DeclaredType type)
        {
            var clone = data.Clone();

            clone.Type = type;

            AddMatch(outputPath, templatePath, clone, ns);
        }
Beispiel #4
0
        public void MatchesSingleFilename()
        {
            var resolver = new PatternTemplateResolver();
            var namespaces = new Namespace[0];
            var results = resolver.Resolve("template.htm.spark", namespaces);

            results[0].OutputPath.ShouldEqual("template.htm");
            results[0].TemplatePath.ShouldEqual("template.htm.spark");
        }
Beispiel #5
0
        public void ShouldResolveDirectoriesOfSameName()
        {
            var resolver = new PatternTemplateResolver();
            var namespaces = new Namespace[0];
            var results = resolver.Resolve("dir\\dir\\template.htm.spark", namespaces);

            results[0].OutputPath.ShouldEqual("dir\\dir\\template.htm");
            results[0].TemplatePath.ShouldEqual("dir\\dir\\template.htm.spark");
        }
        public void CanWriteToOutputDirectory()
        {
            var transformer = MockRepository.GenerateMock<IPageWriter>();
            var bulkTransformer = new BulkPageWriter(transformer);
            var namespaces = new Namespace[0];

            bulkTransformer.CreatePagesFromDirectory(directory_sub, "output", namespaces);

            transformer.AssertWasCalled(x => x.CreatePages(directory_sub_oneSpark, "output", namespaces));
        }
Beispiel #7
0
        public void MatchesTemplateInDirectory()
        {
            var resolver = new PatternTemplateResolver();
            var namespaces = new Namespace[0];
            var results = resolver.Resolve("directory\\template.htm.spark", namespaces);

            results.Count.ShouldEqual(1);
            results[0].OutputPath.ShouldEqual("directory\\template.htm");
            results[0].TemplatePath.ShouldEqual("directory\\template.htm.spark");
        }
        private void create_assemblies()
        {
            first_namespace = Namespace("First");
            first_type = Type<First>(first_namespace);
            second_namespace = Namespace("Second");
            second_type = Type<Second>(second_namespace);
            third_namespace = Namespace("Third");
            third_type = Type<Third>(third_namespace);

            namespaces = new[] { first_namespace, second_namespace, third_namespace };
        }
        public void GeneratesOutputFromTemplate()
        {
            var generator = MockRepository.GenerateMock<IOutputGenerator>();
            var writer = MockRepository.GenerateStub<IOutputWriter>();
            var resolver = MockRepository.GenerateStub<IPatternTemplateResolver>();
            var transformer = new PageWriter(generator, writer, resolver);
            var namespaces = new Namespace[0];

            resolver.Stub(x => x.Resolve(null, null))
                .IgnoreArguments()
                .Return(new List<TemplateMatch> { new TemplateMatch("simple.htm", "simple.spark", new ViewData()) });

            transformer.CreatePages("simple.spark", "", namespaces);

            generator.AssertWasCalled(
                x => x.Convert(Arg.Is("simple.spark"), Arg<ViewData>.Is.Anything, Arg<string>.Is.Anything));
        }
        public void TransformsTemplatesInDirectories()
        {
            var generator = MockRepository.GenerateStub<IOutputGenerator>();
            var writer = MockRepository.GenerateMock<IOutputWriter>();
            var resolver = MockRepository.GenerateStub<IPatternTemplateResolver>();
            var transformer = new PageWriter(generator, writer, resolver);
            var namespaces = new Namespace[0];

            resolver.Stub(x => x.Resolve(null, null))
                .IgnoreArguments()
                .Return(new List<TemplateMatch> { new TemplateMatch("directory\\test.htm", "", new ViewData()) });
            generator.Stub(x => x.Convert(null, null))
                .IgnoreArguments()
                .Return("content");

            transformer.CreatePages("directory\\test.spark", "output", namespaces);

            writer.AssertWasCalled(x => x.WriteFile("output\\directory\\test.htm", "content"));
        }
Beispiel #11
0
        public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type type, Namespace ns)
        {
            var declaredType = new DeclaredType(typeIdentifier, ns) { IsResolved = false, representedType = type };

            if (type.BaseType != null)
                declaredType.ParentType = Unresolved(
                    Identifier.FromType(type.BaseType),
                    type.BaseType,
                    Namespace.Unresolved(Identifier.FromNamespace(type.BaseType.Namespace)));

            IEnumerable<Type> interfaces = GetInterfaces(type);

            foreach (Type face in interfaces)
            {
                declaredType.Interfaces.Add(
                    Unresolved(
                        Identifier.FromType(face),
                        face,
                        Namespace.Unresolved(Identifier.FromNamespace(face.Namespace))));
            }

            return declaredType;
        }
Beispiel #12
0
 public DeclaredType(TypeIdentifier name, Namespace ns)
     : base(name)
 {
     Namespace  = ns;
     Interfaces = new List <IReferencable>();
 }
Beispiel #13
0
        public void Resolve(IDictionary <Identifier, IReferencable> referencables)
        {
            if (referencables.ContainsKey(identifier))
            {
                IsResolved = true;

                IReferencable referencable = referencables[identifier];
                var           type         = referencable as DeclaredType;

                if (type == null)
                {
                    throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'");
                }

                Namespace       = type.Namespace;
                representedType = type.representedType;
                ParentType      = type.ParentType;
                Interfaces      = type.Interfaces;

                if (!Namespace.IsResolved)
                {
                    Namespace.Resolve(referencables);
                }
                if (ParentType != null && !ParentType.IsResolved)
                {
                    ParentType.Resolve(referencables);
                }

                foreach (IReferencable face in Interfaces)
                {
                    if (!face.IsResolved)
                    {
                        face.Resolve(referencables);
                    }
                }

                if (!Summary.IsResolved)
                {
                    Summary.Resolve(referencables);
                }

                foreach (var method in Methods)
                {
                    if (!method.IsResolved)
                    {
                        method.Resolve(referencables);
                    }
                }

                foreach (var property in Properties)
                {
                    if (!property.IsResolved)
                    {
                        property.Resolve(referencables);
                    }
                }

                foreach (var ev in Events)
                {
                    if (!ev.IsResolved)
                    {
                        ev.Resolve(referencables);
                    }
                }

                foreach (var field in Fields)
                {
                    if (!field.IsResolved)
                    {
                        field.Resolve(referencables);
                    }
                }
            }
            else
            {
                ConvertToExternalReference();
            }
        }
Beispiel #14
0
        public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type type, Namespace ns)
        {
            var declaredType = new DeclaredType(typeIdentifier, ns)
            {
                IsResolved = false, representedType = type
            };

            if (type.BaseType != null)
            {
                declaredType.ParentType = Unresolved(
                    Identifier.FromType(type.BaseType),
                    type.BaseType,
                    Namespace.Unresolved(Identifier.FromNamespace(type.BaseType.Namespace)));
            }

            IEnumerable <Type> interfaces = GetInterfaces(type);

            foreach (Type face in interfaces)
            {
                declaredType.Interfaces.Add(
                    Unresolved(
                        Identifier.FromType(face),
                        face,
                        Namespace.Unresolved(Identifier.FromNamespace(face.Namespace))));
            }

            return(declaredType);
        }
        public void when_template_directory_set_exclude_directory_from_output()
        {
            var generator = MockRepository.GenerateStub<IOutputGenerator>();
            var writer = MockRepository.GenerateMock<IOutputWriter>();
            var resolver = MockRepository.GenerateStub<IPatternTemplateResolver>();
            var transformer = new PageWriter(generator, writer, resolver);
            var namespaces = new Namespace[0];

            resolver.Stub(x => x.Resolve(null, null))
                .IgnoreArguments()
                .Return(new List<TemplateMatch> { new TemplateMatch("someTemplatePath\\simple.htm", "someTemplatePath\\simple.spark", new ViewData()) });

            generator.Stub(x => x.Convert(null, null, null))
                .IgnoreArguments()
                .Return("content");

            transformer.SetTemplatePath("someTemplatePath");
            transformer.CreatePages("someTemplatePath\\simple.spark", "output", namespaces);

            writer.AssertWasCalled(x => x.WriteFile("output\\simple.htm", "content"));
        }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeclaredType"/> class.
 /// </summary>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="ns">
 /// The ns.
 /// </param>
 public DeclaredType(TypeIdentifier name, Namespace ns)
     : base(name)
 {
     this.Namespace = ns;
     this.Interfaces = new List<IReferencable>();
 }
Beispiel #17
0
        private void AddNamespace(List<Namespace> namespaces, DocumentedType association)
        {
            var ns = Identifier.FromNamespace(association.Type.Namespace);

            if (!namespaces.Exists(x => x.IsIdentifiedBy(ns)))
            {
                var doc = new Namespace(ns);
                matchedAssociations.Add(association.Name.CloneAsNamespace(), doc);
                namespaces.Add(doc);
            }
        }
        public void shouldnt_parse_underscore_prefixed_spark_files()
        {
            var transformer = MockRepository.GenerateMock<IPageWriter>();
            var bulkTransformer = new BulkPageWriter(transformer);
            var namespaces = new Namespace[0];

            bulkTransformer.CreatePagesFromDirectory(directory, "output", namespaces);

            transformer.AssertWasNotCalled(x => x.CreatePages(directory_underscoreSpark, "output", namespaces));
        }
        public void should_pass_template_path_to_writer()
        {
            var transformer = MockRepository.GenerateMock<IPageWriter>();
            var bulkTransformer = new BulkPageWriter(transformer);
            var namespaces = new Namespace[0];

            bulkTransformer.CreatePagesFromDirectory(directory_sub, "output", namespaces);

            transformer.AssertWasCalled(x => x.SetTemplatePath(directory_sub));
        }
Beispiel #20
0
        public void Resolve(IDictionary <Identifier, IReferencable> referencables)
        {
            if (referencables.ContainsKey(identifier))
            {
                IsResolved = true;

                IReferencable referencable = referencables[identifier];
                var           type         = referencable as DeclaredType;

                if (type == null)
                {
                    throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'");
                }

                Namespace   = type.Namespace;
                declaration = type.declaration;
                ParentType  = type.ParentType;
                Interfaces  = type.Interfaces;

                if (!Namespace.IsResolved)
                {
                    Namespace.Resolve(referencables);
                }

                if (ParentType != null && !ParentType.IsResolved)
                {
                    ParentType.Resolve(referencables);
                }

                foreach (IReferencable face in Interfaces)
                {
                    if (!face.IsResolved)
                    {
                        face.Resolve(referencables);
                    }
                }

                if (declaration != null && declaration.IsDefined(typeof(ObsoleteAttribute)))
                {
                    ObsoleteReason = declaration.GetCustomAttribute <ObsoleteAttribute>().Message;
                }

                if (!Summary.IsResolved)
                {
                    Summary.Resolve(referencables);
                }

                foreach (Method method in Methods)
                {
                    if (!method.IsResolved)
                    {
                        method.Resolve(referencables);
                    }
                }

                foreach (Property property in Properties)
                {
                    if (!property.IsResolved)
                    {
                        property.Resolve(referencables);
                    }
                }

                foreach (Event ev in Events)
                {
                    if (!ev.IsResolved)
                    {
                        ev.Resolve(referencables);
                    }
                }
                foreach (Enumeration enumeration in Enums)
                {
                    if (!enumeration.IsResolved)
                    {
                        enumeration.Resolve(referencables);
                    }
                }
                foreach (Field field in Fields)
                {
                    if (!field.IsResolved)
                    {
                        field.Resolve(referencables);
                    }
                }
            }
            else
            {
                ConvertToExternalReference();
            }
        }
Beispiel #21
0
 public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Namespace ns)
 {
     return new DeclaredType(typeIdentifier, ns) { IsResolved = false };
 }
Beispiel #22
0
        public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type declaration, Namespace ns)
        {
            var declaredType = new DeclaredType(typeIdentifier, ns) { IsResolved = false, declaration = declaration };

            if (declaration.BaseType != null)
            {
                declaredType.ParentType = Unresolved(
                    IdentifierFor.Type(declaration.BaseType),
                    declaration.BaseType,
                    Namespace.Unresolved(IdentifierFor.Namespace(declaration.BaseType.Namespace)));
            }

            IEnumerable<Type> interfaces = GetInterfaces(declaration);

            foreach (Type face in interfaces)
            {
                declaredType.Interfaces.Add(
                    Unresolved(IdentifierFor.Type(face), face, Namespace.Unresolved(IdentifierFor.Namespace(face.Namespace))));
            }

            return declaredType;
        }
Beispiel #23
0
        public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type declaration, Namespace ns)
        {
            var declaredType = new DeclaredType(typeIdentifier, ns)
            {
                IsResolved = false, declaration = declaration
            };

            if (declaration.BaseType != null)
            {
                declaredType.ParentType = Unresolved(
                    IdentifierFor.Type(declaration.BaseType),
                    declaration.BaseType,
                    Namespace.Unresolved(IdentifierFor.Namespace(declaration.BaseType.Namespace)));
            }

            IEnumerable <Type> interfaces = GetInterfaces(declaration);

            foreach (Type face in interfaces)
            {
                declaredType.Interfaces.Add(
                    Unresolved(IdentifierFor.Type(face), face, Namespace.Unresolved(IdentifierFor.Namespace(face.Namespace))));
            }

            return(declaredType);
        }