#989 Create configuration docs page

- Create tool task to generate a doc page with the generated config.yml
- Rename tools.utils.FileUtils to FileIoUtils to avoid naming conflict with fr.xephi.authme.utils.FileUtils
- Make all doc tasks output a success message at the end
- Update all docs pages that have changed
This commit is contained in:
ljacqu
2016-10-23 18:29:00 +02:00
parent 9d21a4cda2
commit b7a7d5b3bd
15 changed files with 577 additions and 56 deletions
@@ -6,7 +6,7 @@ import fr.xephi.authme.command.CommandInitializer;
import fr.xephi.authme.command.CommandUtils;
import fr.xephi.authme.permission.PermissionNode;
import tools.utils.AutoToolTask;
import tools.utils.FileUtils;
import tools.utils.FileIoUtils;
import tools.utils.TagValue.NestedTagValue;
import tools.utils.TagValueHolder;
import tools.utils.ToolsConstants;
@@ -29,7 +29,7 @@ public class CommandPageCreater implements AutoToolTask {
NestedTagValue commandTags = new NestedTagValue();
addCommandsInfo(commandTags, baseCommands);
FileUtils.generateFileFromTemplate(
FileIoUtils.generateFileFromTemplate(
ToolsConstants.TOOLS_SOURCE_ROOT + "docs/commands/commands.tpl.md",
OUTPUT_FILE,
TagValueHolder.create().put("commands", commandTags));
@@ -0,0 +1,49 @@
package tools.docs.config;
import com.github.authme.configme.SettingsManager;
import com.github.authme.configme.resource.YamlFileResource;
import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever;
import fr.xephi.authme.util.FileUtils;
import tools.utils.AutoToolTask;
import tools.utils.FileIoUtils;
import tools.utils.TagValueHolder;
import tools.utils.ToolsConstants;
import java.io.File;
import java.io.IOException;
/**
* Task for updating the config docs page.
*/
public class UpdateConfigPageTask implements AutoToolTask {
private static final String TEMPLATE_FILE = ToolsConstants.TOOLS_SOURCE_ROOT + "docs/config/config.tpl.md";
private static final String OUTPUT_FILE = ToolsConstants.DOCS_FOLDER + "config.md";
@Override
public String getTaskName() {
return "updateConfigPage";
}
@Override
public void executeDefault() {
File config = null;
try {
// Create empty temporary .yml file and save the config to it
config = File.createTempFile("authme-config-", ".yml");
SettingsManager settingsManager = new SettingsManager(
new YamlFileResource(config), null, AuthMeSettingsRetriever.buildConfigurationData());
settingsManager.save();
// Get the contents and generate template file
TagValueHolder tagValueHolder = TagValueHolder.create()
.put("config", FileIoUtils.readFromFile(config.toPath()));
FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, OUTPUT_FILE, tagValueHolder);
System.out.println("Wrote to '" + OUTPUT_FILE + "'");
} catch (IOException e) {
throw new IllegalStateException(e);
} finally {
FileUtils.delete(config);
}
}
}
@@ -0,0 +1,16 @@
<!-- {gen_warning} -->
<!-- File auto-generated on {gen_date}. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
with which you can configure various settings. This following is the initial contents of
the generated config.yml file.
```yml
{config}
```
To change settings on a running server, save your changes to config.yml and use
`/authme reload`.
{gen_footer}
@@ -2,7 +2,7 @@ package tools.docs.hashmethods;
import fr.xephi.authme.security.HashAlgorithm;
import tools.utils.AutoToolTask;
import tools.utils.FileUtils;
import tools.utils.FileIoUtils;
import tools.utils.TagValue.NestedTagValue;
import tools.utils.TagValueHolder;
import tools.utils.ToolsConstants;
@@ -28,7 +28,8 @@ public class HashAlgorithmsDescriptionTask implements AutoToolTask {
// Write to the docs file
TagValueHolder tags = TagValueHolder.create().put("algorithms", methodRows);
FileUtils.generateFileFromTemplate(CUR_FOLDER + "hash_algorithms.tpl.md", OUTPUT_FILE, tags);
FileIoUtils.generateFileFromTemplate(CUR_FOLDER + "hash_algorithms.tpl.md", OUTPUT_FILE, tags);
System.out.println("Wrote to '" + OUTPUT_FILE + "'");
}
private static NestedTagValue constructMethodRows(Map<HashAlgorithm, MethodDescription> descriptions) {
@@ -2,7 +2,7 @@ package tools.docs.permissions;
import fr.xephi.authme.ClassCollector;
import fr.xephi.authme.permission.PermissionNode;
import tools.utils.FileUtils;
import tools.utils.FileIoUtils;
import tools.utils.ToolsConstants;
import java.util.EnumSet;
@@ -103,7 +103,7 @@ public class PermissionNodesGatherer {
*/
private static <T extends Enum<T> & PermissionNode> String getSourceForClass(Class<T> clazz) {
String classFile = ToolsConstants.MAIN_SOURCE_ROOT + clazz.getName().replace(".", "/") + ".java";
return FileUtils.readFromFile(classFile);
return FileIoUtils.readFromFile(classFile);
}
}
@@ -1,7 +1,7 @@
package tools.docs.permissions;
import tools.utils.AutoToolTask;
import tools.utils.FileUtils;
import tools.utils.FileIoUtils;
import tools.utils.TagValue.NestedTagValue;
import tools.utils.TagValueHolder;
import tools.utils.ToolsConstants;
@@ -27,9 +27,8 @@ public class PermissionsListWriter implements AutoToolTask {
final NestedTagValue permissionsTagValue = generatePermissionsList();
TagValueHolder tags = TagValueHolder.create().put("nodes", permissionsTagValue);
FileUtils.generateFileFromTemplate(TEMPLATE_FILE, PERMISSIONS_OUTPUT_FILE, tags);
FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, PERMISSIONS_OUTPUT_FILE, tags);
System.out.println("Wrote to '" + PERMISSIONS_OUTPUT_FILE + "'");
System.out.println("Before committing, please verify the output!");
}
private static NestedTagValue generatePermissionsList() {
@@ -3,7 +3,7 @@ package tools.docs.translations;
import com.google.common.collect.ImmutableMap;
import tools.docs.translations.TranslationsGatherer.TranslationInfo;
import tools.utils.AutoToolTask;
import tools.utils.FileUtils;
import tools.utils.FileIoUtils;
import tools.utils.TagValue.NestedTagValue;
import tools.utils.TagValueHolder;
import tools.utils.ToolsConstants;
@@ -57,7 +57,8 @@ public class TranslationPageGenerator implements AutoToolTask {
}
TagValueHolder tags = TagValueHolder.create().put("languages", translationValuesHolder);
FileUtils.generateFileFromTemplate(TEMPLATE_FILE, DOCS_PAGE, tags);
FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, DOCS_PAGE, tags);
System.out.println("Wrote to '" + DOCS_PAGE + "'");
}
/**