From 783741143a72e6b212f109b2e7d85baa55b1b134 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Fri, 7 Apr 2017 10:05:47 +0200 Subject: [PATCH] KEYCLOAK-4424 Add shared scripts and book-product.json to toplevel --- README.md | 10 ++- SUMMARY.adoc | 2 +- authorization_services/SUMMARY.adoc | 2 +- book-product.json | 105 ++++++++++++++++++++++++++ book.json | 1 - build-product.sh | 69 ++++++++++++++++- getting_started/SUMMARY.adoc | 2 +- gitlab-conversion.py | 111 ++++++++++++++++++++++++++++ securing_apps/SUMMARY.adoc | 2 +- server_admin/SUMMARY.adoc | 2 +- server_development/SUMMARY.adoc | 2 +- server_installation/SUMMARY.adoc | 2 +- 12 files changed, 297 insertions(+), 13 deletions(-) create mode 100755 book-product.json create mode 100755 gitlab-conversion.py diff --git a/README.md b/README.md index 72b8754d29..a0e418f80e 100755 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Keycloak is the basis of [Red Hat Single Sign-On](https://access.redhat.com/prod To build the documentation for RH-SSO go into the directory of the specific guide you want to build. For example to build Server Admin guide run: cd server_admin - python gitlab-conversion.py + python ../gitlab-conversion.py cd target asciidoctor master.adoc @@ -46,6 +46,14 @@ On Linux you can also run build-product.sh DIR. For example: ./build-product.sh server_admin +Or build all guides with: + + ./build-product.sh + +If you have ccutil available you can build the guides with: + + ./build-product.sh -u + You can then view the documentation by opening server_admin/target/master.html This will not create documentation that looks exactly as the official Red Hat Single Sign-On documentation, but the content will be the same. diff --git a/SUMMARY.adoc b/SUMMARY.adoc index 90c9b61048..bfffeffeb2 100644 --- a/SUMMARY.adoc +++ b/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Keycloak Documentation . link:getting_started/README.adoc[Getting Started] {% include "./getting_started/SUMMARY.adoc" %} diff --git a/authorization_services/SUMMARY.adoc b/authorization_services/SUMMARY.adoc index b6ec94fd7c..aea324acf6 100755 --- a/authorization_services/SUMMARY.adoc +++ b/authorization_services/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Authorization Services Guide .. link:authorization_services/topics/overview/overview.adoc[Overview] diff --git a/book-product.json b/book-product.json new file mode 100755 index 0000000000..f68042115f --- /dev/null +++ b/book-product.json @@ -0,0 +1,105 @@ +{ + "gitbook": "2.x.x", + "structure": { + "readme": "OVERVIEW.adoc" + }, + "plugins": [ + "toggle-chapters", + "ungrey", + "splitter", + "ga" + ], + "pluginsConfig": { + "ga": { + "token": "UA-86203452-1" + } + }, + + "variables": { + "project": { + "name": "Red Hat Single Sign-On", + "version": "SNAPSHOT", + "versionMvn": "SNAPSHOT", + "versionNpm": "SNAPSHOT", + "doc_base_url": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/", + "doc_info_version_url": "7.1" + }, + "community": false, + "product": true, + "images": "rhsso-images", + + "adminguide": { + "name": "Server Administration", + "link": "https://keycloak.gitbooks.io/documentation/content/server_admin/index.html" + }, + "developerguide": { + "name": "Server Development", + "link": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/SNAPSHOT/html-single/server-developer-guide/" + }, + "installguide": { + "name": "Server Installation and Configuration", + "link": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/SNAPSHOT/html-single/server-installation-and-configuration-guide/" + }, + "adapterguide": { + "name": "Securing Applications and Services Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/SNAPSHOT/html-single/securing-applications-and-services-guide/" + }, + "gettingstarted": { + "name": "Getting Started Tutorial", + "link": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/SNAPSHOT/html/getting-started-guide/" + }, + "apidocs": { + "name": "API Documentation", + "link": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/SNAPSHOT/html-single/api-documentation/" + }, + + "quickstartRepo": { + "name": "Keycloak Quickstarts Repository", + "link": "https://github.com/keycloak/keycloak-quickstarts", + "dir": "keycloak-quickstarts" + }, + + "fuseVersion": "JBoss Fuse 6.3.0 Rollup 1", + + "appserver": { + "name": "JBoss EAP", + "version": "7.0", + "admindoc": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/configuration-guide" + }, + "datasource": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/#datasource_management" + }, + "network": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/#network_and_port_configuration" + }, + "socket": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/#network_and_port_configuration" + }, + "loadbalancer": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/#configuring_high_availability" + }, + "jgroups": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/#cluster_communication_jgroups" + }, + "caching": { + "name": "JBoss EAP Configuration Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/configuration-guide/#infinispan" + }, + "jpa": { + "name": "JBoss EAP Development Guide", + "link": "https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/html-single/development-guide/#hibernate" + } + }, + + "subsystem": { + "undertow": "urn:jboss:domain:undertow:3.1" + } + } +} diff --git a/book.json b/book.json index 69bba6f91b..5c2e536c03 100755 --- a/book.json +++ b/book.json @@ -16,7 +16,6 @@ }, "variables": { - "title": "Keycloak Documentation", "project": { "name": "Keycloak", "version": "SNAPSHOT", diff --git a/build-product.sh b/build-product.sh index 5ae14d81bf..de65905738 100755 --- a/build-product.sh +++ b/build-product.sh @@ -1,9 +1,70 @@ #!/bin/bash +TOOL="asciidoctor" + +while getopts "h?auc" opt; do + case "$opt" in + h|\?) + echo "Usage: build-guide.sh [OPTION] [GUIDE]" + echo "" + echo " -a use asciidoctor (default)" + echo " -u use ccutil" + echo " -c delete built guides" + echo "" + echo "If guide is not specified all guides are built. GUIDE should be the directory" + echo "name of the specific guide to build." + exit 0 + ;; + a) TOOL="asciidoctor" + ;; + u) TOOL="ccutil" + ;; + c) TOOL="clean" + ;; + esac +done + +shift $((OPTIND-1)) +[ "$1" = "--" ] && shift + GUIDE=$1 -cd $GUIDE -python gitlab-conversion.py -cd target -asciidoctor master.adoc +function buildGuide +{ + GUIDE=$1 + CURRENT_DIRECTORY=$(pwd) + echo "***********************************************************************************************************" + echo "$TOOL: $GUIDE" + echo "" + + cd $GUIDE + rm -rf build + rm -rf target + + python ../gitlab-conversion.py + + if [ "$TOOL" = "asciidoctor" ]; then + asciidoctor -dbook -a toc -o target/master.html target/master.adoc + echo "" + echo "Built file://$CURRENT_DIRECTORY/$GUIDE/target/master.html" + fi + + if [ "$TOOL" = "ccutil" ]; then + ccutil compile --lang en_US --format html-single --main-file target/master.adoc + echo "" + echo "Built file://$CURRENT_DIRECTORY/$GUIDE/build/tmp/en-US/html-single/index.html" + fi + + cd .. +} + +if [ "$GUIDE" = "" ]; then + for i in authorization_services getting_started securing_apps server_admin server_development server_installation; do + buildGuide $i + done +else + buildGuide $GUIDE +fi + +echo "***********************************************************************************************************" diff --git a/getting_started/SUMMARY.adoc b/getting_started/SUMMARY.adoc index 363f4ba386..49bbb6e23f 100755 --- a/getting_started/SUMMARY.adoc +++ b/getting_started/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Getting Started Guide .. link:getting_started/topics/overview.adoc[Overview] .. link:getting_started/topics/first-boot.adoc[Installing and Booting] diff --git a/gitlab-conversion.py b/gitlab-conversion.py new file mode 100755 index 0000000000..180a47a3c8 --- /dev/null +++ b/gitlab-conversion.py @@ -0,0 +1,111 @@ +import sys, os, re, json, shutil, errno + +def transform(root, f, targetdir): + full = os.path.join(root, f) + input = open(full, 'r').read() + dir = os.path.join(targetdir, root) + if not os.path.exists(dir): + os.makedirs(dir) + output = open(os.path.join(dir, f), 'w') + input = applyTransformation(input) + output.write(input) + + +def applyTransformation(input): + for variable in re.findall(r"\{\{(.*?)\}\}", input): + tmp = variable.replace('.', '_') + input = input.replace(variable, tmp) + input = input.replace('{{', '{').replace('}}', '}') + input = re.sub(r"<}==true]\g<2>endif::[]", input) + input = re.sub(r"image:(\.\./)*", "image:", input) + input = re.sub(r"image::(\.\./)*", "image::", input) + return input + + +indir = 'topics' +targetdir = 'target' +if len(sys.argv) > 1: + targetdir = sys.argv[1] + +if os.path.exists(targetdir): + shutil.rmtree(targetdir) + +if os.path.isdir('images'): + shutil.copytree('images',os.path.join(targetdir, 'images')) +if os.path.isdir('keycloak-images'): + shutil.copytree('keycloak-images',os.path.join(targetdir, 'keycloak-images')) +if os.path.isdir('rhsso-images'): + shutil.copytree('rhsso-images',os.path.join(targetdir, 'rhsso-images')) + +shutil.copyfile('metadata.ini', os.path.join(targetdir, 'metadata.ini')); +shutil.copyfile('master-docinfo.xml', os.path.join(targetdir, 'master-docinfo.xml')); + +tmp = os.path.join(targetdir, 'topics') +if not os.path.exists(tmp): + os.makedirs(tmp) + +# transform files +for root, dirs, filenames in os.walk(indir): + for f in filenames: + transform(root,f,targetdir) + +# Create master.doc includes +input = open('SUMMARY.adoc', 'r').read() +output = open(os.path.join(targetdir, 'master.adoc'), 'w') + +output.write(""" +:toc: +:toclevels: 3 +:numbered: + +include::document-attributes.adoc[] +""") + +input = re.sub(r"[ ]*\.+\s*link:[^/]+/(.*)\[(.*)\]", "include::\g<1>[]", input) +input = applyTransformation(input) +output.write(input) + +# parse book-product.json file and create document attributes +with open('../book-product.json') as data_file: + data = json.load(data_file) + +variables = data['variables'] + +def makeAttributes(variables, variable, list): + for i in variables.keys(): + if variable is None: + tmp = i + else: + tmp = variable + '_' + i + if isinstance(variables[i],dict): + makeAttributes(variables[i], tmp, list) + elif isinstance(variables[i],bool): + boolval = 'false' + if variables[i]: + boolval = 'true' + list.append({tmp: boolval}) + else: + list.append({tmp: str(variables[i])}) + + +attributeList = [] +makeAttributes(variables, None, attributeList) + +output = open(os.path.join(targetdir, 'document-attributes.adoc'), 'w') +for attribute in attributeList: + for k in attribute.keys(): + output.write(':book_' + k + ": " + attribute[k] + "\n") + + + + + + + + + diff --git a/securing_apps/SUMMARY.adoc b/securing_apps/SUMMARY.adoc index 71478bf57d..5efb856ae8 100644 --- a/securing_apps/SUMMARY.adoc +++ b/securing_apps/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Securing Applications and Services Guide .. link:securing_apps/topics/overview/overview.adoc[Overview] ... link:securing_apps/topics/overview/what-are-client-adapters.adoc[What are Client Adapters?] diff --git a/server_admin/SUMMARY.adoc b/server_admin/SUMMARY.adoc index 5fcb71e62a..a2ab2b2c0e 100644 --- a/server_admin/SUMMARY.adoc +++ b/server_admin/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Server Administration Guide .. link:server_admin/topics/overview.adoc[Overview] ... link:server_admin/topics/overview/features.adoc[Features] diff --git a/server_development/SUMMARY.adoc b/server_development/SUMMARY.adoc index 6d5a1b2fb4..5c26c94e3b 100755 --- a/server_development/SUMMARY.adoc +++ b/server_development/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Server Developer Guide .. link:server_development/topics/preface.adoc[Preface] .. link:server_development/topics/admin-rest-api.adoc[Admin REST API] diff --git a/server_installation/SUMMARY.adoc b/server_installation/SUMMARY.adoc index 98479f6733..72817a8ea8 100755 --- a/server_installation/SUMMARY.adoc +++ b/server_installation/SUMMARY.adoc @@ -1,4 +1,4 @@ -= {{book.title}} += Server Installation Guide .. link:server_installation/topics/overview.adoc[Overview] ... link:server_installation/topics/overview/recommended-reading.adoc[Recommended Reading]