public override async Task Generate(CodeModel serviceClient)
        {
            var apiVersions = serviceClient.Methods
                              .Select(method => method.Parameters.FirstOrDefault(p => p.SerializedName == "api-version")?.DefaultValue.Value)
                              .Concat(new [] { serviceClient.ApiVersion })
                              .Where(each => each != null)
                              .Distinct().ToArray();

            foreach (var version in apiVersions)
            {
                var resourceSchemas = ResourceSchemaParser.Parse(serviceClient, version);

                foreach (string resourceProvider in resourceSchemas.Keys)
                {
                    var stringWriter = new StringWriter();
                    ResourceSchemaWriter.Write(stringWriter, resourceSchemas[resourceProvider]);
                    await Write(stringWriter.ToString(), Path.Combine(version, resourceProvider + ".json"), true);

                    var md = ResourceMarkdownGenerator.Generate(resourceSchemas[resourceProvider]);

                    foreach (var m in md)
                    {
                        var content = m.Content.Replace("\"boolean\"", "boolean");
                        // place nested topics in subdirectories
                        await Write(content, Path.Combine(version, m.Type.Replace('_', Path.DirectorySeparatorChar) + ".md"), false);
                    }
                }
            }
        }
Exemple #2
0
        public override async Task Generate(CodeModel serviceClient)
        {
            IDictionary <string, ResourceSchema> resourceSchemas = ResourceSchemaParser.Parse(serviceClient);

            foreach (string resourceProvider in resourceSchemas.Keys)
            {
                StringWriter stringWriter = new StringWriter();
                ResourceSchemaWriter.Write(stringWriter, resourceSchemas[resourceProvider]);
                await Write(stringWriter.ToString(), resourceProvider + Path.DirectorySeparatorChar + resourceProvider + ".json", true);

                stringWriter = new StringWriter();
                var md = ResourceMarkdownGenerator.Generate(resourceSchemas[resourceProvider]);

                foreach (var m in md)
                {
                    var content = m.Content.Replace("\"boolean\"", "boolean");
                    await Write(content, EnsureUniqueFileName(resourceProvider, m.Type + ".md"), false);
                }
            }
        }
        public static Markdown[] Generate(ResourceSchema resourceSchema)
        {
            if (resourceSchema == null)
            {
                throw new ArgumentNullException("resourceSchema");
            }

            var mds   = new Markdown[resourceSchema.ResourceDefinitions.Keys.Count];
            int index = 0;

            foreach (var resDefName in resourceSchema.ResourceDefinitions.Keys)
            {
                var resDef = resourceSchema.ResourceDefinitions[resDefName];

                var writer   = new StringWriter();
                var mdWriter = new ResourceMarkdownGenerator(writer, resourceSchema);
                mdWriter.Generate(resDef);

                mds[index] = new Markdown(resDefName, writer.ToString());
                ++index;
            }

            return(mds);
        }