Skip to content

Commit eb8a3aa

Browse files
authored
Link to package homepage instead of the No Docs warning while we add … (#64)
* Link to package "doc" field or homepage instead of the No Docs warning while we add support for doc linking * Fix test-suite
1 parent 18e7d3b commit eb8a3aa

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

src/rocqproverorg_frontend/layouts/package_layout.eml

+10-9
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,20 @@ Layout.base
6060
<li class="flex flex-auto">
6161
<a class="w-full h-10 flex justify-center rounded-r-lg p-1 items-center font-semibold border border-l-0 border-primary dark:border-dark-primary <%s (match path with | Documentation _ -> "bg-primary dark:bg-dark-primary text-white dark:text-dark-title" | _ -> "text-primary dark:text-dark-primary bg-sand dark:bg-dark-card")%>" href="<%s Url.Package.documentation package.name ?version:(Package.url_version package) %>">Docs</a>
6262
</li>
63-
<% | Unknown -> ( %>
63+
<% | _ ->
64+
let title, link = match package.Package.doc with
65+
| Some doc -> "Doc", doc
66+
| None -> match package.Package.homepages with
67+
| [] -> "No Docs", ""
68+
| hd :: _ -> "Homepage", hd
69+
in
70+
%>
6471
<li class="flex flex-auto">
65-
<span aria-label="Documentation status is unknown" class="w-full h-10 flex justify-center gap-2 rounded-r-lg p-1 items-center font-semibold border border-l-0 border-separator_20 dark:border-dark-separator_30 <%s (match path with | Documentation _ -> "bg-primary dark:bg-dark-primary text-title dark:text-dark-title" | _ -> "text-title dark:text-dark-title bg-sand dark:bg-dark-card")%>"><%s! Icons.error "" %> No Docs</span>
72+
<a class="w-full h-10 flex justify-center rounded-r-lg p-1 items-center font-semibold border border-l-0 border-primary dark:border-dark-primary <%s (match path with | Documentation _ -> "bg-primary dark:bg-dark-primary text-white dark:text-dark-title" | _ -> "text-primary dark:text-dark-primary bg-sand dark:bg-dark-card")%>" href="<%s link %>"><%s title %></a>
6673
</li>
67-
<% )
68-
| Failure -> ( %>
69-
<li class="flex flex-auto">
70-
<a title="Documentation failed to build!" class="w-full h-10 flex justify-center gap-2 rounded-r-lg p-1 items-center font-semibold border border-l-0 border-gray-400 <%s (match path with | Documentation _ -> "bg-primary text-white" | _ -> "text-gray-500 bg-sand")%>" href="<%s Url.Package.documentation package.name ?version:(Package.url_version package) %>"><%s! Icons.error "" %> No Docs</a>
71-
</li>
72-
<% ));%>
74+
<% ); %>
7375
</li>
7476
</ol>
75-
7677
<div id="in-package-search" class="relative w-full">
7778
<div class="flex w-full items-center overflow-hidden">
7879
<% if Option.is_some search_index_digest then (%>

src/rocqproverorg_frontend/package.ml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type package = {
1616
maintainers : Data.Opam_user.t list;
1717
publication : float;
1818
homepages : string list;
19+
doc: string option;
1920
source : (string * string list) option;
2021
(* TODO: these should be part of package.json coming from voodoo, but they
2122
currently aren't

src/rocqproverorg_package/lib/info.ml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type t = {
1111
maintainers : string list;
1212
license : string;
1313
homepage : string list;
14+
doc : string option;
1415
tags : string list;
1516
dependencies : (OpamPackage.Name.t * string option) list;
1617
rev_deps : (OpamPackage.Name.t * string option * OpamPackage.Version.t) list;
@@ -152,6 +153,7 @@ let make ~package ~packages ~rev_deps ~timestamps opam =
152153
description =
153154
descr opam |> Option.map OpamFile.Descr.body |> Option.value ~default:"";
154155
homepage = homepage opam;
156+
doc = List.nth_opt (doc opam) 0;
155157
tags = tags opam;
156158
rev_deps;
157159
conflicts = get_conflicts opam;

src/rocqproverorg_package/lib/rocqproverorg_package.mli

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module Info : sig
4040
maintainers : string list;
4141
license : string;
4242
homepage : string list;
43+
doc : string option;
4344
tags : string list;
4445
dependencies : (Name.t * string option) list;
4546
rev_deps : (Name.t * string option * Version.t) list;

src/rocqproverorg_web/lib/handler.ml

+1
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ module Package_helper = struct
797797
license = info.license;
798798
publication = info.publication;
799799
homepages = info.Rocqproverorg_package.Info.homepage;
800+
doc = info.Rocqproverorg_package.Info.doc;
800801
source =
801802
Option.map
802803
(fun url ->

src/rocqproverorg_web/test/graphql_test.ml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ let empty_info =
1919
maintainers = [];
2020
license = "";
2121
homepage = [];
22+
doc = None;
2223
tags = [];
2324
dependencies;
2425
rev_deps = [];

0 commit comments

Comments
 (0)