6 Tool tasks
ljacqu edited this page 2017-03-24 23:10:08 +01:00

Tool tasks are tasks that can be run from the AuthMe codebase for various purposes, e.g. to generate docs pages or to verify the completeness of translation files. All tool tasks are started from the same runner, the ToolsRunner, located under test/tools/ToolsRunner.java. Tip: you can save the run configuration for the ToolsRunner so that you can easily run a tool task at any time.

Once you start the ToolsRunner, a list of all available tools will be displayed. After entering the name the corresponding task will be run.

Available tasks

Cat Name Description
📎 addJavaDocToMessageEnum Adds a JavaDoc comment to each MessageKey entry with the according English message.
🔦 checkMessageUses Finds message keys which aren't used anywhere
📎 checkTestMocks Checks that test classes' @Mock fields correspond to the tested class' @Inject fields.
📗 createCommandPage Updates the docs/commands.md page.
📗 describeHashAlgos Updates the docs/hash_algorithms.md page.
📎 drawDependencyGraph Generates AuthMe's dependency graph as .dot file - requires GraphWiz to render.
✏️ generateCommandsYml Creates the commands.yml config file with default data.
✏️ generatePluginYml Generates the plugin.yml with up-to-date command and permission info.
📗 updateConfigPage Updates the docs/config.md page.
📗 updateDocs Updates all files in the docs/ folder.
📗 updateTranslations Updates the docs/translations.md page.
🔦 verifyHelpTranslations Verifies all or a specific help translation file in resources/messages.
🔦 verifyMessages Verifies all or a specific messages file in resources/messages.
📗 writePermissionsList Updates the docs/permission_nodes.md page.

Categories

Icon Category
📗 Docs/ page generation
🔦 Verification task
✏️ Project file update
📎 Technical task

Tag replacements

Markdown pages in the docs/ folder are created based on a template file. This template file may contain tags which are replaced with data during the generation process. For example:

A total of {total} commands are available:

[#commands]
- {name}[perm], requires {perm}[/perm]
[/#commands]

Three types of tags are available:

  • Replacement: {total}-like tags will be replaced with the value associated with "total"
  • Conditional: [perm]...[/perm]-like tags are conditional tags. The text inside of the tags is only considered if the value associated with "perm" is not empty (empty string / empty collection)
  • Repeating: tags like [#commands]...[/#commands] will make us iterate over all entries in "commands" and apply replacements to the text within

Values can be associated to tag names with a TagValueHolder. Example:

List<Command> commands = Arrays.asList(
  new Command("/home", ""), new Command("/help", "permission.help"));

NestedTagValue commandsInfo = new NestedTagValue();
for (Command command : commands) {
  TagValueHolder commandValues = TagValueHolder.create()
    .put("name", command.getName())
    .put("perm", command.getPermission());
  commandsInfo.add(commandValues);
}

TagValueHolder tagValues = TagValueHolder.create()
  .put("total", commands.size())
  .put("commands", commandsInfo);

// Generate MD file
FileIoUtils.generateFileFromTemplate("commands.tpl.md", "commands.md", tagValues);

The generated file would look like the following:

A total of 2 commands are available:

- /home
- /help, requires permission.help

The following predefined tags are at your disposal:

  • {gen_date}: generation date (i.e. current date)
  • {gen_warning}: comment warning not to edit the output file directly
  • {gen_footer}: info footer with a link to the repo and the generation date