diff --git a/tools/www-generator.py b/tools/www-generator.py index 7e7a2895b5..37a3af8ace 100755 --- a/tools/www-generator.py +++ b/tools/www-generator.py @@ -169,25 +169,56 @@ def _check_url(args): # NOTE(dhellmann): We use URLs with explicit index.html to ensure that # a real page is published to the location, and we are not retrieving # a file list generated by the web server. +URLSettings = collections.namedtuple( + 'URLSettings', + ['flag_name', 'types', 'template'], +) _URLS = [ - (None, [], - 'https://docs.openstack.org/{name}/{series}/index.html'), - ('has_install_guide', ['service'], - 'https://docs.openstack.org/{name}/{series}/install/index.html'), - ('has_admin_guide', ['service'], - 'https://docs.openstack.org/{name}/{series}/admin/index.html'), - ('has_config_ref', ['service', 'library'], - 'https://docs.openstack.org/{name}/{series}/configuration/index.html'), - ('has_in_tree_api_docs', ['service'], - 'https://docs.openstack.org/{name}/{series}/api/index.html'), - ('has_user_guide', ['service'], - 'https://docs.openstack.org/{name}/{series}/user/index.html'), - ('has_api_ref', ['service'], - 'https://developer.openstack.org/api-ref/{service_type}/index.html'), - ('has_api_guide', ['service'], - 'https://developer.openstack.org/api-guide/{service_type}/index.html'), - ('has_deployment_guide', ['deployment'], - 'https://docs.openstack.org/project-deploy-guide/{name}/{series}/index.html'), # noqa + URLSettings( + flag_name=None, + types=[], + template='https://docs.openstack.org/{name}/{series}/index.html', + ), + URLSettings( + flag_name='has_install_guide', + types=['service'], + template='https://docs.openstack.org/{name}/{series}/install/index.html', # noqa + ), + URLSettings( + flag_name='has_admin_guide', + types=['service'], + template='https://docs.openstack.org/{name}/{series}/admin/index.html', + ), + URLSettings( + flag_name='has_config_ref', + types=['service', 'library'], + template='https://docs.openstack.org/{name}/{series}/configuration/index.html', # noqa + ), + URLSettings( + flag_name='has_in_tree_api_docs', + types=['service'], + template='https://docs.openstack.org/{name}/{series}/api/index.html', + ), + URLSettings( + flag_name='has_user_guide', + types=['service'], + template='https://docs.openstack.org/{name}/{series}/user/index.html', + ), + URLSettings( + flag_name='has_api_ref', + types=['service'], + template='https://developer.openstack.org/api-ref/{service_type}/index.html', # noqa + ), + URLSettings( + flag_name='has_api_guide', + types=['service'], + template='https://developer.openstack.org/api-guide/{service_type}/index.html', # noqa + ), + URLSettings( + flag_name='has_deployment_guide', + types=['deployment'], + template='https://docs.openstack.org/project-deploy-guide/{name}/{series}/index.html', # noqa + ), ] @@ -288,18 +319,21 @@ def load_project_data(source_directory, # If the project claims to have a separately published guide # of some sort, look for it before allowing the flag to stand. if not skip_links: - for flag, types, url_template in _URLS: - if flag is None: + for url_info in _URLS: + if url_info.flag_name is None: flag_val = True else: - flag_val = project.get(flag, False) - if (not flag_val) and types and project_type not in types: + flag_val = project.get(url_info.flag_name, False) + if ((not flag_val) and + url_info.types and + project_type not in url_info.types): # This type of project isn't expected to have # this type of link, so if we are not # explicitly told to check for it don't. continue try: - url = url_template.format(series=series, **project) + url = url_info.template.format( + series=series, **project) except KeyError: # The project data does not include a field needed # to build the URL (typically the @@ -315,7 +349,9 @@ def load_project_data(source_directory, logger.info('%s:%s looking for %s', series, project['name'], url) links_to_check.append( - (url, project['name'], flag, flag_val) + (url, project['name'], + url_info.flag_name, + flag_val) ) if links_to_check: