From fe60a38de58b61deae24b0eaef36a4336dde6e34 Mon Sep 17 00:00:00 2001 From: Stian Grenborgen Date: Sat, 17 Sep 2022 09:31:48 +0200 Subject: [PATCH] This fixes automatic generation of specification documentation. Resource URI keys are now supported. Location of the resource directory has been updated. --- doc/specification.xsl | 6 +++--- .../freecol/tools/GenerateDocumentation.java | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/specification.xsl b/doc/specification.xsl index 9cbd49dc7..0761192c8 100644 --- a/doc/specification.xsl +++ b/doc/specification.xsl @@ -83,7 +83,7 @@ -
+
@@ -494,7 +494,7 @@
- +
  • @@ -731,7 +731,7 @@ -
    +
    diff --git a/src/net/sf/freecol/tools/GenerateDocumentation.java b/src/net/sf/freecol/tools/GenerateDocumentation.java index ffaeb0c24..37b512076 100644 --- a/src/net/sf/freecol/tools/GenerateDocumentation.java +++ b/src/net/sf/freecol/tools/GenerateDocumentation.java @@ -47,10 +47,9 @@ import net.sf.freecol.common.util.Utils; */ public class GenerateDocumentation { - private static final File STRING_DIRECTORY = - new File("data/strings"); - private static final File RULE_DIRECTORY = - new File("data/rules/classic"); + private static final File STRING_DIRECTORY = new File("data/strings"); + private static final File RESOURCE_DIRECTORY = new File("data/default"); + private static final File RULE_DIRECTORY = new File("data/rules/classic"); private static final String XSL = "specification.xsl"; private static final File DESTINATION_DIRECTORY = @@ -81,7 +80,7 @@ public class GenerateDocumentation { private static void readResources() { System.out.println("Processing source file: resources.properties"); - File sourceFile = new File(RULE_DIRECTORY, "resources.properties"); + File sourceFile = new File(RESOURCE_DIRECTORY, "resources.properties"); try ( Reader reader = Utils.getFileUTF8Reader(sourceFile); BufferedReader bufferedReader = new BufferedReader(reader); @@ -228,13 +227,19 @@ public class GenerateDocumentation { String found = resources.get(ourKey); if (found == null && splitKey.length > 2 && "model".equals(splitKey[0])) { - String suffix = ("tile".equals(splitKey[1])) ? ".center.r0" : ""; + String suffix = ("tile".equals(splitKey[1])) ? ".center" : ""; options[0] = splitKey[1]; options[1] = splitKey[1] + "icon"; for (String x : options) { ourKey = "image." + x + "." + key + suffix; found = resources.get(ourKey); - if (found != null) break; + if (found != null) { + final String resourcePrefix = "resource:"; + if (found.startsWith(resourcePrefix)) { + found = resources.get(found.substring(resourcePrefix.length())); + } + break; + } } } return found;