class ConfigOptionsDocGenerator {

	@VisibleForTesting
	static void generateCommonSection(String rootDir, String outputDirectory, OptionsClassLocation[] locations, String pathPrefix) throws IOException, ClassNotFoundException {
		List<OptionWithMetaInfo> commonOptions = new ArrayList<>(32);
		for (OptionsClassLocation location : locations) {
			commonOptions.addAll(findCommonOptions(rootDir, location.getModule(), location.getPackage(), pathPrefix));
		}
		commonOptions.sort((o1, o2) -> {
			int position1 = o1.field.getAnnotation(Documentation.CommonOption.class).position();
			int position2 = o2.field.getAnnotation(Documentation.CommonOption.class).position();
			if (position1 == position2) {
				return o1.option.key().compareTo(o2.option.key());
			} else {
				return Integer.compare(position1, position2);
			}
		});

		String commonHtmlTable = toHtmlTable(commonOptions);
		Files.write(Paths.get(outputDirectory, COMMON_SECTION_FILE_NAME), commonHtmlTable.getBytes(StandardCharsets.UTF_8));
	}

	private  ConfigOptionsDocGenerator();

}