From 799f4dc96633a70a1f0116121fc1723812704d47 Mon Sep 17 00:00:00 2001 From: SeongSoo Cho Date: Wed, 14 Dec 2016 02:22:12 +0900 Subject: [PATCH] Add pdf file link in build result page Now, openstack manual builds supports build a pdf file. But, the build result page of Zenkins does not show PDF files. This patch adds a PDF file link for manual in build result page, and removes both 'bk-api-ref*.pdf' section to prevent confused on what is making the PDF files and copying them and unused docs sections. Change-Id: I5043c582c5a09cf8a8976a05a0ba65a007fcf20f Depends-On: I66242f44bb13f1a09be0904a491c84f42f25c3a2 Implements: blueprint build-pdf-from-rst-guides --- os_doc_tools/index.py | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/os_doc_tools/index.py b/os_doc_tools/index.py index 583eebb2..297ac303 100644 --- a/os_doc_tools/index.py +++ b/os_doc_tools/index.py @@ -13,10 +13,21 @@ # under the License. import argparse +import glob import os import sys +def get_pdf_link(root, publish_path): + p = '%s/*.pdf' % root + re = glob.glob(p) + if len(re) == 0: + return '' + filename = os.path.basename(re[0]) + path = os.path.relpath(root, publish_path) + return ' (pdf)' % (path, filename) + + def generate_index_file(publish_path): """Generate index.html file in publish_path.""" @@ -42,27 +53,12 @@ def generate_index_file(publish_path): if root == publish_path: continue - if os.path.isfile(os.path.join(root, 'content/index.html')): - path = os.path.relpath(root, publish_path) - links[path] = ('%s\n' % - (path, path)) - elif os.path.isfile(os.path.join(root, 'index.html')): - path = os.path.relpath(root, publish_path) - links[path] = ('%s\n' % - (path, path.replace('draft/', ''))) + pdf_link = get_pdf_link(root, publish_path) - if os.path.isfile(os.path.join(root, 'api-ref.html')): + if os.path.isfile(os.path.join(root, 'index.html')): path = os.path.relpath(root, publish_path) - links[path] = ('%s\n' % - (path, path)) - - # List PDF files for api-site that have from "bk-api-ref*.pdf" - # as well since they have no corresponding html file. - for f in files: - if f.startswith('bk-api-ref') and f.endswith('.pdf'): - path = os.path.relpath(root, publish_path) - links[f] = ('%s\n' % - (path, f, f)) + links[path] = ('%s%s\n' % + (path, path.replace('draft/', ''), pdf_link)) for entry in sorted([s for s in links if not s.startswith('draft/')]): index_file.write(links[entry])