Ejemplo n.º 1
0
        private void ParseDocumentation(Folder folder, ClientType currentLanguage)
        {
            var fullFolderSlug = Path.Combine(folder.Trail, folder.Slug ?? string.Empty);
            var fullPath       = Path.Combine(this.destinationFullPath, fullFolderSlug);

            if (!File.Exists(Path.Combine(fullPath, DocsListFileName)))
            {
                return;
            }

            var languagesToProces = new List <ClientType>();

            if (folder.Multilanguage)
            {
                languagesToProces.AddRange(SupportedLanguages);
            }
            else
            {
                languagesToProces.Add(currentLanguage);
            }

            foreach (var language in languagesToProces)
            {
                var docs = DocsListParser.Parse(Path.Combine(fullPath, DocsListFileName), folder).ToArray();
                foreach (var item in docs)
                {
                    item.Language = language;

                    if (item.Slug != null)
                    {
                        item.Slug = item.Slug.TrimStart('\\', '/');
                    }

                    item.Trail        = Path.Combine(folder.Trail, folder.Slug ?? string.Empty);
                    item.VirtualTrail = Path.Combine(folder.VirtualTrail, folder.Slug ?? string.Empty);

                    if (language != ClientType.None && !item.VirtualTrail.Contains(language.ToString()))
                    {
                        item.VirtualTrail = Path.Combine(item.VirtualTrail, language.ToString());
                    }

                    var document = item as Document;
                    if (document != null)
                    {
                        continue;
                    }

                    var subFolder = item as Folder;
                    if (subFolder != null)
                    {
                        ParseDocumentation(subFolder, language);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process item as markdown.
        /// </summary>
        /// <param name="folder">
        /// The folder.
        /// </param>
        /// <param name="versionUrl">
        /// The version url.
        /// </param>
        /// <param name="fullPath">
        /// The full path.
        /// </param>
        /// <param name="fullFolderSlug">
        /// The full folder slug.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        private string ProcessAsMarkdown(Folder folder, string versionUrl, string fullPath, string fullFolderSlug)
        {
            var output = string.Empty;

            output += this.ProcessIndexItem(folder, versionUrl, fullPath, fullFolderSlug);

            var docs = DocsListParser.Parse(Path.Combine(fullPath, DocsListFileName)).ToArray();

            foreach (var item in docs)
            {
                Console.WriteLine("CompileFolder - processing item {0}", item.Trail);
                output += this.ProcessItem(folder, versionUrl, item, fullPath);
            }

            this.CopyImages(folder, fullPath);
            return(output);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes item as HTML.
        /// </summary>
        /// <param name="folder">
        /// The folder.
        /// </param>
        /// <param name="versionUrl">
        /// The version url.
        /// </param>
        /// <param name="fullPath">
        /// The full path.
        /// </param>
        /// <param name="fullFolderSlug">
        /// The full folder slug.
        /// </param>
        private void ProcessAsHtml(Folder folder, string versionUrl, string fullPath, string fullFolderSlug)
        {
            var docs = DocsListParser.Parse(Path.Combine(fullPath, DocsListFileName)).ToArray();

            foreach (var item in docs)
            {
                Console.WriteLine("CompileFolder - processing item {0}", item.Trail);
                this.ProcessItem(folder, versionUrl, item, fullPath);
            }

            var contents = DocumentationParser.Parse(
                this,
                folder,
                Path.Combine(fullPath, "index.markdown"),
                string.IsNullOrWhiteSpace(folder.Trail) ? folder.Slug : folder.Trail + "/" + folder.Slug,
                versionUrl);

            this.Output.SaveDocItem(
                new Document {
                Title = folder.Title, Content = contents, Trail = fullFolderSlug, Slug = "index"
            });

            this.CopyImages(folder, fullPath);
        }
Ejemplo n.º 4
0
        private void CompileFolder(Folder folder)
        {
            var fullFolderSlug = Path.Combine(folder.Trail, folder.Slug ?? string.Empty);
            var fullPath       = Path.Combine(_fullPath, fullFolderSlug);

            if (!File.Exists(Path.Combine(fullPath, DocsListFileName)))
            {
                return;
            }

            var docs = DocsListParser.Parse(Path.Combine(fullPath, DocsListFileName)).ToArray();

            foreach (var item in docs)
            {
                if (item.Slug != null)
                {
                    item.Slug = item.Slug.TrimStart('\\', '/');
                }
                item.Trail = Path.Combine(folder.Trail, folder.Slug ?? string.Empty);
                folder.Items.Add(item);

                var document = item as Document;
                if (document != null)
                {
                    var strippedSlug = document.Slug.Replace(".markdown", string.Empty);
                    document.Content = DocumentationParser.Parse(this, null, Path.Combine(fullPath, document.Slug), document.Trail);
                    document.Slug    = strippedSlug;
                    Output.SaveDocItem(document);
                    continue;
                }

                var subFolder = item as Folder;
                if (subFolder != null)
                {
                    CompileFolder(subFolder);
                    continue;
                }
            }

            var contents = DocumentationParser.Parse(this, folder, Path.Combine(fullPath, "index.markdown"),
                                                     string.IsNullOrWhiteSpace(folder.Trail) ? folder.Slug : folder.Trail + "/" + folder.Slug
                                                     );

            Output.SaveDocItem(new Document
            {
                Title   = folder.Title,
                Content = contents,
                Trail   = fullFolderSlug,
                Slug    = "index"
            });

            // Copy images
            var imagesPath = Path.Combine(fullPath, "images");

            if (Directory.Exists(imagesPath))
            {
                var images = Directory.GetFiles(imagesPath);
                foreach (var image in images)
                {
                    var imageFileName = Path.GetFileName(image);
                    if (imageFileName == null)
                    {
                        continue;
                    }
                    Output.SaveImage(folder, image);
                }
            }
        }