|
18 | 18 | # under the License. |
19 | 19 | # |
20 | 20 |
|
21 | | -pushd "$(dirname $0)/.." > /dev/null |
22 | | - |
23 | | -NOCLEAN= |
24 | | - |
25 | | -DRYRUN= |
26 | | -DRYRUN_DOCS= |
27 | | -FULLRUN_DOCS= |
28 | | - |
29 | | -makeAbsPaths () { |
30 | | - for doc in $(tr ',' $'\n' <<< "$1"); do |
31 | | - if [ -d $doc ]; then |
32 | | - for d in $(find "$doc" -name "*.asciidoc"); do |
33 | | - echo $(cd $(dirname "$d") && pwd -P)/$(basename "$d") |
34 | | - done |
35 | | - else |
36 | | - echo $(cd $(dirname "$doc") && pwd -P)/$(basename "$doc") |
37 | | - fi |
38 | | - done | paste -sd ',' - |
39 | | -} |
40 | | - |
41 | | -while [[ $# -gt 0 ]] |
42 | | -do |
43 | | - key="$1" |
44 | | - case $key in |
45 | | - -n|--noClean) |
46 | | - NOCLEAN=1 |
47 | | - shift |
48 | | - ;; |
49 | | - -d|--dryRun) |
50 | | - DRYRUN=1 |
51 | | - shift |
52 | | - if [[ $# -gt 0 ]] && [[ $1 != -* ]]; then |
53 | | - DRYRUN_DOCS=$(makeAbsPaths "$1") |
54 | | - shift |
55 | | - else |
56 | | - DRYRUN_DOCS="*" |
57 | | - fi |
58 | | - ;; |
59 | | - -f|--fullRun) |
60 | | - DRYRUN=1 |
61 | | - DRYRUN_DOCS=${DRYRUN_DOCS:-"*"} |
62 | | - shift |
63 | | - FULLRUN_DOCS=$(makeAbsPaths "$1") |
64 | | - shift |
65 | | - ;; |
66 | | - *) |
67 | | - # unknown option |
68 | | - shift |
69 | | - ;; |
70 | | - esac |
71 | | -done |
72 | | - |
73 | | -if [ -z ${NOCLEAN} ]; then |
74 | | - rm -rf ~/.groovy/grapes/org.apache.tinkerpop/ |
75 | | - if hash hadoop 2> /dev/null; then |
76 | | - hadoop fs -rm -r "hadoop-gremlin-*-libs" > /dev/null 2>&1 |
77 | | - fi |
78 | | -fi |
79 | | - |
80 | | -if [ ${DRYRUN} ] && [ "${DRYRUN_DOCS}" == "*" ] && [ -z "${FULLRUN_DOCS}" ]; then |
81 | | - |
82 | | - mkdir -p target/postprocess-asciidoc/tmp |
83 | | - cp -R docs/{static,stylesheets} target/postprocess-asciidoc/ |
84 | | - cp -R docs/src/. target/postprocess-asciidoc/ |
85 | | - ec=$? |
86 | | - |
87 | | -else |
88 | | - |
89 | | - GEPHI_MOCK= |
| 21 | +# Builds TinkerPop documentation using the gremlin-docs AsciidoctorJ extension. |
| 22 | +# This bypasses the old AWK preprocessing pipeline and processes [gremlin-*] blocks |
| 23 | +# directly during Asciidoctor rendering. |
| 24 | +# |
| 25 | +# Usage: |
| 26 | +# bin/process-docs-new.sh # full build with live gremlin execution |
| 27 | +# bin/process-docs-new.sh --dry-run # skip gremlin execution (fast, for layout checks) |
90 | 28 |
|
91 | | - trap cleanup EXIT |
| 29 | +set -e |
92 | 30 |
|
93 | | - function cleanup() { |
94 | | - [ ${GEPHI_MOCK} ] && kill ${GEPHI_MOCK} |
95 | | - } |
| 31 | +PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| 32 | +cd "${PROJECT_ROOT}" |
96 | 33 |
|
97 | | - nc -z localhost 8080 || ( |
98 | | - bin/gephi-mock.py > /dev/null 2>&1 & |
99 | | - GEPHI_MOCK=$! |
100 | | - ) |
| 34 | +TP_VERSION=$(cat pom.xml | grep -A1 '<artifactId>tinkerpop</artifactId>' | grep '<version>' | sed -e 's/.*<version>//' -e 's/<\/version>.*//') |
101 | 35 |
|
102 | | - docs/preprocessor/preprocess.sh "${DRYRUN_DOCS}" "${FULLRUN_DOCS}" |
103 | | - ec=$? |
| 36 | +if [ -z "${TP_VERSION}" ]; then |
| 37 | + echo "ERROR: Could not determine TinkerPop version from pom.xml" |
| 38 | + exit 1 |
104 | 39 | fi |
105 | 40 |
|
106 | | -if [ $ec -eq 0 ]; then |
107 | | - mvn process-resources -Dasciidoc && docs/postprocessor/postprocess.sh |
108 | | - ec=$? |
| 41 | +ASCIIDOC_ATTRS="" |
| 42 | +if [ "$1" = "--dry-run" ]; then |
| 43 | + ASCIIDOC_ATTRS="-Dasciidoctor.attributes.gremlin-docs-dryrun=true" |
| 44 | + echo "Dry-run mode: gremlin blocks will not be executed" |
109 | 45 | fi |
110 | 46 |
|
111 | | -popd > /dev/null |
| 47 | +echo "Building docs for TinkerPop ${TP_VERSION}..." |
| 48 | +echo "Source: docs/src/" |
| 49 | +echo "Output: target/docs/htmlsingle/" |
| 50 | + |
| 51 | +# build and install the gremlin-docs extension (not part of the main reactor) |
| 52 | +echo "Installing gremlin-docs extension..." |
| 53 | +mvn install -f gremlin-docs/pom.xml -DskipTests -Denforcer.skip=true -q |
| 54 | + |
| 55 | +# copy static assets that live outside docs/src/ into the staging area |
| 56 | +# (Maven's copy-docs-to-work-area handles docs/src/ itself) |
| 57 | +mkdir -p target/doc-source |
| 58 | +cp -r docs/static target/doc-source/ 2>/dev/null || true |
| 59 | +cp -r docs/stylesheets target/doc-source/ 2>/dev/null || true |
| 60 | + |
| 61 | +# set up conf/hadoop so GraphFactory.open('conf/hadoop/...') resolves during build |
| 62 | +mkdir -p conf/hadoop |
| 63 | +cp hadoop-gremlin/conf/* conf/hadoop/ 2>/dev/null || true |
| 64 | + |
| 65 | +# run asciidoctor with the gremlin-docs extension, pointing at raw sources |
| 66 | +mvn process-resources \ |
| 67 | + -Dasciidoc \ |
| 68 | + -Drat.skip=true \ |
| 69 | + ${ASCIIDOC_ATTRS} |
| 70 | + |
| 71 | +# clean up |
| 72 | +rm -rf conf/hadoop |
| 73 | +rmdir conf 2>/dev/null || true |
| 74 | + |
| 75 | +# post-process: replace version placeholder |
| 76 | +echo "Post-processing: replacing x.y.z with ${TP_VERSION}..." |
| 77 | +find target/docs/htmlsingle -name '*.html' | while IFS= read -r f; do |
| 78 | + sed "s/x\.y\.z/${TP_VERSION}/g" "$f" > "$f.tmp" && mv "$f.tmp" "$f" |
| 79 | +done |
112 | 80 |
|
113 | | -exit ${ec} |
| 81 | +echo "Done. Output in target/docs/htmlsingle/" |
0 commit comments