コード例 #1
0
        private XRefSpec GetXrefFromUid(string uid, FileModel model, IDocumentBuildContext context)
        {
            var xref = context.GetXrefSpec(uid);

            if (xref == null)
            {
                Logger.LogWarning($"Unable to find file with uid \"{uid}\" referenced by TOC file \"{model.LocalPathFromRoot}\"");
            }
            return(xref);
        }
コード例 #2
0
        private XRefSpec GetXrefFromUid(string uid, FileModel model, IDocumentBuildContext context, string includedFrom)
        {
            var xref = context.GetXrefSpec(uid);

            if (xref == null)
            {
                Logger.LogWarning(
                    $"Unable to find file with uid \"{uid}\" referenced by TOC file \"{includedFrom ?? model.LocalPathFromRoot}\"",
                    code: WarningCodes.Build.UidNotFound,
                    file: includedFrom);
            }
            return(xref);
        }
コード例 #3
0
        private static void UpdateXref(HtmlNode node, IDocumentBuildContext context, string language)
        {
            var xref = XRefDetails.From(node);

            // Resolve external xref map first, and then internal xref map.
            // Internal one overrides external one
            var xrefSpec = context.GetXrefSpec(HttpUtility.HtmlDecode(xref.Uid));

            xref.ApplyXrefSpec(xrefSpec);

            var convertedNode = xref.ConvertToHtmlNode(language);

            node.ParentNode.ReplaceChild(convertedNode, node);
            if (xrefSpec == null && xref.ThrowIfNotResolved)
            {
                throw new CrossReferenceNotResolvedException(xref);
            }
        }
コード例 #4
0
        private (bool resolved, bool warn) UpdateXref(HtmlNode node, IDocumentBuildContext context, string language, out XRefDetails xref)
        {
            xref = XRefDetails.From(node);
            XRefSpec xrefSpec = null;

            if (!string.IsNullOrEmpty(xref.Uid))
            {
                // Resolve external xref map first, and then internal xref map.
                // Internal one overrides external one
                xrefSpec = context.GetXrefSpec(HttpUtility.HtmlDecode(xref.Uid));
                xref.ApplyXrefSpec(xrefSpec);
            }

            var renderer = xref.TemplatePath == null ? null : _rendererLoader.Load(xref.TemplatePath);

            var(convertedNode, resolved) = xref.ConvertToHtmlNode(language, renderer);
            node.ParentNode.ReplaceChild(convertedNode, node);
            var warn = xrefSpec == null && xref.ThrowIfNotResolved;

            return(resolved, warn);
        }
コード例 #5
0
        private static bool UpdateXref(HtmlNode node, IDocumentBuildContext context, string language, out XRefDetails xref)
        {
            xref = XRefDetails.From(node);
            XRefSpec xrefSpec = null;

            if (!string.IsNullOrEmpty(xref.Uid))
            {
                // Resolve external xref map first, and then internal xref map.
                // Internal one overrides external one
                xrefSpec = context.GetXrefSpec(HttpUtility.HtmlDecode(xref.Uid));
                xref.ApplyXrefSpec(xrefSpec);
            }

            var convertedNode = xref.ConvertToHtmlNode(language);

            node.ParentNode.ReplaceChild(convertedNode, node);
            if (xrefSpec == null && xref.ThrowIfNotResolved == true)
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
ファイル: TocDocumentProcessor.cs プロジェクト: ansyral/docfx
 private XRefSpec GetXrefFromUid(string uid, FileModel model, IDocumentBuildContext context)
 {
     var xref = context.GetXrefSpec(uid);
     if (xref == null)
     {
         throw new DocumentException($"Unable to find file with uid \"{uid}\" referenced by TOC file \"{model.LocalPathFromRepoRoot}\"");
     }
     return xref;
 }
コード例 #7
0
        private static void UpdateXref(HtmlAgilityPack.HtmlNode node, IDocumentBuildContext context, string language)
        {
            var xref = XRefDetails.From(node);

            // Resolve external xref map first, and then internal xref map.
            // Internal one overrides external one
            var xrefSpec = context.GetXrefSpec(xref.Uid);
            xref.ApplyXrefSpec(xrefSpec);

            var convertedNode = xref.ConvertToHtmlNode(language);
            node.ParentNode.ReplaceChild(convertedNode, node);
            if (xrefSpec == null)
            {
                if (xref.ThrowIfNotResolved)
                {
                    throw new CrossReferenceNotResolvedException(xref.Uid, xref.RawSource, null);
                }
            }
        }