Example #1
0
        public void Text_property_is_converted_to_CompositeSpan_when_required_03()
        {
            var paragraph = new MdParagraph();

            var expected = MdEmptySpan.Instance;

            Assert.True(expected.DeepEquals(paragraph.Text));
        }
Example #2
0
        public void Text_property_is_converted_to_CompositeSpan_when_required_02()
        {
            var paragraph = new MdParagraph("Text", "Text");

            var expected = new MdCompositeSpan(new MdTextSpan("Text"), new MdTextSpan("Text"));

            Assert.True(expected.DeepEquals(paragraph.Text));
        }
Example #3
0
        public void MdParagraph_can_be_initialized_with_string_content_01()
        {
            var paragraph = new MdParagraph("Content");

            Assert.IsType <MdTextSpan>(paragraph.Text);

            var textSpan = (MdTextSpan)paragraph.Text;

            Assert.Equal("Content", textSpan.Text);
        }
Example #4
0
        public void DeepEquals_returns_expected_value()
        {
            var instance1 = new MdParagraph("Some Text");
            var instance2 = new MdParagraph("Some Text");
            var instance3 = new MdParagraph("Other", "text");

            Assert.True(instance1.DeepEquals(instance1));
            Assert.True(instance1.DeepEquals(instance2));

            Assert.False(instance1.DeepEquals(null));
            Assert.False(instance1.DeepEquals(instance3));
            Assert.False(instance1.DeepEquals(new MdParagraph()));
        }
Example #5
0
        public void MdParagraph_can_be_initialized_with_string_content_02()
        {
            var paragraph = new MdParagraph("Content1", "Content2");

            Assert.IsType <MdCompositeSpan>(paragraph.Text);

            var compositeSpan = (MdCompositeSpan)paragraph.Text;

            Assert.Equal(2, compositeSpan.Spans.Count);
            var textSpan1 = Assert.IsType <MdTextSpan>(compositeSpan.Spans[0]);
            var textSpan2 = Assert.IsType <MdTextSpan>(compositeSpan.Spans[1]);

            Assert.Equal("Content1", textSpan1.Text);
            Assert.Equal("Content2", textSpan2.Text);
        }
Example #6
0
        public void Visit(MdParagraph paragraph)
        {
            m_Writer.RequestBlankLine();

            var lines = paragraph.Text.ToString(m_Options).Split(s_LineBreakChars, StringSplitOptions.RemoveEmptyEntries);

            // skip paragraph if it is empty
            if (lines.Length == 0)
            {
                return;
            }

            for (var i = 0; i < lines.Length; i++)
            {
                // get the current line
                var line = lines[i];

                // if the line is not the last, append 2 spaces to
                // cause a line break in the output
                // for the last line, this can be omitted, as there will
                // be a blank line after the paragraph
                if (i != lines.Length - 1)
                {
                    line += "  ";
                }

                // no maximum line length specified => write the line to the output
                if (m_Options.MaxLineLength <= 0)
                {
                    m_Writer.WriteLine(line);
                }
                // maximum line length specified
                // => format lines to max length and write all lines to the output
                else
                {
                    var formattedLines = LineFormatter.GetLines(line, m_Options.MaxLineLength - m_Writer.PrefixLength);
                    foreach (var formattedLine in formattedLines)
                    {
                        m_Writer.WriteLine(formattedLine);
                    }
                }
            }

            m_Writer.RequestBlankLine();
        }
Example #7
0
        protected void AddDeclaringTypeSection(MdContainerBlock block)
        {
            var paragraph = new MdParagraph(
                new MdStrongEmphasisSpan("Declaring Type:"), " ", GetMdSpan(Model.TypeDocumentation.TypeId),
                "\r\n",
                new MdStrongEmphasisSpan("Namespace:"), " ", GetMdSpan(Model.TypeDocumentation.NamespaceDocumentation.NamespaceId),
                "\r\n",
                new MdStrongEmphasisSpan("Assembly:"), " " + Model.AssemblyDocumentation.Name
                );

            if (m_Configuration.Template.Default.IncludeVersion)
            {
                paragraph.Add("\r\n");
                paragraph.Add(new MdCompositeSpan(
                                  new MdStrongEmphasisSpan("Assembly Version:"), " " + Model.AssemblyDocumentation.Version)
                              );
            }

            block.Add(paragraph);
        }
Example #8
0
        private void AddDefinitionSection(MdContainerBlock block)
        {
            var infoParagraph = new MdParagraph();

            block.Add(infoParagraph);

            // Add declaring type if the type is a nested type
            if (Model.IsNestedType)
            {
                infoParagraph.Add(new MdCompositeSpan(new MdStrongEmphasisSpan("Declaring Type:"), " ", GetMdSpan(Model.DeclaringType !.TypeId)));
                infoParagraph.Add("\r\n");
            }

            // add namespace and assembly names
            infoParagraph.Add(new MdCompositeSpan(new MdStrongEmphasisSpan("Namespace:"), " ", GetMdSpan(Model.NamespaceDocumentation.NamespaceId)));
            infoParagraph.Add("\r\n");
            infoParagraph.Add(new MdCompositeSpan(new MdStrongEmphasisSpan("Assembly:"), " " + Model.GetAssemblyDocumentation().Name));

            // add assembly version
            if (m_Configuration.Template.Default.IncludeVersion)
            {
                infoParagraph.Add("\r\n");
                infoParagraph.Add(new MdCompositeSpan(new MdStrongEmphasisSpan("Assembly Version:"), " " + Model.GetAssemblyDocumentation().Version));
            }

            if (!Model.Summary.IsEmpty)
            {
                block.Add(ConvertToBlock(Model.Summary));
            }

            // Definition as code
            block.Add(new MdCodeBlock(Model.CSharpDefinition, "csharp"));

            // Add list of base types
            if (Model.InheritanceHierarchy.Count > 1)
            {
                block.Add(
                    new MdParagraph(
                        new MdStrongEmphasisSpan("Inheritance:"),
                        " ",
                        Model.InheritanceHierarchy.Select(GetMdSpan).Join(" → ")
                        ));
            }

            // Add class attributes
            if (Model.Attributes.Count > 0)
            {
                block.Add(
                    new MdParagraph(
                        new MdStrongEmphasisSpan("Attributes:"),
                        " ",
                        Model.Attributes.Select(GetMdSpan).Join(",")
                        ));
            }

            // Add list of implemented interfaces
            if (Model.ImplementedInterfaces.Count > 0)
            {
                block.Add(
                    new MdParagraph(
                        new MdStrongEmphasisSpan("Implements:"),
                        " ",
                        Model.ImplementedInterfaces.Select(GetMdSpan).Join(","))
                    );
            }
        }