Exemplo n.º 1
0
        /// <summary>
        /// Renders the <see cref="ExceptionDoc"/> element  to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Builds the link with the reference according to the <c>cref</c> attribute value. The value represents the Documentation ID
        /// that can be matched to the information got during the code analysis or to build the link to MS API reference for the "MS objects".
        /// First, it tries to resolve the <see cref="Member"/> in code being documented (internal link). If not successful, tries to look for
        /// the <c>cref</c> (Documentation ID) in the MS API documentation if allowed/available (see <see cref="MsApiDocEngine"/> for details)
        /// <para>
        /// The link text is the the name of linked entity when using internal <see cref="IMarkupProvider.Link(string,net.adamec.dev.markupdoc.CodeModel.Member)"/>
        /// or the <c>cref</c> without the leading type information when rendering .
        /// When the link is not constructed ("target unknown"), the <c>cref</c>  value without the leading type information is rendered in italic
        /// </para>
        /// <para>
        /// The &lt;exception&gt; element is then rendered as <see cref="IMarkupProvider.DescriptionListItem"/> where
        ///<c>Term</c> is the link and <c>Description</c> is the fully trimmed element content.
        /// Important: it returns description list item, so must be encapsulated on higher level !!!
        /// </para>
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of &lt;exception&gt; element of XML Documentation Comments.
        /// Important: it returns description list item, so must be encapsulated on higher level !!!</returns>
        ///<seealso cref="MsApiDocEngine"/>
        /// <seealso cref="MsApiDocOptions"/>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            //for exception always render both Ref(link if available) AND content

            //content
            var content = base.RenderElement(markupProvider, member, trim);

            //ref
            string exceptionRef;

            if (member.Root.AllMembersByDocId.TryGetValue(Ref, out var refMember))
            {
                exceptionRef = markupProvider.Link(refMember.Name, refMember);
            }
            else
            {
                //Try to get the MS API link from reference
                var msLink = MsApiDocEngine.GetLink(Ref);
                //Got the MS link, so use external link
                // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                if (msLink != null)
                {
                    exceptionRef = markupProvider.ExternalLink(Ref.Substring(2), msLink);
                }
                else
                {
                    //No link -  Ref without leading "ref type"
                    exceptionRef = markupProvider.Italic(Ref.Substring(2));
                }
            }
            //output
            return(markupProvider.DescriptionListItem(exceptionRef, content));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Зарегистрировать провайдер.
 /// </summary>
 /// <param name="markupProvider">Провайдер.</param>
 public void RegisterProvider(IMarkupProvider markupProvider)
 {
     lock (providers)
     {
         providers[markupProvider.MarkupType] = markupProvider;
     }
 }
        /// <summary>
        /// Renders the element having the <c>cref</c> attribute to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Builds the link with the reference according to the <c>cref</c> attribute value. The value represents the Documentation ID
        /// that can be matched to the information got during the code analysis or to build the link to MS API reference for the "MS objects".
        /// First, it tries to resolve the <see cref="Member"/> in code being documented (internal link). If not successful, tries to look for
        /// the <c>cref</c> (Documentation ID) in the MS API documentation if allowed/available (see <see cref="MsApiDocEngine"/> for details)
        /// <para>
        /// The link text is the rendered trimmed content of the tag if available,
        /// the name of linked entity when using internal <see cref="IMarkupProvider.Link(string,net.adamec.dev.markupdoc.CodeModel.Member)"/>
        /// or the <c>cref</c> without the leading type information when rendering <see cref="IMarkupProvider.ExternalLink"/>.
        /// When the link is not constructed ("target unknown"), the <c>cref</c>  value without the leading type information is rendered in italic
        /// </para>
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of element of XML Documentation Comments</returns>
        ///<seealso cref="MsApiDocEngine"/>
        /// <seealso cref="MsApiDocOptions"/>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true) //used  for links
        {
            // ReSharper disable once RedundantArgumentDefaultValue
            var content = base.RenderElement(markupProvider, member, true); //always trim content for links

            if (string.IsNullOrEmpty(Ref))
            {
                return(content);
            }

            //Return Ref to existing member as link, if available. If no content provided, use the member's name
            if (member.Root.AllMembersByDocId.TryGetValue(Ref, out var refMember))
            {
                return(markupProvider.Link(!string.IsNullOrEmpty(content) ? content : refMember.Name, refMember));
            }

            //Try to get the MS API link from reference
            var msLink = MsApiDocEngine.GetLink(Ref);

            //Got the MS link, so return external link
            if (msLink != null)
            {
                return(markupProvider.ExternalLink(!string.IsNullOrEmpty(content) ? content : Ref.Substring(2), msLink));
            }

            //No link, return content if available otherwise Ref without leading "ref type"
            return(!string.IsNullOrEmpty(content) ? content : markupProvider.Italic(Ref.Substring(2)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Renders the <see cref="C"/> and its content to string
        /// containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Gets (fully) trimmed content of the tag and renders it using <see cref="IMarkupProvider.InlineCode"/>
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of &lt;c&gt; element of XML Documentation Comments</returns>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            // ReSharper disable once RedundantArgumentDefaultValue
            var content = base.RenderElement(markupProvider, member, true); //always trim spaces for inline code.Text

            content = markupProvider.InlineCode(content);
            return(content);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Writes to the footer for the code model member page
        /// </summary>
        /// <param name="baseFileName">Name of the main file</param>
        /// <param name="markup">Markup provider</param>
        /// <returns>String to be added to the footer</returns>
        public string WritePageFooter(string baseFileName, IMarkupProvider markup)
        {
            if (SourceOnlyPackages != null && SourceOnlyPackages.Count > 0)
            {
                return(markup.Link("source-only packages", baseFileName, "package-list"));
            }

            return("");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Renders the <see cref="ModelElement"/> and its content to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Gets content of the all child <see cref="Elements"/>  and merges it together with a space as a separator.
        /// If <paramref name="trim"/> parameter is set, the result is "fully" trimmed - the line breaks are replaced by spaces and leading/ending spaces are removed.
        /// The parameter is also propagated to child's RenderElement function when getting the content.
        /// Use <see cref="TagKeepLineBreak"/> and <see cref="TagKeepSpace"/> in derived classes to preserve the whitespaces.
        /// when the parent element is to be rendered (and its content trimmed)
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of element/node of XML Documentation Comments</returns>
        protected virtual string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            var sb = new StringBuilder();

            foreach (var element in Elements)
            {
                sb.Append(element.RenderElement(markupProvider, member, trim) + " ");
            }
            return(trim ? sb.ToString().TrimAndMergeLines() : sb.ToString());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Writes the header for the code model member
        /// </summary>
        /// <remarks>Writes source-only packages list if available</remarks>
        /// <param name="member">Member being documented</param>
        /// <param name="markup">Markup provider</param>
        /// <returns>String to be added to the header text builder</returns>
        public string WritePageHeader(Member member, IMarkupProvider markup)
        {
            SourceOnlyPackagesByMember.TryGetValue(member, out var packages);
            if (packages == null || packages.Count < 1)
            {
                return(string.Empty);
            }

            return(markup.LineBreak() + "Source-only packages: " + string.Join(", ", packages.Select(p => Link(p.PackageId, p, markup))));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Renders the <c>see</c> element - by default the <see cref="ModelElementWithCrefSimple.RenderElement"/> is used.
        /// <c>langword</c> attribute is rendered when the base renders null or empty
        /// </summary>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of element of XML Documentation Comments</returns>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true) //used  for links
        {
            // ReSharper disable once RedundantArgumentDefaultValue
            var content = base.RenderElement(markupProvider, member, true); //always trim content for links

            if (string.IsNullOrEmpty(content) && !string.IsNullOrEmpty(Langword))
            {
                return(markupProvider.InlineCode(Langword));
            }

            return(content ?? "");
        }
Exemplo n.º 9
0
        /// <summary>
        /// Renders the <see cref="Para"/> and its content to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Gets trimmed content of the tag and renders it using <see cref="IMarkupProvider.Para"/>.
        /// Replaces the line breaks within the output with <see cref="ModelElement.TagKeepLineBreak"/> pseudo-tag
        /// to preserve the line breaks in the markup when the parent element is to be rendered (and its content trimmed)
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of &lt;para&gt; element of XML Documentation Comments</returns>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            // ReSharper disable once RedundantArgumentDefaultValue
            var content = base.RenderElement(markupProvider, member, true); //always trim the content

            content = markupProvider.Para(content);
            content = content
                      .Replace("\r\n", TagKeepLineBreak)
                      .Replace("\r", TagKeepLineBreak)
                      .Replace("\n", TagKeepLineBreak);//preserve line breaks
            return(content);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Renders the <see cref="ModelElement"/> and its content to string containing the markup provided by <paramref name="markupProvider"/>.
        /// This is the public "entry point" to <see cref="RenderElement"/> that does the final adjustment of the whitespaces.
        /// </summary>
        /// <remarks>
        /// Gets content of the all child <see cref="Elements"/>  and merges it together with a space as a separator.
        /// The result is "fully" trimmed - the line breaks are replaced by spaces and leading/ending spaces are removed.
        /// Use <see cref="TagKeepLineBreak"/> and <see cref="TagKeepSpace"/> in derived classes' <see cref="RenderElement"/> to preserve the whitespaces.
        /// The <see cref="Render"/> method replaces <see cref="ModelElement.TagKeepLineBreak"/> and  <see cref="ModelElement.TagKeepSpace"/>
        /// pseudo-tags back to line breaks and spaces to preserve the "hard" whitespace required by the rendering method
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <returns>Rendered content of element/node of XML Documentation Comments</returns>
        public virtual string Render(IMarkupProvider markupProvider, Member member)
        {
            var o = RenderElement(markupProvider, member);

            o = o.TrimAndMergeLines(); //shrink whitespaces

            //restore the "hard" whitespaces
            o = o.Replace(TagKeepLineBreak, Environment.NewLine);
            o = o.Replace(TagKeepSpace, " ");
            o = o.Replace(TagKeepLineBreak.HtmlEncode(), Environment.NewLine); //also the html encoded values for code
            o = o.Replace(TagKeepSpace.HtmlEncode(), " ");
            return(o);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Writes the body fro the code model member
        /// </summary>
        /// <remarks>This method is used as a sample only. It's not called as the <see cref="PriorityPageBody"/> is zero</remarks>
        /// <param name="member">Member being documented</param>
        /// <param name="markup">Markup provider</param>
        /// <returns>Async task</returns>
        public async Task WritePageBodyAsync(Member member, IMarkupProvider markup)
        {
            SourceOnlyPackagesByMember.TryGetValue(member, out var packages);
            if (packages == null || packages.Count < 1)
            {
                return;
            }

            await markup.WriteH3Async("Source-only packages");

            await markup.WriteParaAsync(new Txt()
                                        .AddEach(p => $"{p.PackageId} - {p.PackageDescription}", packages, markup.LineBreak()));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Renders the <see cref="Code"/> and its content to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Gets not-trimmed content of the tag and renders it using <see cref="IMarkupProvider.Code"/>.
        /// Replaces the line breaks within the output with <see cref="ModelElement.TagKeepLineBreak"/> pseudo-tag and
        /// spaces with <see cref="ModelElement.TagKeepSpace"/> pseudo-tag to preserve the whitespace when the
        /// parent element is to be rendered (and its content trimmed)
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of &lt;code&gt; element of XML Documentation Comments</returns>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            var content = base.RenderElement(markupProvider, member, false);         //don't trim spaces for code.Text

            content = content.Trim('\n').Trim('\r').TrimEnd().Trim('\n').Trim('\r'); //ensure "just code" without leading/ending line breaks and ending spaces
            content = markupProvider.Code(content);
            content = content
                      .Replace("\r\n", TagKeepLineBreak)
                      .Replace("\r", TagKeepLineBreak)
                      .Replace("\n", TagKeepLineBreak)
                      .Replace(" ", TagKeepSpace); //preserve whitespaces

            return(content);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Renders the <see cref="List"/> and its content to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// Gets content of the all child <see cref="ListItem"/> elements and renders them into the list of required <see cref="ListType"/>.
        ///<list type="bullet">
        /// <item>
        /// <term>Bullet list</term>
        /// <description>Each item contains "Term" in bold and "Description" (separated by dash). Both parts are optional.
        /// This includes the list header item if present, however, there is no special handling for such item.</description>
        /// </item>
        /// <item>
        /// <term>Numbered list</term>
        /// <description>Each item contains "Term" in bold and "Description" (separated by dash). Both parts are optional.
        /// This includes the list header item if present, however, there is no special handling for such item.</description></item>
        /// <item>
        /// <term>Table</term>
        /// <description>Rendered as two column table (term and description). Both parts are optional.
        /// Header item should be provided to define the table header ("Term" and "Description" are used as defaults)</description></item>
        /// </list>
        ///The rendering uses <see cref="IMarkupProvider.List{T}"/> to render the lists and <see cref="IMarkupProvider.TableHeader"/>,
        /// <see cref="IMarkupProvider.TableCols"/> and<see cref="IMarkupProvider.TableFooter"/> for table rendering.
        /// Pseudo-tags <see cref="ModelElement.TagKeepLineBreak"/> and <see cref="ModelElement.TagKeepSpace"/> are used in the rendering output, to preserve the whitespaces
        /// when the parent element is to be rendered (and its content trimmed)
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered list element of XML Documentation Comments</returns>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            switch (ListType)
            {
            case ListTypeEnum.Bullet:
            case ListTypeEnum.Number:
                var content = markupProvider.List(li =>
                {
                    {
                        var term        = li.Term?.Render(markupProvider, member);
                        var description = li.Description?.Render(markupProvider, member) ?? "";
                        return(!string.IsNullOrEmpty(term)
                                ? $"{markupProvider.Bold(term)}{(!string.IsNullOrEmpty(description) ? $" - {description}" : "")}"
                                : description);
                    }
                }, Elements.OfType <ListItem>().ToList(), ListType == ListTypeEnum.Number);
                content = $"{Environment.NewLine}{Environment.NewLine}{content}{Environment.NewLine}{Environment.NewLine}"     //ensure proper separation from the text
                          .Replace("\r\n", TagKeepLineBreak)
                          .Replace("\r", TagKeepLineBreak)
                          .Replace("\n", TagKeepLineBreak)
                          .Replace(" ", TagKeepSpace); //preserve whitespaces
                return(content);

            case ListTypeEnum.Table:
                var headerItem        = Elements.OfType <ListItem>().FirstOrDefault(li => li.IsHeader);
                var headerTerm        = headerItem?.Term?.Render(markupProvider, member) ?? "Term";
                var headerDescription = headerItem?.Description?.Render(markupProvider, member) ?? "Description";
                var contentTbl        = markupProvider.TableHeader(headerTerm, headerDescription);
                foreach (var listItem in Elements.OfType <ListItem>().Where(li => !li.IsHeader))
                {
                    var term        = listItem.Term?.Render(markupProvider, member) ?? "";
                    var description = listItem.Description?.Render(markupProvider, member) ?? "";
                    contentTbl += markupProvider.TableCols(term, description);
                }
                contentTbl += markupProvider.TableFooter();
                contentTbl  = $"{Environment.NewLine}{Environment.NewLine}{contentTbl}{Environment.NewLine}{Environment.NewLine}"    //ensure proper separation from the text
                              .Replace("\r\n", TagKeepLineBreak)
                              .Replace("\r", TagKeepLineBreak)
                              .Replace("\n", TagKeepLineBreak)
                              .Replace(" ", TagKeepSpace); //preserve whitespaces
                return(contentTbl);

            default:
                return("");
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates the link to the <see cref="package"/> page
        /// </summary>
        /// <param name="text">Link text</param>
        /// <param name="package">Package metadata</param>
        /// <param name="markup">Markup provider</param>
        /// <returns>Markup with the link to the <param name="package"></param></returns>
        private string Link(string text, NuProps package, IMarkupProvider markup)
        {
            var fileName = string.Empty;

            if (OutputOptions.SplitNs && !OutputOptions.SplitType)
            {
                fileName = GetPackagePagesFileName();
            }
            if (OutputOptions.SplitType)
            {
                fileName = GetPackagePageFileName(package);
            }

            var extension = markup.Extension;

            return(markup.Link(text, string.IsNullOrEmpty(fileName) ? "" : $"{fileName}.{extension}", GetPackageAnchor(package)));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Writes the table of all source-only packages within the code model into the output
        /// </summary>
        /// <param name="root">Code model root</param>
        /// <param name="markup">Markup provider</param>
        /// <returns>True when any output has been generated</returns>
        public async Task <bool> WriteIndexAsync(RootMember root, IMarkupProvider markup)
        {
            if (SourceOnlyPackages == null || SourceOnlyPackages.Count < 1)
            {
                return(false);
            }

            await markup.WriteH2Async("Source-only packages", "package-list");

            await markup.WriteTableHeaderAsync("Name", "Summary");

            foreach (var nuProps in SourceOnlyPackages.OrderBy(p => p.PackageId))
            {
                await markup.WriteTableColsAsync(Link(nuProps.PackageId, nuProps, markup), nuProps.PackageDescription ?? string.Empty);
            }
            await markup.WriteTableFooterAsync();

            return(true);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Renders the <see cref="TypeParamRef"/> and its content to string containing the markup provided by <paramref name="markupProvider"/>
        /// </summary>
        /// <remarks>
        /// When the element has the content (text), the content is rendered, otherwise the <c>name</c> attribute value in bold is rendered.
        /// </remarks>
        /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
        /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
        /// <param name="trim">Flag whether to (full) trim the rendered content</param>
        /// <returns>Rendered content of &lt;typeparamref&gt; element of XML Documentation Comments</returns>
        protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
        {
            var content = base.RenderElement(markupProvider, member, trim);

            return(!string.IsNullOrEmpty(content) ? content : markupProvider.Bold(Name));
        }
 public ForumsCrawler(IMarkupProvider markupProvider)
 {
     this.markupProvider = markupProvider;
     address             = BaseForumsAddress + "page/";
 }
Exemplo n.º 18
0
        /// <summary>
        /// Writes the source-only packages pages into the output
        /// </summary>
        /// <param name="root">Code model root</param>
        /// <param name="markup">Markup provider</param>
        /// <param name="generator">Markup generator</param>
        /// <returns>Async task</returns>
        public async Task WriteOwnPagesAsync(RootMember root, IMarkupProvider markup, MarkupGenerator generator)
        {
            if (SourceOnlyPackages == null || SourceOnlyPackages.Count < 1)
            {
                return;
            }

            if (OutputOptions.SplitNs && !OutputOptions.SplitType)
            {
                //split by Ns only -> all source only packages will be on single page
                await generator.SplitAsync(GetPackagePagesFileName());
            }
            foreach (var nuProps in SourceOnlyPackages.OrderBy(p => p.PackageId))
            {
                if (OutputOptions.SplitType)
                {
                    //split by Type -> each source only packages will be on dedicated page
                    await generator.SplitAsync(GetPackagePageFileName(nuProps));
                }

                await markup.WriteH2Async($"{nuProps.PackageId} Source only package", GetPackageAnchor(nuProps));

                await markup.WriteParaAsync(
                    markup.Small(
                        new Txt()
                        .AddIf($"Version: {nuProps.PackageVersion}", !string.IsNullOrEmpty(nuProps.PackageVersion))
                        .AddIf(markup.LineBreak(), !string.IsNullOrEmpty(nuProps.PackageVersion))
                        .AddIf($"Tags: {nuProps.PackageTags}", !string.IsNullOrEmpty(nuProps.PackageTags))
                        .AddIf(markup.LineBreak(), !string.IsNullOrEmpty(nuProps.PackageTags))
                        .Add($"Includes: {nuProps.IncludesType}")
                        .Add(markup.LineBreak())
                        .Add($"Declaring file: { PathUtils.GetRelativeSourceFile(nuProps.DeclaringFile,root.ProjectRootDir)}")
                        ));

                await markup.WriteParaAsync(nuProps.PackageDescription);

                if (nuProps.Usings != null && nuProps.Usings.Count > 0)
                {
                    await markup.WriteParaAsync(new Txt()
                                                .Add(markup.Bold("Usings"))
                                                .Add(markup.DescriptionList(
                                                         u =>
                    {
                        var refPkg = SourceOnlyPackages.FirstOrDefault(p => p.PackageId == u.PackageId);
                        return(refPkg == null ? u.PackageId : Link(u.PackageId, refPkg, markup));
                    },
                                                         u => string.IsNullOrEmpty(u.PackageVersion) ? string.Empty : $"version: {u.PackageVersion}",
                                                         nuProps.Usings)));
                }

                if (nuProps.ExternalReferences != null && nuProps.ExternalReferences.Count > 0)
                {
                    await markup.WriteParaAsync(new Txt()
                                                .Add(markup.Bold("References needed"))
                                                .Add(markup.DescriptionList(
                                                         er => er,
                                                         er => string.Empty,
                                                         nuProps.ExternalReferences)));
                }

                if (nuProps.PackageRemarksSource != null &&
                    root.AllMembersByDocId.TryGetValue(nuProps.PackageRemarksSource, out var member))
                {
                    var remarksDocumentation = member.Documentation?.GetRemarks(member)?.Render(markup, member);
                    if (!string.IsNullOrEmpty(remarksDocumentation))
                    {
                        await markup.WriteH3Async("Remarks");

                        await markup.WriteParaAsync(remarksDocumentation);
                    }
                }

                if (MembersBySourceOnlyPackage.TryGetValue(nuProps, out var members) && members.Count > 0)
                {
                    await markup.WriteParaAsync(new Txt()
                                                .Add(markup.Bold("Package members"))
                                                .Add(markup.DescriptionList(
                                                         m => markup.Link($"{m.Name} ({m.MemberKind})", m),
                                                         m => m.Documentation?.GetSummary(m)?.Render(markup, m),
                                                         members)));
                }
                await markup.WriteParaAsync(new Txt()
                                            .Add(markup.Bold("Sources"))
                                            .Add(markup.DescriptionList(
                                                     f => $"{PathUtils.GetRelativeSourceFile(f,root.ProjectRootDir)}",
                                                     f => string.Empty,
                                                     nuProps.PackageFiles)));

                await generator.WritePageFooterAsync();
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="provider">Провайдер.</param>
 /// <param name="tag">Тэг.</param>
 public ApplyMarkupEventArgs(IMarkupProvider provider, MarkupTag tag)
 {
     this.provider = provider;
     this.tag = tag;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Renders the <see cref="Text"/> content to string
 /// </summary>
 /// <remarks>
 /// The text content is by default fully trimmed meaning that the inner line breaks are replaced by spaces
 /// and leading and ending spaces and line breaks are cut out.
 /// </remarks>
 /// <param name="markupProvider"><see cref="IMarkupProvider"/> allowing using the markup within the rendered content</param>
 /// <param name="member">Code model <see cref="Member"/> to render the XML Documentation Comment for</param>
 /// <param name="trim">Flag whether to (full) trim the rendered content</param>
 /// <returns>Rendered text content of element in XML Documentation Comments</returns>
 protected override string RenderElement(IMarkupProvider markupProvider, Member member, bool trim = true)
 {
     return(markupProvider.Text(trim ? Content.TrimAndMergeLines() : Content));
 }