コード例 #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }
            var          path     = args[0];
            var          folder   = Path.GetDirectoryName(path);
            string       fileName = "demo";
            HtmlDocument doc      = new HtmlDocument();

            doc.Load(path);
            var detailsInfo = new DetailsInfo();

            detailsInfo.Name      = GetName(doc);
            detailsInfo.Authors   = GetAuthor(doc);
            detailsInfo.Resources = ProcessResources(doc);
            detailsInfo.Wrap      = GetWrapMode(doc);
            var saveFolder = folder + "/" + Path.GetFileNameWithoutExtension(path) + "/";

            if (!Directory.Exists(saveFolder))
            {
                Directory.CreateDirectory(saveFolder);
            }
            WriteDetails(detailsInfo, saveFolder, fileName);
            CreateHTML(doc, saveFolder, fileName);
            CreateJS(doc, saveFolder, fileName);
            CreateCSS(doc, saveFolder, fileName);
        }
コード例 #2
0
        private static void WriteDetails(DetailsInfo detailsInfo, string folder, string name)
        {
            var           fullPath = folder + name + ".details";
            StringBuilder builder  = new StringBuilder();

            builder.AppendLine("/*");
            builder.AppendLine("---");
            builder.AppendLine(string.Format("name: {0}", detailsInfo.Name));
            builder.AppendLine("authors:");
            builder.AppendLine(string.Format("  - {0}", detailsInfo.Authors));
            builder.AppendLine("resources:");
            foreach (string item in detailsInfo.Resources)
            {
                builder.AppendLine(string.Format("  - {0}", item));
            }
            builder.AppendLine(string.Format("wrap: {0}", detailsInfo.Wrap));
            builder.AppendLine("...");
            builder.AppendLine("*/");
            File.WriteAllText(fullPath, builder.ToString());
        }