Beispiel #1
0
        private async Task AddDocumentToUrls(string prefix, Project project, DocumentWithoutDetails document,
                                             List <string> documentUrls)
        {
            var navigationNodes = await GetNavigationNodesAsync(project, document);

            AddDocumentUrls(prefix, navigationNodes, documentUrls, project, document);
        }
Beispiel #2
0
        private string NormalizePath(string prefix, string path, string shortName, DocumentWithoutDetails document)
        {
            var pathWithoutFileExtension = RemoveFileExtensionFromPath(path, document.Format);

            var normalizedPathStringBuilder = new StringBuilder();

            normalizedPathStringBuilder.Append(prefix).Append(document.LanguageCode).Append("/").Append(shortName)
            .Append("/").Append(document.Version).Append("/").Append(pathWithoutFileExtension);

            return(normalizedPathStringBuilder.ToString());
        }
Beispiel #3
0
 private void AddDocumentUrls(string prefix,
                              List <NavigationNode> navigationNodes,
                              List <string> documentUrls,
                              Project project,
                              DocumentWithoutDetails document)
 {
     navigationNodes?.ForEach(node =>
     {
         documentUrls.AddIfNotContains(
             GetDocumentLinks(node, documentUrls, prefix, project.ShortName, document)
             );
     });
 }
Beispiel #4
0
        private List <string> GetDocumentLinks(NavigationNode node, List <string> documentUrls, string prefix,
                                               string shortName, DocumentWithoutDetails document)
        {
            if (!IsExternalLink(node.Path))
            {
                documentUrls.AddIfNotContains(
                    NormalizePath(prefix, node.Path, shortName, document)
                    );
            }

            node.Items?.ForEach(childNode =>
            {
                GetDocumentLinks(childNode, documentUrls, prefix, shortName, document);
            });

            return(documentUrls);
        }
Beispiel #5
0
        private async Task <List <NavigationNode> > GetNavigationNodesAsync(Project project,
                                                                            DocumentWithoutDetails document)
        {
            var version            = GetProjectVersionPrefixIfExist(project) + document.Version;
            var navigationDocument = await GetDocumentWithDetailsDtoAsync(
                project,
                project.NavigationDocumentName,
                document.LanguageCode,
                version
                );

            if (!DocsJsonSerializerHelper.TryDeserialize <NavigationNode>(navigationDocument.Content,
                                                                          out var navigationNode))
            {
                throw new UserFriendlyException(
                          $"Cannot validate navigation file '{project.NavigationDocumentName}' for the project {project.Name}.");
            }

            return(navigationNode.Items);
        }