Skip to content

Commit

Permalink
Disable links to missing API docs.
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored and tfoote committed Jan 2, 2024
1 parent fce2bc0 commit 7fbcb26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 4 additions & 5 deletions _includes/package_links.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
{% endif %}

<div class="list-group list-group-sm {%if horizontal%}list-group-horizontal list-group-justified{%endif%}">
<a class="{{list_group_class}}"
target="_blank"
href="{{ package.data.docs_uri }}"
title="View API documentation on docs.ros.org"
{% unless package.snapshot.documented %}disabled{% endunless %}>
<a class="{{list_group_class}} {% if package.data.docs_uri == '' %}disabled{% endif %}" target="_blank"
{% unless package.data.docs_uri == '' %}href="{{ package.data.docs_uri }}"{% endunless %}
{% if package.data.docs_uri == '' %}href="javascript:void(0)"{% endif %}
title="View API documentation">
<span style="margin-right: 5px;" class="glyphicon glyphicon-file"></span>
{%if hide_link_labels%}<br>{%endif%}
API Docs
Expand Down
11 changes: 10 additions & 1 deletion _plugins/rosindex_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require 'uri'
require 'set'
require 'yaml'
require "net/http"
require 'net/http'
require 'thread'

# local libs
Expand Down Expand Up @@ -513,6 +513,15 @@ def extract_package(site, distro, repo, snapshot, checkout_path, path, pkg_type,
docs_uri = "http://docs.ros.org/#{DEFAULT_LANGUAGE_PREFIX}/#{distro}/p/#{package_name}"
end

# ensure documentation uri refers to an existing site
url = URI(docs_uri)
Net::HTTP.start(url.host, url.port) do |http|
response = http.head(url.path)
if response.code != '200'
docs_uri = ''
end
end

# try to acquire information on the CI status of the package
ci_data = get_ci_data(distro, package_name, repo.name)

Expand Down

0 comments on commit 7fbcb26

Please sign in to comment.