Esempio n. 1
0
        public void TestAddInlineElementItem()
        {
            var list = new MarkdownList();

            list.AddItem(new MarkdownText("item"));
            Assert.Equal("item", (list.ListItems.First() as MarkdownTextListItem).Text);
        }
Esempio n. 2
0
        public override void ShowRootItemMenu(int parameter)
        {
            _ActiveItem.IsHighlighted = true;
            var titles = _Titles = Array.ConvertAll(_Tags.GetTags(), t => new LocationItem(t));
            var menu   = new MarkdownList(this)
            {
                ItemsControlMaxHeight = View.ViewportHeight / 2,
                ItemsSource           = titles,
                SelectedIndex         = GetSelectedTagIndex(titles, View.GetCaretPosition().Position),
                FilteredItems         = new System.Windows.Data.ListCollectionView(titles)
            };

            menu.ScrollToSelectedItem();
            menu.MouseLeftButtonUp += MenuItemSelect;
            if (_Tags.Count > 100)
            {
                menu.EnableVirtualMode = true;
            }
            if (_TitleList != menu)
            {
                ListContainer.Children.Remove(_TitleList);
                ListContainer.Children.Add(menu);
                _TitleList = menu;
            }
            if (menu != null)
            {
                Canvas.SetLeft(menu, _ActiveItem.TransformToVisual(_ActiveItem.GetParent <Grid>()).Transform(new Point()).X - View.VisualElement.TranslatePoint(new Point(), View.VisualElement.GetParent <Grid>()).X);
                Canvas.SetTop(menu, -1);
            }
        }
Esempio n. 3
0
        public void TestAddStringItem()
        {
            var list = new MarkdownList();

            list.AddItem("item");
            Assert.Equal("item", (list.ListItems.First() as MarkdownTextListItem).Text);
        }
Esempio n. 4
0
        public void TestConstructorWithCharAndListItemsEnumerable()
        {
            {
                var list = new MarkdownList(
                    '-',
                    new List <MarkdownTextListItem> {
                    new MarkdownTextListItem("One"),
                    new MarkdownTextListItem("Two")
                }
                    );

                Assert.Equal('-', list.Char);
                Assert.Equal(2, list.ListItems.Count);
            }
            {
                var list = new MarkdownList(
                    '*',
                    new List <MarkdownTextListItem> {
                    new MarkdownTextListItem("One"),
                    new MarkdownTextListItem("Two")
                }
                    );

                Assert.Equal('*', list.Char);
                Assert.Equal(2, list.ListItems.Count);
            }
        }
Esempio n. 5
0
        internal static MarkdownList ToMDList(DotNetCommentList commentList, DotNetMember parent = null)
        {
            MarkdownList markdownList = new MarkdownList(isNumbered: commentList.IsNumbered);

            foreach (DotNetCommentListItem commentItem in commentList.Items)
            {
                MarkdownLine text = new MarkdownLine();
                if (commentItem.Term == null && commentItem.Description == null)
                {
                    markdownList.Add(text);
                    continue;
                }

                if (commentItem.Term == null)
                {
                    text = DotNetCommentGroupToMarkdownLine(commentItem.Description, parent);
                }
                else if (commentItem.Description == null)
                {
                    text = DotNetCommentGroupToMarkdownLine(commentItem.Term, parent);
                }
                else
                {
                    text = DotNetCommentGroupToMarkdownLine(commentItem.Term, parent);
                    text.Add(": ");
                    text.Concat(DotNetCommentGroupToMarkdownLine(commentItem.Description, parent));
                }
                markdownList.Add(text);
            }

            return(markdownList);
        }
Esempio n. 6
0
        public IElement CreateElement(string elementType, string props)
        {
            var      propArray = props.Split(';');
            IElement element;

            //determine element type
            switch (elementType)
            {
            case "Image":
                element = new MarkdownImage(propArray[0], propArray[1], propArray[2]);
                return(element);

            case "Header":
                element = new MarkdownHeader(propArray[0], propArray[1]);
                return(element);

            case "List":
                element = new MarkdownList(propArray[0], propArray[1], propArray[2], propArray[3]);
                return(element);

            case "Table":
                element = new MarkdownTable(propArray[0], propArray[1], propArray[2], propArray[3]);
                return(element);

            default:
                return(null);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Parses a <see cref="DocAssembly"/> to return a <see cref="DocFile"/>.
        /// </summary>
        /// <param name="assembly">The <see cref="DocAssembly"/> to parse.</param>
        /// <returns>The transformed <see cref="DocFile"/>.</returns>
        public DocFile Parse(DocAssembly assembly)
        {
            var result = new DocFile(assembly.FileName);

            result.AddThenBlankLine(writer.WriteHeading1($"{assembly.Name} API Reference"));
            result.AddThenBlankLine(ParserUtils.ProcessBreadcrumb(this));

            var list = new MarkdownList();

            foreach (var customDoc in assembly.CustomDocs)
            {
                if (customDoc is DocSerialization ser)
                {
                    list.AddItem(writer.WriteLink($"{ser.Name.NameOnly()} Reference", ser.FileName));
                    result.Files.Add(ProcessSerialization(ser, assembly));
                }
            }

            foreach (var ns in assembly.Namespaces.OrderBy(ns => ns.Name))
            {
                list.AddItem(writer.WriteLink(ns.Name, ns.FileName));
                result.Files.Add(ProcessNamespace(ns));
            }

            writer.AddRange(result.Markdown, list.CloseList());
            return(result);
        }
Esempio n. 8
0
        public void ShowRootItemMenu()
        {
            var titles = _Titles = Array.ConvertAll(_Tags.GetTags(), t => new LocationItem(t));
            var menu   = new MarkdownList(this)
            {
                ItemsControlMaxHeight = _View.ViewportHeight / 2,
                ItemsSource           = titles,
                SelectedIndex         = GetSelectedTagIndex(titles, _View.GetCaretPosition().Position),
                FilteredItems         = new System.Windows.Data.ListCollectionView(titles)
            };

            menu.ScrollToSelectedItem();
            menu.MouseLeftButtonUp += MenuItemSelect;
            if (_Tags.Count > 100)
            {
                ScrollViewer.SetCanContentScroll(menu, true);
            }
            if (_TitleList != menu)
            {
                _ListContainer.Children.Remove(_TitleList);
                _ListContainer.Children.Add(menu);
                _TitleList = menu;
            }
            if (menu != null)
            {
                Canvas.SetLeft(menu, _ActiveItem.TransformToVisual(_View.VisualElement).Transform(new Point()).X);
                Canvas.SetTop(menu, -1);
            }
        }
Esempio n. 9
0
        public void TestListWithListItem()
        {
            IMarkdownDocument document = new MarkdownDocument().AppendList(new MarkdownTextListItem("First"), new MarkdownTextListItem("Second"));
            MarkdownList      list     = Assert.IsType <MarkdownList>(document.ElementAt(0));

            Assert.Equal(2, list.ListItems.Count);
        }
Esempio n. 10
0
        public void TestConstructorWithStringArray()
        {
            var list = new MarkdownList("One", "Two");

            Assert.Equal('-', list.Char);
            Assert.Equal(2, list.ListItems.Count);
        }
Esempio n. 11
0
        public void TestEmptyConstructor()
        {
            var list = new MarkdownList();

            Assert.Empty(list.ListItems);
            Assert.Equal('-', list.Char);
            Assert.Equal(string.Empty, list.ToString());
        }
Esempio n. 12
0
        public void TestListWhithChar()
        {
            IMarkdownDocument document = new MarkdownDocument().AppendList('*', "First", "Second");
            MarkdownList      list     = Assert.IsType <MarkdownList>(document.ElementAt(0));

            Assert.Equal(2, list.ListItems.Count);
            Assert.Equal('*', list.Char);
        }
Esempio n. 13
0
 void HideMenu()
 {
     if (_TitleList != null)
     {
         _ListContainer.Children.Remove(_TitleList);
         _TitleList.SelectedItem = null;
         _TitleList = null;
     }
 }
Esempio n. 14
0
        public void TestConstructorWithListItemsArray()
        {
            var list = new MarkdownList(
                new MarkdownTextListItem("One"),
                new MarkdownTextListItem("Two")
                );

            Assert.Equal('-', list.Char);
            Assert.Equal(2, list.ListItems.Count);
        }
Esempio n. 15
0
 void HideMenu()
 {
     if (_TitleList != null)
     {
         ListContainer.Children.Remove(_TitleList);
         _TitleList.SelectedItem = null;
         _TitleList = null;
         _ActiveItem.IsHighlighted = false;
     }
 }
Esempio n. 16
0
        public bool AddMarkdown(string sku, double amount)
        {
            if (ValidateSkuEntry(sku, amount))
            {
                MarkdownList.Add(sku, amount);

                return(MarkdownList.Any(markdown => markdown.Key.Equals(sku) && markdown.Value.Equals(amount)));
            }

            return(false);
        }
Esempio n. 17
0
        internal static MarkdownList EnumToMinimalMDList(DotNetType _enum)
        {
            MarkdownList list = new MarkdownList(isNumbered: false);

            foreach (DotNetField field in _enum.Fields)
            {
                list.Add(new MarkdownLine(field.ConstantValue + ": " + field.Name.LocalName));
            }

            return(list);
        }
Esempio n. 18
0
        public void MarkdownList_Add_InLine()
        {
            //arrange
            MarkdownList list = new MarkdownList();
            MarkdownText text = new MarkdownText("abc");

            //act
            list.Add(text as IMarkdownInLine);
            //assert
            Assert.AreEqual(1, list.Length);
            Assert.IsNotNull(list[0]);
        }
Esempio n. 19
0
        public void TestListWithCharAndListItemEnumerable()
        {
            IMarkdownDocument document = new MarkdownDocument().AppendList(
                '*',
                new List <MarkdownTextListItem>
            {
                new MarkdownTextListItem("First"),
                new MarkdownTextListItem("Second")
            }
                );
            MarkdownList list = Assert.IsType <MarkdownList>(document.ElementAt(0));

            Assert.Equal(2, list.ListItems.Count);
            Assert.Equal('*', list.Char);
        }
Esempio n. 20
0
        public double GetMarkdown(string sku)
        {
            var markdown = ERROR_RETURN;

            if (ValidateSkuRequest(sku))
            {
                if (MarkdownList.Any(mn => mn.Key.Equals(sku)))
                {
                    markdown = MarkdownList[sku];
                }
                else
                {
                    markdown = 0;
                }
            }

            return(markdown);
        }
Esempio n. 21
0
        protected virtual MarkdownPage GenerateDocumentationIndex([NotNull, ItemNotNull] IEnumerable <MarkdownPage> modulePages)
        {
            var moduleList = new MarkdownList();

            foreach (var modulePage in modulePages)
            {
                moduleList.AppendItem(new MarkdownLink($"modules/{modulePage.Name}.md", modulePage.Title.Humanize().Transform(To.TitleCase)));
            }

            var page = new MarkdownPage("index", "Index")
                       .AppendSection
                       (
                new MarkdownSection("Available Command Modules", 3)
                .AppendContent
                (
                    moduleList
                )
                       );

            page.Footer = "<sub><sup>Generated by DIGOS.Ambassador.Doc</sup></sub>";

            return(page);
        }
Esempio n. 22
0
        public void TestToString()
        {
            var list = new MarkdownList(
                new MarkdownTextListItem("One"),
                new MarkdownTextListItem("Two"),
                new MarkdownList(
                    new MarkdownTextListItem("First"),
                    new MarkdownTextListItem("Second"),
                    new MarkdownList(
                        new MarkdownTextListItem("First"),
                        new MarkdownTextListItem("Second")
                        )
                    )
                );

            Assert.Equal(
                "- One" + Environment.NewLine +
                "- Two" + Environment.NewLine +
                "  - First" + Environment.NewLine +
                "  - Second" + Environment.NewLine +
                "    - First" + Environment.NewLine +
                "    - Second" + Environment.NewLine, list.ToString());
        }
Esempio n. 23
0
        protected virtual MarkdownSection GenerateSubmodulesSection([NotNull] ModuleInformation module)
        {
            var submoduleSection = new MarkdownSection("Submodules", 2);
            var submoduleList    = new MarkdownList
            {
                Type = ListType.Bullet
            };

            submoduleSection.AppendContent(submoduleList);

            foreach (var submodule in module.Submodules)
            {
                submoduleList.AppendItem
                (
                    new MarkdownLink
                    (
                        $"{submodule.GetNameChain().Replace(" ", "_")}.md",
                        submodule.Name.Humanize()
                    )
                );
            }

            return(submoduleSection);
        }