Exemplo n.º 1
0
 private MetadataJsonConfig ParseOptions(MetadataCommandOptions options)
 {
     string configFile;
     if (TryGetJsonConfig(options.Projects, out configFile))
     {
         var config = CommandUtility.GetConfig<MetadataConfig>(configFile).Item;
         if (config == null) throw new DocumentException($"Unable to find metadata subcommand config in file '{configFile}'.");
         config.BaseDirectory = Path.GetDirectoryName(configFile);
         config.OutputFolder = options.OutputFolder;
         foreach (var item in config)
         {
             item.Raw |= options.PreserveRawInlineComments;
             item.Force |= options.ForceRebuild;
             item.FilterConfigFile = options.FilterConfigFile ?? item.FilterConfigFile;
         }
         return config;
     }
     else
     {
         var config = new MetadataJsonConfig();
         config.Add(new MetadataJsonItemConfig
         {
             Force = options.ForceRebuild,
             Destination = options.OutputFolder,
             Raw = options.PreserveRawInlineComments,
             Source = new FileMapping(new FileMappingItem(options.Projects.ToArray())) { Expanded = true },
             FilterConfigFile = options.FilterConfigFile
         });
         return config;
     }
 }
Exemplo n.º 2
0
 private MetadataJsonConfig ParseOptions(MetadataCommandOptions options)
 {
     string configFile;
     if (TryGetJsonConfig(options.Projects, out configFile))
     {
         var config = CommandUtility.GetConfig<MetadataConfig>(configFile).Item;
         if (config == null) throw new DocumentException($"Unable to find metadata subcommand config in file '{configFile}'.");
         config.BaseDirectory = Path.GetDirectoryName(configFile);
         config.OutputFolder = options.OutputFolder;
         foreach (var item in config)
         {
             item.Raw |= options.PreserveRawInlineComments;
             item.Force |= options.ForceRebuild;
             item.ShouldSkipMarkup |= options.ShouldSkipMarkup;
             item.FilterConfigFile = options.FilterConfigFile ?? item.FilterConfigFile;
         }
         return config;
     }
     else
     {
         var config = new MetadataJsonConfig();
         config.Add(new MetadataJsonItemConfig
         {
             Force = options.ForceRebuild,
             ShouldSkipMarkup = options.ShouldSkipMarkup,
             Destination = options.OutputFolder,
             Raw = options.PreserveRawInlineComments,
             Source = new FileMapping(new FileMappingItem(options.Projects.ToArray())) { Expanded = true },
             FilterConfigFile = options.FilterConfigFile
         });
         return config;
     }
 }
Exemplo n.º 3
0
        private MetadataJsonConfig ParseOptions(MetadataCommandOptions options)
        {
            MetadataJsonConfig config;

            string configFile;

            if (TryGetJsonConfig(options.Projects, out configFile))
            {
                config = CommandUtility.GetConfig <MetadataConfig>(configFile).Item;
                if (config == null)
                {
                    throw new DocumentException($"Unable to find metadata subcommand config in file '{configFile}'.");
                }
                config.BaseDirectory = Path.GetDirectoryName(configFile);
            }
            else
            {
                config = new MetadataJsonConfig();
                config.Add(new MetadataJsonItemConfig
                {
                    Destination = options.OutputFolder,
                    Source      = new FileMapping(new FileMappingItem(options.Projects.ToArray()))
                    {
                        Expanded = true
                    }
                });
            }

            var msbuildProperties = ResolveMSBuildProperties(options);

            foreach (var item in config)
            {
                item.Force            |= options.ForceRebuild;
                item.Raw              |= options.PreserveRawInlineComments;
                item.ShouldSkipMarkup |= options.ShouldSkipMarkup;
                if (!string.IsNullOrEmpty(options.FilterConfigFile))
                {
                    item.FilterConfigFile = Path.GetFullPath(options.FilterConfigFile);
                }

                if (!string.IsNullOrEmpty(options.GlobalNamespaceId))
                {
                    item.GlobalNamespaceId = options.GlobalNamespaceId;
                }

                if (item.MSBuildProperties == null)
                {
                    item.MSBuildProperties = msbuildProperties;
                }
                else
                {
                    // Command line properties overwrites the one defined in docfx.json
                    foreach (var pair in msbuildProperties)
                    {
                        item.MSBuildProperties[pair.Key] = pair.Value;
                    }
                }
            }

            config.OutputFolder = options.OutputFolder;

            return(config);
        }
Exemplo n.º 4
0
 private static MetadataJsonConfig GetConfigFromOptions(MetadataCommandOptions options)
 {
     string jsonConfig;
     // Glob pattern is not allowed for command line options
     if (TryGetJsonConfig(options.Projects, out jsonConfig))
     {
         var command = (MetadataCommand)CommandFactory.ReadConfig(jsonConfig, null).Commands.FirstOrDefault(s => s is MetadataCommand);
         if (command == null) throw new DocumentException($"Unable to find {CommandType.Build} subcommand config in file '{Constants.ConfigFileName}'.");
         var config = command.Config;
         config.BaseDirectory = Path.GetDirectoryName(jsonConfig);
         config.OutputFolder = options.OutputFolder;
         foreach (var item in config)
         {
             item.Raw |= options.PreserveRawInlineComments;
             item.Force |= options.ForceRebuild;
         }
         return config;
     }
     else
     {
         var config = new MetadataJsonConfig();
         config.Add(new MetadataJsonItemConfig
         {
             Force = options.ForceRebuild,
             Destination = options.OutputFolder,
             Raw = options.PreserveRawInlineComments,
             Source = new FileMapping(new FileMappingItem() { Files = new FileItems(options.Projects) }) { Expanded = true }
         });
         return config;
     }
 }