tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [8/9] tinkerpop git commit: Added automatic tab generation for code snippets in asciidoc files.
Date Thu, 21 Dec 2017 15:16:49 GMT
Added automatic tab generation for code snippets in asciidoc files.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c4d71187
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c4d71187
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c4d71187

Branch: refs/heads/TINKERPOP-1447
Commit: c4d71187da5945767e834d594e62c2c01b73e9c4
Parents: e042879
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Fri Dec 15 14:30:59 2017 -0700
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Thu Dec 21 08:15:47 2017 -0700

----------------------------------------------------------------------
 docs/postprocessor/processor.awk     |   4 +
 docs/preprocessor/awk/tabify.awk     | 108 ++++++++++++++++++
 docs/preprocessor/preprocess-file.sh |   3 +-
 docs/sass/compile                    |  30 +++++
 docs/sass/tabs.scss                  | 178 ++++++++++++++++++++++++++++++
 docs/stylesheets/tabs.css            |  19 ++++
 6 files changed, 341 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4d71187/docs/postprocessor/processor.awk
----------------------------------------------------------------------
diff --git a/docs/postprocessor/processor.awk b/docs/postprocessor/processor.awk
index e640273..7f9d420 100644
--- a/docs/postprocessor/processor.awk
+++ b/docs/postprocessor/processor.awk
@@ -33,6 +33,10 @@ BEGIN {
   }
 }
 
+/<body/ {
+  print "<link rel=\"stylesheet\" href=\"/docs/x.y.z/stylesheets/tabs.css\" />"
+}
+
 !/<span class="comment">/ {
   if (firstMatch || !isHeader) {
     print gensub(/(<b class="conum">)\(([0-9]+)\)(<\/b>)/,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4d71187/docs/preprocessor/awk/tabify.awk
----------------------------------------------------------------------
diff --git a/docs/preprocessor/awk/tabify.awk b/docs/preprocessor/awk/tabify.awk
new file mode 100644
index 0000000..bc8d644
--- /dev/null
+++ b/docs/preprocessor/awk/tabify.awk
@@ -0,0 +1,108 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+# @author Daniel Kuppitz (http://gremlin.guru)
+#
+function print_tabs(next_id, tabs, blocks) {
+
+  num_tabs = length(tabs)
+  x = next_id
+
+  print "++++"
+  print "<section class=\"tabs tabs-" num_tabs "\">"
+
+  for (i in tabs) {
+    title = tabs[i]
+    print "  <input id=\"tab-" id_part "-" x "\" type=\"radio\" name=\"radio-set-" id_part
"-" next_id "\" class=\"tab-selector-" i "\"" (i == 1 ? " checked=\"checked\"" : "") " />"
+    print "  <label for=\"tab-" id_part "-" x "\" class=\"tab-label-" i "\">" title
"</label>"
+    x++
+  }
+
+  for (i in blocks) {
+    print "  <div class=\"tabcontent\">"
+    print "    <div class=\"tabcontent-" i "\">"
+    print "++++\n"
+    print blocks[i]
+    print "++++"
+    print "    </div>"
+    print "  </div>"
+  }
+
+  print "</section>"
+  print "++++\n"
+}
+
+BEGIN {
+  id_part=systime()
+  status = 0
+  next_id = 1
+  block[0] = 0 # initialize "blocks" as an array
+  delete blocks[0]
+}
+
+/^\[gremlin-/ {
+  status = 1
+  lang = gensub(/^\[gremlin-([^,\]]+).*/, "\\1", "g", $0)
+  code = ""
+}
+
+/^\[source,/ {
+  if (status == 3) {
+    status = 1
+    lang = gensub(/^\[source,([^\]]+).*/, "\\1", "g", $0)
+    code = ""
+  }
+}
+
+! /^\[source,/ {
+  if (status == 3 && $0 != "") {
+    print_tabs(next_id, tabs, blocks)
+    next_id = next_id + length(tabs)
+    for (i in tabs) {
+      delete tabs[i]
+      delete blocks[i]
+    }
+    status = 0
+  }
+}
+
+/^----$/ {
+  if (status == 1) {
+    status = 2
+  } else if (status == 2) {
+    status = 3
+  }
+}
+
+{ if (status == 3) {
+    if ($0 == "----") {
+      i = length(blocks) + 1
+      if (i == 1) {
+        tabs[i] = "console (" lang ")"
+        blocks[i] = code_header code "\n" $0 "\n"
+        i++
+      }
+      tabs[i] = lang
+      blocks[i] = "[source," lang "]" code "\n" $0 "\n"
+    }
+  } else {
+    if (status == 0) print
+    else if (status == 1) code_header = $0
+    else code = code "\n" $0
+  }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4d71187/docs/preprocessor/preprocess-file.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/preprocess-file.sh b/docs/preprocessor/preprocess-file.sh
index 0ca534a..33608d1 100755
--- a/docs/preprocessor/preprocess-file.sh
+++ b/docs/preprocessor/preprocess-file.sh
@@ -129,6 +129,7 @@ if [ ! ${SKIP} ] && [ $(grep -c '^\[gremlin' ${input}) -gt 0 ];
then
   fi
 
   sed 's/\t/    /g' ${input} |
+  awk -f ${AWK_SCRIPTS}/tabify.awk |
   awk -f ${AWK_SCRIPTS}/prepare.awk |
   awk -f ${AWK_SCRIPTS}/init-code-blocks.awk -v TP_HOME="${TP_HOME}" -v PYTHONPATH="${TP_HOME}/gremlin-python/target/classes/Lib"
|
   awk -f ${AWK_SCRIPTS}/progressbar.awk -v tpl=${AWK_SCRIPTS}/progressbar.groovy.template
|
@@ -139,7 +140,7 @@ if [ ! ${SKIP} ] && [ $(grep -c '^\[gremlin' ${input}) -gt 0 ];
then
   ${lb} awk -f ${AWK_SCRIPTS}/language-variants.awk > ${output}
 
   ps=(${PIPESTATUS[@]})
-  for i in {0..6}; do
+  for i in {0..7}; do
     ec=${ps[i]}
     [ ${ec} -eq 0 ] || break
   done

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4d71187/docs/sass/compile
----------------------------------------------------------------------
diff --git a/docs/sass/compile b/docs/sass/compile
new file mode 100755
index 0000000..002954e
--- /dev/null
+++ b/docs/sass/compile
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+DIR=`dirname $0`
+
+IF="${DIR}/tabs.scss"
+OF="${DIR}/../stylesheets/tabs.css"
+TF=`mktemp`
+
+scss --sourcemap=none -t compressed -C ${IF} ${OF}
+
+cat ${DIR}/../stylesheets/tinkerpop.css | awk 'BEGIN {p=1} {if (p) print} /\*\// {p=0}' |
cat - ${OF} > ${TF} && mv ${TF} ${OF}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4d71187/docs/sass/tabs.scss
----------------------------------------------------------------------
diff --git a/docs/sass/tabs.scss b/docs/sass/tabs.scss
new file mode 100644
index 0000000..39c88f4
--- /dev/null
+++ b/docs/sass/tabs.scss
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+$blue: #3f6b9d;
+$orange: #e08f24;
+$white: #fefefe;
+$black: #1a1a1a;
+$gray: #eee;
+
+$active: #609060;
+$inactive: #e9ffe9;
+
+$tabHeight: 50px;
+$minTabs: 2;
+$maxTabs: 4;
+
+@mixin single-transition($property:all, $speed:150ms, $ease:ease, $delay: 0s) {
+  -webkit-transition: $property $speed $ease $delay;  
+  transition: $property $speed $ease $delay;
+}
+
+.tabs {
+
+  position: relative;
+  margin: 40px auto;
+  width: 1024px;
+  max-width: 100%;
+  overflow: hidden;
+  padding-top: 10px;
+  margin-bottom: 60px;
+
+  input  {
+    position: absolute;
+    z-index: 1000;
+    height: $tabHeight;
+    left: 0;
+    top: 0;
+    opacity: 0;
+    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+    filter: alpha(opacity=0);
+    cursor: pointer;
+    margin: 0;
+    &:hover + label {
+      background: $orange;
+    }
+  }
+
+  label {
+    background: $inactive;
+    color: $black;
+    font-size: 15px;
+    line-height: $tabHeight;
+    height: $tabHeight + 10;
+    position: relative;
+    top: 0;
+    padding: 0 20px;
+    float: left;
+    display: block;
+    letter-spacing: 1px;
+    text-transform: uppercase;
+    font-weight: bold;
+    text-align: center;
+    box-shadow: 2px 0 2px rgba(0,0,0,0.1), -2px 0 2px rgba(0,0,0,0.1);
+    box-sizing: border-box;
+    @include single-transition();
+    &:hover{
+      cursor: pointer;
+    }
+    &:after {
+      content: '';
+      background: $active;
+      position: absolute;
+      bottom: -2px;
+      left: 0;
+      width: 100%;
+      height: 2px;
+      display: block;
+    }
+  }  
+}
+
+@for $n from $minTabs through $maxTabs {
+
+  .tabs-#{$n} {
+
+    input {
+      width: 100% / $n;
+      @for $i from 1 through $n {
+        &.tab-selector-#{$i}{
+          left: ($i - 1) * (100% / $n);
+        }
+      }
+    }
+
+    label {
+      width: 100% / $n;
+    }
+  }
+}
+
+.tabs label:first-of-type {
+  z-index: 4;
+}
+.tab-label-2 {
+  z-index: 4;
+}
+.tab-label-3 {
+  z-index: 3;
+}
+.tab-label-4 {
+  z-index: 2;
+}
+
+.tabs input:checked + label {
+  background: $active;
+  color: $white;
+  z-index: 6;
+}
+
+.clear-shadow {
+  clear: both;
+}
+
+.tabcontent {
+  height: auto;
+  width: 100%;
+  float: left;
+  position: relative;
+  z-index: 5;
+  background: $gray;
+  top: -10px;
+  box-sizing: border-box;
+  &>div{
+    position: relative;
+    float: left;
+    width: 0;
+    height: 0;
+    box-sizing: border-box;
+    top: 0;
+    left: 0;
+    z-index: 1;
+    opacity: 0;
+    background: $gray;
+  }
+  .CodeRay {
+    background-color: $white;
+  }
+}
+
+@for $i from 1 through $maxTabs {
+  .tabs .tab-selector-#{$i}:checked ~ .tabcontent .tabcontent-#{$i} {
+    z-index: 100;
+    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
+    filter: alpha(opacity=100);
+    opacity: 1;
+    width: 100%;
+    height: auto;
+    width: 100%;
+    height: auto;
+    padding-top: 30px;
+  }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4d71187/docs/stylesheets/tabs.css
----------------------------------------------------------------------
diff --git a/docs/stylesheets/tabs.css b/docs/stylesheets/tabs.css
new file mode 100644
index 0000000..df508b7
--- /dev/null
+++ b/docs/stylesheets/tabs.css
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+.tabs{position:relative;margin:40px auto;width:1024px;max-width:100%;overflow:hidden;padding-top:10px;margin-bottom:60px}.tabs
input{position:absolute;z-index:1000;height:50px;left:0;top:0;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);cursor:pointer;margin:0}.tabs
input:hover+label{background:#e08f24}.tabs label{background:#e9ffe9;color:#1a1a1a;font-size:15px;line-height:50px;height:60px;position:relative;top:0;padding:0
20px;float:left;display:block;letter-spacing:1px;text-transform:uppercase;font-weight:bold;text-align:center;box-shadow:2px
0 2px rgba(0,0,0,0.1),-2px 0 2px rgba(0,0,0,0.1);box-sizing:border-box;-webkit-transition:all
150ms ease 0s;transition:all 150ms ease 0s}.tabs label:hover{cursor:pointer}.tabs label:after{content:'';background:#609060;position:absolute;bottom:-2px;left:0;width:100%;height:2px;display:block}.tabs-2
input{width:50%}.tabs-2 input.tab-selector-1{left:0%}.tabs-2 input.tab-selector-2{left:50%}.tabs-
 2 label{width:50%}.tabs-3 input{width:33.33333%}.tabs-3 input.tab-selector-1{left:0%}.tabs-3
input.tab-selector-2{left:33.33333%}.tabs-3 input.tab-selector-3{left:66.66667%}.tabs-3 label{width:33.33333%}.tabs-4
input{width:25%}.tabs-4 input.tab-selector-1{left:0%}.tabs-4 input.tab-selector-2{left:25%}.tabs-4
input.tab-selector-3{left:50%}.tabs-4 input.tab-selector-4{left:75%}.tabs-4 label{width:25%}.tabs
label:first-of-type{z-index:4}.tab-label-2{z-index:4}.tab-label-3{z-index:3}.tab-label-4{z-index:2}.tabs
input:checked+label{background:#609060;color:#fefefe;z-index:6}.clear-shadow{clear:both}.tabcontent{height:auto;width:100%;float:left;position:relative;z-index:5;background:#eee;top:-10px;box-sizing:border-box}.tabcontent>div{position:relative;float:left;width:0;height:0;box-sizing:border-box;top:0;left:0;z-index:1;opacity:0;background:#eee}.tabcontent
.CodeRay{background-color:#fefefe}.tabs .tab-selector-1:checked ~ .tabcontent .tabcontent-1{z-index:100;-ms-filter:"progid:DXImag
 eTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;width:100%;height:auto;width:100%;height:auto;padding-top:30px}.tabs
.tab-selector-2:checked ~ .tabcontent .tabcontent-2{z-index:100;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;width:100%;height:auto;width:100%;height:auto;padding-top:30px}.tabs
.tab-selector-3:checked ~ .tabcontent .tabcontent-3{z-index:100;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;width:100%;height:auto;width:100%;height:auto;padding-top:30px}.tabs
.tab-selector-4:checked ~ .tabcontent .tabcontent-4{z-index:100;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);opacity:1;width:100%;height:auto;width:100%;height:auto;padding-top:30px}


Mime
View raw message