only check links associated with the project type

When using www-generator.py with --check-all-links we don't want to
look for links that we do not expect to find or want to use. Limit the
URLs checked by the project type in that case.

Change-Id: I7560ec5d57d564730ebe60957153ea63f58002f8
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2017-08-05 15:17:33 -04:00
parent 14ebe6920f
commit a85dab5668
1 changed files with 14 additions and 9 deletions

View File

@ -160,21 +160,21 @@ def _check_url(args):
# a real page is published to the location, and we are not retrieving
# a file list generated by the web server.
_URLS = [
(None,
(None, [],
'https://docs.openstack.org/{name}/{series}/index.html'),
('has_install_guide',
('has_install_guide', ['service'],
'https://docs.openstack.org/{name}/{series}/install/index.html'),
('has_admin_guide',
('has_admin_guide', ['service'],
'https://docs.openstack.org/{name}/{series}/admin/index.html'),
('has_config_ref',
('has_config_ref', ['service', 'library'],
'https://docs.openstack.org/{name}/{series}/configuration/index.html'),
('has_in_tree_api_docs',
('has_in_tree_api_docs', ['service'],
'https://docs.openstack.org/{name}/{series}/api/index.html'),
('has_user_guide',
('has_user_guide', ['service'],
'https://docs.openstack.org/{name}/{series}/user/index.html'),
('has_api_ref',
('has_api_ref', ['service'],
'https://developer.openstack.org/api-ref/{service_type}/index.html'),
('has_api_guide',
('has_api_guide', ['service'],
'https://developer.openstack.org/api-guide/{service_type}/index.html'),
]
@ -261,11 +261,16 @@ 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, url_template in _URLS:
for flag, types, url_template in _URLS:
if flag is None:
flag_val = True
else:
flag_val = project.get(flag, False)
if (not flag_val) and types and project_type not in 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)
except KeyError: