This fixes automatic generation of specification documentation. Resource URI keys are now supported. Location of the resource directory has been updated.

This commit is contained in:
Stian Grenborgen 2022-09-17 09:31:48 +02:00
parent dd2094cae1
commit fe60a38de5
2 changed files with 15 additions and 10 deletions

View File

@ -83,7 +83,7 @@
<xsl:variable name="id" select="@made-from"/> <xsl:variable name="id" select="@made-from"/>
<xsl:variable name="src" <xsl:variable name="src"
select="freecol:getResource(@made-from)"/> select="freecol:getResource(@made-from)"/>
<img src="../data/rules/classic/{$src}"/><br /> <img src="../data/default/{$src}"/><br />
<a href="#{$id}"> <a href="#{$id}">
<xsl:value-of select="freecol:localize(concat(@made-from, '.name'))"/> <xsl:value-of select="freecol:localize(concat(@made-from, '.name'))"/>
</a> </a>
@ -494,7 +494,7 @@
<xsl:template match="settlement"> <xsl:template match="settlement">
<div class="center"> <div class="center">
<xsl:variable name="src" select="freecol:getResource(@id)"/> <xsl:variable name="src" select="freecol:getResource(@id)"/>
<img src="../data/rules/classic/{$src}"/> <img src="../data/default/{$src}"/>
</div> </div>
<ul> <ul>
<li> <li>
@ -731,7 +731,7 @@
<xsl:variable name="src" select="freecol:getResource($id)"/> <xsl:variable name="src" select="freecol:getResource($id)"/>
<td class="name"> <td class="name">
<a id="{$id}"> <a id="{$id}">
<img src="../data/rules/classic/{$src}"/><br /> <img src="../data/default/{$src}"/><br />
<xsl:value-of select="freecol:localize(concat($id, '.name'))"/> <xsl:value-of select="freecol:localize(concat($id, '.name'))"/>
</a> </a>
</td> </td>

View File

@ -47,10 +47,9 @@ import net.sf.freecol.common.util.Utils;
*/ */
public class GenerateDocumentation { public class GenerateDocumentation {
private static final File STRING_DIRECTORY = private static final File STRING_DIRECTORY = new File("data/strings");
new File("data/strings"); private static final File RESOURCE_DIRECTORY = new File("data/default");
private static final File RULE_DIRECTORY = private static final File RULE_DIRECTORY = new File("data/rules/classic");
new File("data/rules/classic");
private static final String XSL = "specification.xsl"; private static final String XSL = "specification.xsl";
private static final File DESTINATION_DIRECTORY = private static final File DESTINATION_DIRECTORY =
@ -81,7 +80,7 @@ public class GenerateDocumentation {
private static void readResources() { private static void readResources() {
System.out.println("Processing source file: resources.properties"); 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 ( try (
Reader reader = Utils.getFileUTF8Reader(sourceFile); Reader reader = Utils.getFileUTF8Reader(sourceFile);
BufferedReader bufferedReader = new BufferedReader(reader); BufferedReader bufferedReader = new BufferedReader(reader);
@ -228,13 +227,19 @@ public class GenerateDocumentation {
String found = resources.get(ourKey); String found = resources.get(ourKey);
if (found == null && splitKey.length > 2 if (found == null && splitKey.length > 2
&& "model".equals(splitKey[0])) { && "model".equals(splitKey[0])) {
String suffix = ("tile".equals(splitKey[1])) ? ".center.r0" : ""; String suffix = ("tile".equals(splitKey[1])) ? ".center" : "";
options[0] = splitKey[1]; options[0] = splitKey[1];
options[1] = splitKey[1] + "icon"; options[1] = splitKey[1] + "icon";
for (String x : options) { for (String x : options) {
ourKey = "image." + x + "." + key + suffix; ourKey = "image." + x + "." + key + suffix;
found = resources.get(ourKey); 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; return found;