diff --git a/doc/doc-contrib-guide/source/doc-tools/template-generator.rst b/doc/doc-contrib-guide/source/doc-tools/template-generator.rst index b0d84e1cb6..f61dbdc581 100644 --- a/doc/doc-contrib-guide/source/doc-tools/template-generator.rst +++ b/doc/doc-contrib-guide/source/doc-tools/template-generator.rst @@ -299,22 +299,27 @@ loop contexts). extract the correct subset of the data. ``TOPDIR`` - The relative path to the top of the build output. This is useful for + The path to the top of the build output (relative path by default and + absolute URL with ``--publish`` option). This is useful for building paths between output pages in a way that allows those pages to move around later. ``SCRIPTDIR`` - The relative path to the location of the JavaScript directory in the - build output. This is useful for building links to JavaScript files. + The path to the location of the JavaScript directory in the + build output (relative path by default and absolute URL with + ``--publish`` option). + This is useful for building links to JavaScript files. ``CSSDIR`` - The relative path to the location of the directory containing the - CSS files in the build output. This is useful for building links to + The path to the location of the directory containing the + CSS files in the build output (relative path by default and absolute URL + with ``--publish`` option). This is useful for building links to CSS files. ``IMAGEDIR`` - The relative path to the location of the directory containing image - files in the build output. This is useful for building links to + The path to the location of the directory containing image + files in the build output (relative path by default and absolute URL + with ``--publish`` option). This is useful for building links to images. ``SERIES`` diff --git a/tools/publishdocs.sh b/tools/publishdocs.sh index d6a2fc0d66..5214712f4f 100755 --- a/tools/publishdocs.sh +++ b/tools/publishdocs.sh @@ -36,7 +36,7 @@ if [ "$PUBLISH" = "build" ] ; then fi if [ "$PUBLISH" = "publish" ] ; then python3 tools/www-generator.py --source-directory www/ \ - --output-directory publish-docs + --output-directory publish-docs --publish rsync -a www/static/ publish-docs/ # Don't publish these files rm publish-docs/www-index.html diff --git a/tools/www-generator.py b/tools/www-generator.py index ad808e6dbe..456ce95062 100755 --- a/tools/www-generator.py +++ b/tools/www-generator.py @@ -155,6 +155,11 @@ def parse_command_line_arguments(): action='append', help='project to check (defaults to all)', ) + parser.add_argument('--publish', + default=False, + action='store_true', + help='use absolute paths for publish environment', + ) return parser.parse_args() @@ -475,18 +480,25 @@ def _get_official_repos(): def render_template(environment, project_data, regular_repos, infra_repos, - template_files, template_file, output_directory, extra={}): + template_files, template_file, output_directory, + is_publish, extra={}): logger = logging.getLogger() logger.info("generating %s", template_file) # Determine the relative path to a few common directories so # we don't need to set them in the templates. - topdir = os.path.relpath( - '.', os.path.dirname(template_file), - ).rstrip('/') + '/' - scriptdir = os.path.join(topdir, 'common', 'js').rstrip('/') + '/' - cssdir = os.path.join(topdir, 'common', 'css').rstrip('/') + '/' - imagedir = os.path.join(topdir, 'common', 'images').rstrip('/') + '/' + if is_publish: + topdir = 'https://docs.openstack.org/' + scriptdir = topdir + 'common/js/' + cssdir = topdir + 'common/css/' + imagedir = topdir + 'common/images/' + else: + topdir = os.path.relpath( + '.', os.path.dirname(template_file), + ).rstrip('/') + '/' + scriptdir = os.path.join(topdir, 'common', 'js').rstrip('/') + '/' + cssdir = os.path.join(topdir, 'common', 'css').rstrip('/') + '/' + imagedir = os.path.join(topdir, 'common', 'images').rstrip('/') + '/' series_match = SERIES_PAT.match(template_file) if series_match: @@ -610,6 +622,7 @@ def main(): template_files, template_file, args.output_directory, + args.publish ) output_pages.append(template_file) @@ -623,6 +636,7 @@ def main(): template_files, page_list_template, args.output_directory, + args.publish, extra={ 'file_list': output_pages, }, diff --git a/www/templates/deprecated_badge.tmpl b/www/templates/deprecated_badge.tmpl index e60c075463..c6cc75ad92 100644 --- a/www/templates/deprecated_badge.tmpl +++ b/www/templates/deprecated_badge.tmpl @@ -1,12 +1,9 @@ {# -*- mode: html -*- #} -{# reason to not use the CSSDIR its because introduces a relative path #} -{# not an absolute, so when its included on docthemes, its tried to include the css #} -{# from a wrong path instead of the right one #} - - + +