KEYCLOAK-4424 Add shared scripts and book-product.json to toplevel

This commit is contained in:
Stian Thorgersen 2017-04-07 10:05:47 +02:00
parent cf18563e95
commit 783741143a
12 changed files with 297 additions and 13 deletions

View file

@ -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: 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 cd server_admin
python gitlab-conversion.py python ../gitlab-conversion.py
cd target cd target
asciidoctor master.adoc asciidoctor master.adoc
@ -46,6 +46,14 @@ On Linux you can also run build-product.sh DIR. For example:
./build-product.sh server_admin ./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 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. This will not create documentation that looks exactly as the official Red Hat Single Sign-On documentation, but the content will be the same.

View file

@ -1,4 +1,4 @@
= {{book.title}} = Keycloak Documentation
. link:getting_started/README.adoc[Getting Started] . link:getting_started/README.adoc[Getting Started]
{% include "./getting_started/SUMMARY.adoc" %} {% include "./getting_started/SUMMARY.adoc" %}

View file

@ -1,4 +1,4 @@
= {{book.title}} = Authorization Services Guide
.. link:authorization_services/topics/overview/overview.adoc[Overview] .. link:authorization_services/topics/overview/overview.adoc[Overview]

105
book-product.json Executable file
View file

@ -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"
}
}
}

View file

@ -16,7 +16,6 @@
}, },
"variables": { "variables": {
"title": "Keycloak Documentation",
"project": { "project": {
"name": "Keycloak", "name": "Keycloak",
"version": "SNAPSHOT", "version": "SNAPSHOT",

View file

@ -1,9 +1,70 @@
#!/bin/bash #!/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 GUIDE=$1
cd $GUIDE function buildGuide
python gitlab-conversion.py {
cd target GUIDE=$1
asciidoctor master.adoc 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 "***********************************************************************************************************"

View file

@ -1,4 +1,4 @@
= {{book.title}} = Getting Started Guide
.. link:getting_started/topics/overview.adoc[Overview] .. link:getting_started/topics/overview.adoc[Overview]
.. link:getting_started/topics/first-boot.adoc[Installing and Booting] .. link:getting_started/topics/first-boot.adoc[Installing and Booting]

111
gitlab-conversion.py Executable file
View file

@ -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"<<fake.+#", "<<", input)
for variable in re.findall(r"[ ]*{% if (.*?) %}", input):
tmp = variable.replace('.', '_')
input = input.replace(variable, tmp)
exp = re.compile("[ ]*{% if (.*?) %}(.*?)[ ]*{% endif %}", re.DOTALL)
input = re.sub(exp, "ifeval::[{\g<1>}==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")

View file

@ -1,4 +1,4 @@
= {{book.title}} = Securing Applications and Services Guide
.. link:securing_apps/topics/overview/overview.adoc[Overview] .. link:securing_apps/topics/overview/overview.adoc[Overview]
... link:securing_apps/topics/overview/what-are-client-adapters.adoc[What are Client Adapters?] ... link:securing_apps/topics/overview/what-are-client-adapters.adoc[What are Client Adapters?]

View file

@ -1,4 +1,4 @@
= {{book.title}} = Server Administration Guide
.. link:server_admin/topics/overview.adoc[Overview] .. link:server_admin/topics/overview.adoc[Overview]
... link:server_admin/topics/overview/features.adoc[Features] ... link:server_admin/topics/overview/features.adoc[Features]

View file

@ -1,4 +1,4 @@
= {{book.title}} = Server Developer Guide
.. link:server_development/topics/preface.adoc[Preface] .. link:server_development/topics/preface.adoc[Preface]
.. link:server_development/topics/admin-rest-api.adoc[Admin REST API] .. link:server_development/topics/admin-rest-api.adoc[Admin REST API]

View file

@ -1,4 +1,4 @@
= {{book.title}} = Server Installation Guide
.. link:server_installation/topics/overview.adoc[Overview] .. link:server_installation/topics/overview.adoc[Overview]
... link:server_installation/topics/overview/recommended-reading.adoc[Recommended Reading] ... link:server_installation/topics/overview/recommended-reading.adoc[Recommended Reading]