sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1713329 - in /sis/branches/JDK8/core/sis-build-helper/src/main: java/org/apache/sis/internal/book/ resources/org/apache/sis/internal/book/
Date Mon, 09 Nov 2015 00:33:32 GMT
Author: desruisseaux
Date: Mon Nov  9 00:33:31 2015
New Revision: 1713329

URL: http://svn.apache.org/viewvc?rev=1713329&view=rev
Log:
Developer-guide generator: allow word break in some <code>...</code> expressions,
and add some keywords to recognize.

Modified:
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
    sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
    sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
    sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/SIS.lst

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java?rev=1713329&r1=1713328&r2=1713329&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
[UTF-8] Mon Nov  9 00:33:31 2015
@@ -75,6 +75,13 @@ public final class Assembler {
     private static final String LINE_SEPARATOR = "\n";
 
     /**
+     * Minimal number of characters in a Java identifier before to allows a line break before
the next identifier.
+     * This value if used in expressions like {@code foo.bar()} for deciding whether or not
we accept line break
+     * between {@code foo} and {@code .bar()}.
+     */
+    private static final int MINIMAL_LENGTH_BEFORE_BREAK = 3;
+
+    /**
      * The directory of all input files to process.
      */
     private final File inputDirectory;
@@ -318,6 +325,10 @@ public final class Assembler {
                                 ((Element) node).setAttribute("class", style);
                             }
                         }
+                        String text = insertWordSeparator(node.getTextContent());
+                        if (text != null) {
+                            node.setTextContent(text);
+                        }
                         return; // Do not scan recursively the <code> text content.
                     }
                     default: {
@@ -467,6 +478,48 @@ public final class Assembler {
     }
 
     /**
+     * Allows word break before the code in expression like {@code Class.method()}.
+     * If there is nothing to change in the given text, returns {@code null}.
+     */
+    private static String insertWordSeparator(String text) {
+        StringBuilder buffer = null;
+        for (int i=text.length() - 1; --i > MINIMAL_LENGTH_BEFORE_BREAK;) {
+            if (text.charAt(i) == '.' && Character.isJavaIdentifierStart(text.charAt(i+1)))
{
+                final char b = text.charAt(i-1);
+                if (Character.isJavaIdentifierPart(b) || b == ')') {
+                    /*
+                     * Verifiy if the element to eventually put on the next line is a call
to a method.
+                     * For now we split only calls to method for avoiding to split for example
every
+                     * elements in a package name.
+                     */
+                    for (int j=i; ++j < text.length();) {
+                        final char c = text.charAt(j);
+                        if (!Character.isJavaIdentifierPart(c)) {
+                            if (c == '(') {
+                                /*
+                                 * Found a call to a method. But we also require the word
before it
+                                 * to have more than 3 letters.
+                                 */
+                                for (j = i; Character.isJavaIdentifierPart(text.charAt(--j));)
{
+                                    if (j == i - MINIMAL_LENGTH_BEFORE_BREAK) {
+                                        if (buffer == null) {
+                                            buffer = new StringBuilder(text);
+                                        }
+                                        buffer.insert(i, '\u200B');     // Zero-width space.
+                                        break;
+                                    }
+                                }
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        return (buffer != null) ? buffer.toString() : null;
+    }
+
+    /**
      * Inserts a line separator just before the given node.
      */
     private void insertLineSeparator(final Node insertionPoint) {

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst?rev=1713329&r1=1713328&r2=1713329&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
[UTF-8] Mon Nov  9 00:33:31 2015
@@ -115,6 +115,7 @@ LegalConstraints
 Lineage
 LinearCS
 LogicalConsistency
+Matrix
 MaintenanceFrequency
 MaintenanceInformation
 MathTransform

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst?rev=1713329&r1=1713328&r2=1713329&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
[UTF-8] Mon Nov  9 00:33:31 2015
@@ -233,3 +233,4 @@ SV_OperationChainMetadata
 SV_OperationMetadata
 SV_ParameterDirection
 SV_ServiceIdentification
+TOWGS84

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/SIS.lst
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/SIS.lst?rev=1713329&r1=1713328&r2=1713329&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/SIS.lst
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/SIS.lst
[UTF-8] Mon Nov  9 00:33:31 2015
@@ -1,5 +1,7 @@
+AbstractMathTransform
 AngleFormat
 DefaultEllipsoid
+DefaultGeodeticDatum
 DefaultMetadata
 Envelopes
 GeneralEnvelope



Mime
View raw message