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: We only need the copyright comments in offline mode. Also, Docgen now removes the copyright comment from the beginning of the embedded tracker HTML snippet.
Date Fri, 01 Jan 2016 21:14:43 GMT
Repository: incubator-freemarker-docgen
Updated Branches:
  refs/heads/master 99cfc0423 -> d096e24da


We only need the copyright comments in offline mode. Also, Docgen now removes the copyright
comment from the beginning of the embedded tracker HTML snippet.


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/d096e24d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/tree/d096e24d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/diff/d096e24d

Branch: refs/heads/master
Commit: d096e24da965a786ac4868cc1d4649bf62a44360
Parents: 99cfc04
Author: ddekany <ddekany@apache.org>
Authored: Fri Jan 1 22:14:27 2016 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Fri Jan 1 22:14:27 2016 +0100

----------------------------------------------------------------------
 src/main/org/freemarker/docgen/Transform.java   | 49 ++++++++++++++------
 .../docgen/templates/eclipse-toc.ftlx           |  2 +-
 .../org/freemarker/docgen/templates/page.ftlh   |  2 +-
 .../freemarker/docgen/templates/sitemap.ftlx    |  2 +-
 .../freemarker/docgen/templates/toc-json.ftl    |  2 +-
 5 files changed, 38 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/blob/d096e24d/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 5bc998d..7fcdb9f 100644
--- a/src/main/org/freemarker/docgen/Transform.java
+++ b/src/main/org/freemarker/docgen/Transform.java
@@ -380,7 +380,9 @@ import freemarker.template.utility.StringUtil;
  *         <li><p><tt>copyrightHolder</tt> (String): Used in the
page footer copyright notice.
  *         <li><p><tt>copyrightCommentFile</tt> (String): The path
of a HTML file to the text used inside
  *         the output files as copyright header comment. If this path is relative, it's relative
to the source
- *         directory.
+ *         directory. Currently, the copyright comment is only inserted if the {@code offline}
mode is {@code true}.
+ *         That's because at ASF currently only the documentation files that are part of
the released archive need
+ *         these comments.
  *       </ul>
  *
  *       <li><p><tt>docgen-templates</tt> directory:
@@ -1048,6 +1050,19 @@ public final class Transform {
                     deployUrl = castSettingToString(cfgFile, settingName, settingValue);
                 } else if (settingName.equals(SETTING_ONLINE_TRACKER_HTML)) {
                     onlineTrackerHTML = getFileContentForSetting(cfgFile, settingName, settingValue);
+                    if (onlineTrackerHTML.startsWith("<!--")) {
+                        int commentEnd = onlineTrackerHTML.indexOf("-->");
+                        if (commentEnd != -1) {
+                            commentEnd += 3;
+                            String comment = onlineTrackerHTML.substring(0, commentEnd);
+                            if (comment.contains("copyright") || comment.contains("Copyright"))
{
+                                onlineTrackerHTML = onlineTrackerHTML.substring(commentEnd);
+                            }
+                        }
+                    }
+                    String eol = TextUtil.detectEOL(onlineTrackerHTML, "\n");
+                    onlineTrackerHTML = onlineTrackerHTML.trim();
+                    onlineTrackerHTML += eol;
                 } else if (settingName.equals(SETTING_REMOVE_NODES_WHEN_ONLINE)) {
                     removeNodesWhenOnline = Collections.unmodifiableSet(new HashSet<String>(
                             castSettingToStringList(cfgFile, settingName, settingValue)));
@@ -1802,7 +1817,7 @@ public final class Transform {
                         + Transform.class.getPackage().getName());
             }
             
-            if (copyrightComment != null && (staticFileName.endsWith(".css") || staticFileName.endsWith(".js")))
{
+            if (staticFileName.endsWith(".css") || staticFileName.endsWith(".js")) {
                 // ISO-8859-1 will be good enough as far as the resource isn't UTF-16 or
EBCDIC:
                 final Charset fileCharset = StandardCharsets.ISO_8859_1;
                 String content = FileUtil.loadString(in, fileCharset);
@@ -1823,14 +1838,16 @@ public final class Transform {
                     }
                     
                     // Include an EOL after the comment, if there's any.
-                    if (commentEnd < content.length()) {
-                        char c = content.charAt(commentEnd);
-                        if (c == '\n') {
-                            commentEnd++;
-                        } else if (c == '\r') {
-                            commentEnd++;
-                            if (commentEnd < content.length() && content.charAt(commentEnd)
== '\n') {
+                    for (int i = 0; i < 2; i++) {
+                        if (commentEnd < content.length()) {
+                            char c = content.charAt(commentEnd);
+                            if (c == '\n') {
                                 commentEnd++;
+                            } else if (c == '\r') {
+                                commentEnd++;
+                                if (commentEnd < content.length() && content.charAt(commentEnd)
== '\n') {
+                                    commentEnd++;
+                                }
                             }
                         }
                     }
@@ -1839,14 +1856,16 @@ public final class Transform {
                     content = content.substring(commentEnd);
                 }
                 
-                // Add copyright comment:
-                StringBuilder sb = new StringBuilder(TextUtil.normalizeEOL(copyrightJavaComment,
eol));
-                sb.append(eol);
-                if (content.length() > 0 && content.charAt(0) != '\n' &&
content.charAt(0) != '\r') {
+                if (offline && copyrightComment != null) {                
+                    // Add copyright comment:
+                    StringBuilder sb = new StringBuilder(TextUtil.normalizeEOL(copyrightJavaComment,
eol));
                     sb.append(eol);
+                    if (content.length() > 0 && content.charAt(0) != '\n' &&
content.charAt(0) != '\r') {
+                        sb.append(eol);
+                    }
+                    sb.append(content);
+                    content = sb.toString();
                 }
-                sb.append(content);
-                content = sb.toString();
                 
                 Path destSubdir = destDir.toPath().resolve("docgen-resources");
                 Files.createDirectories(destSubdir);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/blob/d096e24d/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
----------------------------------------------------------------------
diff --git a/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx b/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
index 6ffb2d9..92028f0 100644
--- a/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
+++ b/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
@@ -1,7 +1,7 @@
 <#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"}>
 <#import "util.ftl" as u>
 <?xml version="1.0" encoding="utf-8"?>
-<#if copyrightComment?hasContent>
+<#if offline && copyrightComment?hasContent>
   <!--<#lt>
   ${copyrightComment}<#lt>
   --><#lt>

http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/blob/d096e24d/src/main/org/freemarker/docgen/templates/page.ftlh
----------------------------------------------------------------------
diff --git a/src/main/org/freemarker/docgen/templates/page.ftlh b/src/main/org/freemarker/docgen/templates/page.ftlh
index fbdfa33..ee8db32 100644
--- a/src/main/org/freemarker/docgen/templates/page.ftlh
+++ b/src/main/org/freemarker/docgen/templates/page.ftlh
@@ -91,7 +91,7 @@
 
 <#macro page>
   <!doctype html><#lt>
-  <#if copyrightComment?hasContent>
+  <#if offline && copyrightComment?hasContent>
     <!--<#lt>
     ${copyrightComment}<#lt>
     --><#lt>

http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/blob/d096e24d/src/main/org/freemarker/docgen/templates/sitemap.ftlx
----------------------------------------------------------------------
diff --git a/src/main/org/freemarker/docgen/templates/sitemap.ftlx b/src/main/org/freemarker/docgen/templates/sitemap.ftlx
index 324b016..c553e77 100644
--- a/src/main/org/freemarker/docgen/templates/sitemap.ftlx
+++ b/src/main/org/freemarker/docgen/templates/sitemap.ftlx
@@ -18,7 +18,7 @@
     </#list>
 </#macro>
 <?xml version="1.0" encoding="UTF-8"?>
-<#if copyrightComment?hasContent>
+<#if offline && copyrightComment?hasContent>
   <!--<#lt>
   ${copyrightComment}<#lt>
   --><#lt>

http://git-wip-us.apache.org/repos/asf/incubator-freemarker-docgen/blob/d096e24d/src/main/org/freemarker/docgen/templates/toc-json.ftl
----------------------------------------------------------------------
diff --git a/src/main/org/freemarker/docgen/templates/toc-json.ftl b/src/main/org/freemarker/docgen/templates/toc-json.ftl
index fdd35cc..66975b6 100644
--- a/src/main/org/freemarker/docgen/templates/toc-json.ftl
+++ b/src/main/org/freemarker/docgen/templates/toc-json.ftl
@@ -1,5 +1,5 @@
 <#import "util.ftl" as u>
-<#if copyrightComment?hasContent>
+<#if offline && copyrightComment?hasContent>
   ${copyrightJavaComment}<#lt>
 </#if>
 <#macro tocNodeToJSON node>


Mime
View raw message