Пример #1
0
        private string LanguageSelector(string outputfile)
        {
            var languages = AvailableLanguages.Get();
            var sb        = new StringBuilder();

            sb.Append(@"<select id='languageselector' onclick='window.open(languageselector.options[languageselector.selectedIndex].value)'>");
            foreach (var lang in languages)
            {
                string selectedstr = lang == _language ? "selected='selected';" : "";
                sb.AppendFormat("<option value='../{0}/{2}' {3}>{1}</option>", lang.ToLower(), lang, Path.GetFileName(outputfile), selectedstr);
            }
            sb.Append("</select>");
            return(sb.ToString());
        }
Пример #2
0
        static void Main(string[] args)
        {
            var rootDirName = DocumentationRoot();

            Console.WriteLine("RootDirName: " + rootDirName);

            var englishinputdir = rootDirName + "/content/english/book";

            foreach (var lang in AvailableLanguages.Get())
            {
                var inputdir = rootDirName + "/content/" + lang + "/book/";
                var pages    = new List <BookPage>();

                var tocBuilder = new TOCBuilder(File.ReadAllText(rootDirName + "/content/toc.yaml"));

                var outputDir = OutputDir(lang);
                foreach (var file in Directory.GetFiles(englishinputdir, "*.md"))
                {
                    var    languagefile = inputdir + "/" + Path.GetFileName(file);
                    string filecontents;
                    bool   usingEnglishAsFallback = !File.Exists(languagefile);

                    string filetouse = usingEnglishAsFallback ? file : languagefile;

                    var page       = new BookPage(filetouse, lang, usingEnglishAsFallback);
                    var outputfile = outputDir + Path.GetFileName(Path.GetFileNameWithoutExtension(file)) + ".html";
                    pages.Add(page);
                    page.WriteAsHtml(outputfile, tocBuilder);
                }

                CopyNonMDFilesFrom(englishinputdir, outputDir);
                CopyNonMDFilesFrom(inputdir, outputDir);

                File.Copy(DocumentationRoot() + "/layout/book.css", outputDir + "/book.css", true);
            }
        }