freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker-docgen git commit: olink setting now supports targets with "id:" URL schema.
Date Sat, 19 Dec 2015 16:20:02 GMT
Repository: incubator-freemarker-docgen
Updated Branches:
  refs/heads/master d158a56b3 -> 3f34f5638


olink setting now supports targets with "id:" URL schema.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/commit/3f34f563
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/tree/3f34f563
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/diff/3f34f563

Branch: refs/heads/master
Commit: 3f34f5638f0a26a7d80396fd8c45607aa1b9bc96
Parents: d158a56
Author: ddekany <ddekany@apache.org>
Authored: Sat Dec 19 17:19:47 2015 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Sat Dec 19 17:19:47 2015 +0100

----------------------------------------------------------------------
 src/main/org/freemarker/docgen/Transform.java | 29 +++++++++-------------
 1 file changed, 12 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/blob/3f34f563/src/main/org/freemarker/docgen/Transform.java
----------------------------------------------------------------------
diff --git a/src/main/org/freemarker/docgen/Transform.java b/src/main/org/freemarker/docgen/Transform.java
index 42613e0..c1c6e21 100644
--- a/src/main/org/freemarker/docgen/Transform.java
+++ b/src/main/org/freemarker/docgen/Transform.java
@@ -230,9 +230,8 @@ import freemarker.template.utility.StringUtil;
  *            for canonical URL-s)
  *         <li><p><tt>olinks</tt> (map):
  *            Maps <tt>olink</tt> <tt>targetdoc</tt> attribute values
to
- *            actual URL-s. The target URL can also be like <tt>olink:<i>someOlinkName<i></tt>,
in which case it
- *            will be an alias to another olink (which can also be a further reference and
so on, and can be defined
- *            both after or before the referring olink).
+ *            actual URL-s. The target URL can also be an "olink:" or "id:" URL, and the
result of resolving that can
+ *            also be further such URL, and so on.
  *         <li><p><tt>validation</tt> (map):
  *            This is where you can configure the optional Docgen-specific
  *            DocBook validation restrictions. Accepted map entries are:
@@ -883,19 +882,6 @@ public final class Transform {
                                 cfgFile, settingName, ent.getValue());
                         olinks.put(name, target);
                     }
-                    // Resolve "olink:"-s:
-                    boolean hadSubstitutions;
-                    do {
-                        hadSubstitutions = false;
-                        for (Map.Entry<String, String> ent : olinks.entrySet()) {
-                            String value = ent.getValue();
-                            String resolvedValue = resolveDocgenURL(SETTING_OLINKS, value);
-                            if (value != resolvedValue) {
-                                ent.setValue(resolvedValue);
-                                hadSubstitutions = true;
-                            }
-                        }
-                    } while (hadSubstitutions);
                 } else if (settingName.equals(SETTING_INTERNAL_BOOKMARKS)) {
                     Map<String, Object> m = castSettingToMap(
                             cfgFile, settingName, settingValue);
@@ -1256,6 +1242,12 @@ public final class Transform {
         preprocessDOM(doc);
 
         // Resolve Docgen URL schemes in setting values:
+        // Olinks must come first:
+        if (olinks != null) {
+            for (Entry<String, String> olinkEnt : olinks.entrySet()) {
+                olinkEnt.setValue(resolveDocgenURL(SETTING_OLINKS, olinkEnt.getValue()));
+            }
+        }
         if (tabs != null) {
             for (Entry<String, String> tabEnt : tabs.entrySet()) {
                 tabEnt.setValue(resolveDocgenURL(SETTING_TABS, tabEnt.getValue()));
@@ -1542,7 +1534,7 @@ public final class Transform {
                         + StringUtil.jQuote(settingName)
                         + ": " + StringUtil.jQuote(oLinkName));
             }
-            return resolvedOLink;
+            return resolveDocgenURL(settingName, resolvedOLink);
         } else if (url.startsWith(ID_SCHEMA_START)) {
             String id = url.substring(ID_SCHEMA_START.length());
             try {
@@ -2861,6 +2853,9 @@ public final class Transform {
     };
 
     private String createLinkFromId(String id) throws DocgenException {
+        if (elementsById == null) {
+            throw new IllegalStateException("Can't resolve ID as elementsById is still null:
" + id);
+        }
         Element elem = elementsById.get(id);
         if (elem == null) {
             throw new DocgenException(


Mime
View raw message