StorytellerDocGen.Outline.OutlineWriter.WriteToFiles C# (CSharp) Method

WriteToFiles() public static method

public static WriteToFiles ( string directory, Topic topLevel ) : void
directory string
topLevel StorytellerDocGen.Topics.Topic
return void
        public static void WriteToFiles(string directory, Topic topLevel)
        {
            if (!FileSystem.DirectoryExists(directory))
            {
                FileSystem.CreateDirectory(directory);
            }

            var file = directory.AppendPath("index.md");
            WriteTopicFile(file, topLevel);

            WriteOrderFile(directory, topLevel);

            topLevel.Children.Each(child =>
            {
                var key = child.KeyWithinParent;

                if (child.Children.Any())
                {
                    WriteToFiles(directory.AppendPath(key), child);
                }
                else
                {
                    var childFile = directory.AppendPath(key + ".md");
                    WriteTopicFile(childFile, child);
                }
            });
        }