Skip to content

Commit a446f92

Browse files
committed
Disable links to missing API docs.
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
1 parent c5e2011 commit a446f92

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

_includes/package_links.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
{% endif %}
1414

1515
<div class="list-group list-group-sm {%if horizontal%}list-group-horizontal list-group-justified{%endif%}">
16-
<a class="{{list_group_class}}"
17-
target="_blank"
18-
href="{{ package.data.docs_uri }}"
19-
title="View API documentation on docs.ros.org"
20-
{% unless package.snapshot.documented %}disabled{% endunless %}>
16+
<a class="{{list_group_class}} {% if package.data.docs_uri == '' %}disabled{% endif %}" target="_blank"
17+
{% unless package.data.docs_uri == '' %}href="{{ package.data.docs_uri }}"{% endunless %}
18+
{% if package.data.docs_uri == '' %}href="javascript:void(0)"{% endif %}
19+
title="View API documentation">
2120
<span style="margin-right: 5px;" class="glyphicon glyphicon-file"></span>
2221
{%if hide_link_labels%}<br>{%endif%}
2322
API Docs
@@ -51,11 +50,13 @@
5150
Wiki
5251
</a>
5352
{%endif%}
54-
<a class="{{list_group_class}}"
55-
target="_blank"
53+
<a class="{{list_group_class}} {% unless package.snapshot.documented %}disabled{% endunless %}"
54+
target="_blank"
55+
{% if package.snapshot.documented %}
5656
href="http://http404error.github.io/roseco/graph.html?id=ros.json&focus={{page.package_name}}&height=1&depth=2&tred=standard&metagroup=false&colorby=Health&direction=LR"
57-
title="View RosEco package graph"
58-
{% unless package.snapshot.documented %}disabled{% endunless %}>
57+
{% endif %}
58+
{% unless package.snapshot.documented %}href="javascript:void(0);"{% endunless %}
59+
title="View RosEco package graph">
5960
<span style="margin-right: 5px;" class="glyphicon glyphicon-tree-deciduous"></span>
6061
{%if hide_link_labels%}<br>{%endif%}
6162
RosEco

_plugins/rosindex_generator.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
require 'uri'
1515
require 'set'
1616
require 'yaml'
17-
require "net/http"
17+
require 'net/http'
1818
require 'thread'
1919

2020
# local libs
@@ -500,6 +500,15 @@ def extract_package(site, distro, repo, snapshot, checkout_path, path, pkg_type,
500500
docs_uri = "http://docs.ros2.org/#{distro}/api/#{package_name}/"
501501
end
502502

503+
# ensure documentation uri refers to an existing site
504+
url = URI(docs_uri)
505+
Net::HTTP.start(url.host, url.port) do |http|
506+
response = http.head(url.path)
507+
if response.code != '200'
508+
docs_uri = ''
509+
end
510+
end
511+
503512
# try to acquire information on the CI status of the package
504513
ci_data = get_ci_data(distro, package_name, repo.name)
505514

0 commit comments

Comments
 (0)