Beispiel #1
0
        public void RegisterInternalXrefSpecBookmark(string uid, string bookmark)
        {
            if (uid == null)
            {
                throw new ArgumentNullException(nameof(uid));
            }
            if (uid.Length == 0)
            {
                throw new ArgumentException("Uid cannot be empty", nameof(uid));
            }
            if (bookmark == null)
            {
                throw new ArgumentNullException(nameof(bookmark));
            }
            if (bookmark.Length == 0)
            {
                return;
            }

            if (XRefSpecMap.TryGetValue(uid, out XRefSpec xref))
            {
                xref.Href = UriUtility.GetNonFragment(xref.Href) + "#" + bookmark;
            }
            else
            {
                throw new DocfxException($"Xref spec with uid {uid} not found. Can't register bookmark {bookmark} to it.");
            }
        }
Beispiel #2
0
        public void RegisterInternalXrefSpecBookmark(string uid, string bookmark)
        {
            if (string.IsNullOrEmpty(uid))
            {
                throw new ArgumentNullException(nameof(uid));
            }
            if (bookmark == null)
            {
                throw new ArgumentNullException(nameof(uid));
            }
            if (bookmark == string.Empty)
            {
                return;
            }

            XRefSpec xref;

            if (XRefSpecMap.TryGetValue(uid, out xref))
            {
                xref.Href = UriUtility.GetNonFragment(xref.Href) + "#" + bookmark;
            }
            else
            {
                throw new DocfxException($"Xref spec with uid {uid} not found. Can't register bookmark {bookmark} to it.");
            }
        }
Beispiel #3
0
 public void TestUriUtility(string input, string path, string queryString, string fragment, string queryStringAndFragment, string nonFragment)
 {
     Assert.Equal(path, UriUtility.GetPath(input));
     Assert.Equal(queryString, UriUtility.GetQueryString(input));
     Assert.Equal(fragment, UriUtility.GetFragment(input));
     Assert.Equal(queryStringAndFragment, UriUtility.GetQueryStringAndFragment(input));
     Assert.Equal(nonFragment, UriUtility.GetNonFragment(input));
 }
Beispiel #4
0
        public void ApplyXrefSpec(XRefSpec spec)
        {
            if (spec == null)
            {
                return;
            }

            // TODO: What if href is not html?
            if (!string.IsNullOrEmpty(spec.Href))
            {
                Href = UriUtility.GetNonFragment(spec.Href);
                if (string.IsNullOrEmpty(Anchor))
                {
                    Anchor = UriUtility.GetFragment(spec.Href);
                }
            }
            Spec = spec;
        }
        /// <summary>
        /// Export xref map file.
        /// </summary>
        private static string ExportXRefMap(DocumentBuildParameters parameters, DocumentBuildContext context)
        {
            Logger.LogVerbose("Exporting xref map...");
            var xrefMap = new XRefMap();

            xrefMap.References =
                (from xref in context.XRefSpecMap.Values.AsParallel().WithDegreeOfParallelism(parameters.MaxParallelism)
                 select new XRefSpec(xref)
            {
                Href = ((RelativePath)context.GetFilePath(UriUtility.GetNonFragment(xref.Href))).RemoveWorkingFolder() + UriUtility.GetFragment(xref.Href)
            }).ToList();
            xrefMap.Sort();
            string xrefMapFileNameWithVersion = string.IsNullOrEmpty(parameters.VersionName) ?
                                                XRefMapFileName :
                                                parameters.VersionName + "." + XRefMapFileName;

            YamlUtility.Serialize(
                xrefMapFileNameWithVersion,
                xrefMap,
                YamlMime.XRefMap);
            Logger.LogInfo("XRef map exported.");
            return(xrefMapFileNameWithVersion);
        }