Esempio n. 1
0
        private void AssignDiscussionIds(TableOfContents.TableOfContentsItem tocItem, string sourceDirectory, string version)
        {
            AssignDiscussionIdsInDocsFile(tocItem, sourceDirectory);
            var sourceDiscussionId = GetSourceDiscussionId(tocItem, sourceDirectory);

            AssignDiscussionIdToDerivedPages(tocItem, version, sourceDiscussionId);
        }
        public static string GetDirectoryPath(this TableOfContents.TableOfContentsItem tableOfContentsItem, string version, ParserOptions parserOptions)
        {
            var documentationPagesDirectory = parserOptions.GetPathToDocumentationPagesDirectory(version);
            var filePath = Path.Combine(documentationPagesDirectory, tableOfContentsItem.Key);

            return(Directory.GetParent(filePath).FullName);
        }
Esempio n. 3
0
        private IEnumerable <FolderItem> GetPagesForTocItem(TableOfContents.TableOfContentsItem tocItem, string directory)
        {
            var matchingFolderItem = GetFolderItemForTocItem(directory, tocItem);

            var pages = GetPages(directory, matchingFolderItem);

            foreach (var folderItem in pages)
            {
                yield return(folderItem);
            }
        }
Esempio n. 4
0
        public TableOfContents.TableOfContentsItem ConvertToTableOfContentsItem(TableOfContentsCompiler.CompilationResult compilationResult)
        {
            var tocItem = new TableOfContents.TableOfContentsItem
            {
                Key           = compilationResult.Key,
                Title         = compilationResult.Title,
                SourceVersion = compilationResult.SourceVersion,
                IsFolder      = compilationResult.IsFolder,
                Languages     = compilationResult.Languages
            };

            return(tocItem);
        }
Esempio n. 5
0
        private void AssignDiscussionIdsInDocsFile(TableOfContents.TableOfContentsItem tocItem, string directory, string discussionId = null)
        {
            var matchingFolderItem = GetFolderItemForTocItem(directory, tocItem);

            if (matchingFolderItem == null)
            {
                return;
            }

            var docsFilePath = Path.Combine(directory, Constants.DocumentationFileName);

            DocumentationFileHelper.AssignDiscussionIdIfNeeded(docsFilePath, matchingFolderItem, discussionId);
        }
Esempio n. 6
0
        private FolderItem GetFolderItemForTocItem(string directory, TableOfContents.TableOfContentsItem tocItem)
        {
            var docsFilePath = Path.Combine(directory, Constants.DocumentationFileName);

            if (File.Exists(docsFilePath) == false)
            {
                return(null);
            }

            var keySuffix = tocItem.GetKeySuffix();

            var matchingFolderItem = DocumentationFileHelper.ParseFile(docsFilePath)
                                     .SingleOrDefault(x => x.Name == keySuffix);

            return(matchingFolderItem);
        }
Esempio n. 7
0
        private static void GenerateForFolder(HtmlHelper htmlHelper, UrlHelper urlHelper, StringBuilder builder, TableOfContents.TableOfContentsItem item, string key, int level, bool containsKey, string version, DocumentationMode mode)
        {
            if (mode == DocumentationMode.Legacy)
            {
                builder.AppendLine(string.Format("<a href='{0}'>", urlHelper.Action(MVC.Docs.ActionNames.Articles, MVC.Docs.Name, new { version = version, language = Language.Csharp, key = item.Key })));
            }

            builder.AppendLine(string.Format("<span class='fa fa-folder {1}'></span><span>{0}</span>", item.Title, containsKey ? "text-danger" : string.Empty));

            if (mode == DocumentationMode.Legacy)
            {
                builder.AppendLine("</a>");
            }

            builder.AppendLine("<ul class='list-group'>");

            GenerateTableOfContents(htmlHelper, urlHelper, builder, item.Items, key, ++level, version, mode);

            builder.AppendLine("</ul>");
        }
Esempio n. 8
0
        private static void GenerateForArticle(HtmlHelper htmlHelper, StringBuilder builder, TableOfContents.TableOfContentsItem item)
        {
            var link = htmlHelper.ActionLink(item.Title, MVC.Docs.ActionNames.Articles, MVC.Docs.Name, new { key = item.Key }, null).ToHtmlString();

            builder.AppendLine(string.Format("<span class='fa fa-file-text-o'></span>{0}", link));
        }
        public static string GetSourceBaseDirectory(this TableOfContents.TableOfContentsItem tableOfContentsItem, ParserOptions parserOptions)
        {
            var version = tableOfContentsItem.SourceVersion;

            return(GetDirectoryPath(tableOfContentsItem, version, parserOptions));
        }
Esempio n. 10
0
        private void AssignDiscussionIdToDerivedPages(TableOfContents.TableOfContentsItem tocItem, string version, string sourceDiscussionId)
        {
            var directory = tocItem.GetDirectoryPath(version, Options);

            AssignDiscussionIdsInDocsFile(tocItem, directory, sourceDiscussionId);
        }
Esempio n. 11
0
        private string GetSourceDiscussionId(TableOfContents.TableOfContentsItem tocItem, string directory)
        {
            var matchingFolderItem = GetFolderItemForTocItem(directory, tocItem);

            return(matchingFolderItem.DiscussionId);
        }