diff --git a/tools/build-index.sh b/tools/build-index.sh new file mode 100755 index 000000000..4b65980c4 --- /dev/null +++ b/tools/build-index.sh @@ -0,0 +1,44 @@ +#!/bin/bash -xe +# +# Licensed 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. + +PUBLISH=$1 + +if [[ -z "$PUBLISH" ]] ; then + echo "usage $0 (build|publish)" + exit 1 +fi + +mkdir -p publish-docs + +# Build the www pages so that openstack-doc-test creates a link to +# www/www-index.html. +if [ "$PUBLISH" = "build" ] ; then + python tools/www-generator.py --source-directory www/ \ + --output-directory publish-docs/www/ + rsync -a www/static/ publish-docs/www/ + # publish-docs/www-index.html is the trigger for openstack-doc-test + # to include the file. + mv publish-docs/www/www-index.html publish-docs/www-index.html +fi +if [ "$PUBLISH" = "publish" ] ; then + + # Publication happens from publish-docs/api-ref to + # developer.openstack.org, so move content around + mkdir publish-docs/api-ref/ + python tools/www-generator.py --source-directory www/ \ + --output-directory publish-docs/api-ref/ + rsync -a www/static/ publish-docs/api-ref/ + # Don't publish this file + rm publish-docs/api-ref/www-index.html +fi diff --git a/tools/www-generator.py b/tools/www-generator.py new file mode 100755 index 000000000..8661c338b --- /dev/null +++ b/tools/www-generator.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python + +# Licensed 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. + +import argparse +import logging +import os +import sys + +import lxml.html +from lxml import etree +import jinja2 + + +def initialize_logging(debug, verbose): + """Initialize the Logger.""" + + logger = logging.getLogger(name='logger') + formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s') + handler = logging.StreamHandler() + handler.setFormatter(formatter) + logger.addHandler(handler) + + if verbose: + logger.setLevel(logging.INFO) + + if debug: + logger.setLevel(logging.DEBUG) + + return logging.getLogger('logger') + + +def parse_command_line_arguments(): + """Parse the command line arguments.""" + parser = argparse.ArgumentParser() + parser.add_argument("--debug", help="Print debugging messages.", + action="store_true", default=False) + parser.add_argument("--verbose", help="Be more verbose.", + action="store_true", default=False) + parser.add_argument("--source-directory", type=str, + default='www', help='') + parser.add_argument("--output-directory", type=str, + default='publish-docs/www', help='') + return parser.parse_args() + + +def main(): + """Entry point for this script.""" + + args = parse_command_line_arguments() + logger = initialize_logging(args.debug, args.verbose) + + try: + loader = jinja2.FileSystemLoader(args.source_directory) + environment = jinja2.Environment(loader=loader) + except Exception as e: + logger.error("initialising template environment failed: %s" % e) + return 1 + + for templateFile in environment.list_templates(): + if not templateFile.endswith('.html'): + continue + + logger.info("generating %s" % templateFile) + + try: + template = environment.get_template(templateFile) + except Exception as e: + logger.error("parsing template %s failed: %s" % + (templateFile, e)) + continue + + try: + output = lxml.html.tostring( + lxml.html.fromstring(template.render()), + pretty_print=True) + except Exception as e: + logger.error("rendering template %s failed: %s" % + (templateFile, e)) + continue + + try: + target_directory = os.path.join(args.output_directory, + os.path.dirname(templateFile)) + target_file = os.path.join(args.output_directory, templateFile) + if not os.path.isdir(target_directory): + logger.debug("creating target directory %s" % + target_directory) + os.makedirs(target_directory) + logger.debug("writing %s" % target_file) + with open(os.path.join(target_file), 'wb') as fh: + fh.write(output.encode('utf8')) + except (IOError, OSError, UnicodeEncodeError) as e: + logger.error("writing %s failed: %s" % (target_file, e)) + continue + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tox.ini b/tox.ini index 2939c8144..64cf2820c 100644 --- a/tox.ini +++ b/tox.ini @@ -42,6 +42,8 @@ commands = openstack-doc-test --check-deletions {posargs} commands = # Build and copy RST Guides {toxinidir}/tools/build-all-rst.sh + # Build website index + {toxinidir}/tools/build-index.sh build # Build DocBook Guides openstack-doc-test --check-build {posargs} @@ -61,6 +63,8 @@ commands = {toxinidir}/tools/build-firstapp-rst.sh # Build and copy API Quick Start {toxinidir}/tools/build-api-quick-start.sh + # Build website index + {toxinidir}/tools/build-index.sh publish [testenv:checklang] # openstack-generate-docbook needs xml2po which cannot be installed in diff --git a/www/index.html b/www/index.html index 8a966c759..26f0c0d5c 100644 --- a/www/index.html +++ b/www/index.html @@ -1,199 +1,58 @@ - - -
- - - -- Need help with a development problem? - - Ask OpenStack - -
-- You interact with an OpenStack cloud using a number of tools. The tool you choose depends on your use case in the cloud. Here are some starting points. -
-
- A Software Development Kit (SDK) is a collection of code, examples, and
- documentation that helps you to create applications in the language of
- your choice on OpenStack clouds. If one of the following SDKs do not
- support your language or use case, you can use the API
- or one of the other
+
+ You interact with an OpenStack cloud using a number of tools. The tool you choose depends on your use case in the cloud. Here are some starting points.
+
+ A Software Development Kit (SDK) is a collection of code, examples, and
+ documentation that helps you to create applications in the language of
+ your choice on OpenStack clouds. If one of the following SDKs do not
+ support your language or use case, you can use the API
+ or one of the other Known SDKs.
-
- Get SDK Now
-
-
+
+ Get SDK Now
+
+
-
- Get SDK Now
-
-
+
+ Get SDK Now
+
+
-
- Get SDK Now
-
-
+
+ Get SDK Now
+
+
-
- Get SDK Now
-
-
+
+ Get SDK Now
+
+
-
- Get SDK Now
-
-
+
+ Get SDK Now
+
+
-
- Get SDK Now
-
-
+
+ Get SDK Now
+
+
- An OpenStack Command Line Interface (CLI) is a text based client that helps you to create scripts for interacting with OpenStack clouds.
-
+ An OpenStack Command Line Interface (CLI) is a text based client that helps you to create scripts for interacting with OpenStack clouds.
+ Development Resources for OpenStack clouds
+
+ View SDKs
+ View APIs
+ View CLIs
+
+
+ Software Development Kits
+
+
Java
-
-
Node.js
-
Python
-
Ruby
-
.NET
-
PHP
-
- Command Line Interfaces
-
-
-
-
-
-
-
-
Application Programming Interfaces
@@ -858,8 +567,6 @@
OpenStack API Quick Start
gives you the basics for interacting with the services.
-
+ Command Line Interfaces
+
+
+
+
+
+
+
+
+
diff --git a/www/templates/script_footer.tmpl b/www/templates/script_footer.tmpl
new file mode 100644
index 000000000..a51c92868
--- /dev/null
+++ b/www/templates/script_footer.tmpl
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/www/www-index.html b/www/www-index.html
new file mode 100644
index 000000000..126c2b549
--- /dev/null
+++ b/www/www-index.html
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+