Skip to content

Commit

Permalink
Remove the link from content
Browse files Browse the repository at this point in the history
  • Loading branch information
panglesd committed Nov 26, 2024
1 parent ab216d2 commit 9c4087c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
26 changes: 15 additions & 11 deletions src/document/sidebar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Id = Odoc_model.Paths.Identifier

type entry = {
url : Url.t option;
content : Inline.one;
content : Inline.t;
toc_status : [ `Open ] option;
}

Expand Down Expand Up @@ -35,16 +35,22 @@ end = struct
(* When transforming the tree, we use a filter_map to remove the nodes that
are irrelevant for the current url. However, we always want to keep the
root. So we apply the filter_map starting from the first children. *)
let convert_entry { url; content = b; _ } =
let convert_entry { url; content; _ } =
let link =
match url with
| Some url ->
if url.page = current_url && Astring.String.equal url.anchor ""
then { b with Inline.attr = [ "current_unit" ] }
else b
| None -> b
let target = Target.Internal (Target.Resolved url) in
let attr =
if url.page = current_url && Astring.String.equal url.anchor ""
then [ "current_unit" ]
else []
in
[
inline ~attr @@ Inline.Link { target; content; tooltip = None };
]
| None -> content
in
Types.block @@ Inline [ link ]
Types.block @@ Inline link
in
let rec convert n =
let children =
Expand Down Expand Up @@ -77,7 +83,7 @@ end = struct
| Dir ->
{
url = None;
content = inline @@ Text (Id.name entry.id);
content = [ inline @@ Text (Id.name entry.id) ];
toc_status = None;
}
| _ ->
Expand Down Expand Up @@ -117,9 +123,7 @@ end = struct
let name = Odoc_model.Paths.Identifier.name entry.id in
[ inline (Text name) ]
in
let target = Target.Internal (Target.Resolved path) in
let i = inline @@ Inline.Link { target; content; tooltip = None } in
{ url = Some path; content = i; toc_status }
{ url = Some path; content; toc_status }
in
let f x =
match x.Entry.kind with
Expand Down
2 changes: 1 addition & 1 deletion src/document/sidebar.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Types

type entry = {
url : Url.t option;
content : Inline.one;
content : Inline.t;
toc_status : [ `Open ] option;
}

Expand Down
4 changes: 1 addition & 3 deletions src/odoc/sidebar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ let toc_to_json ({ url; content = inline; _ } : Odoc_document.Sidebar.entry) :
(`String href, `String kind)
in
let inline =
let inline =
Odoc_html.Generator.inline ~config ~xref_base_uri:"" [ inline ]
in
let inline = Odoc_html.Generator.inline ~config ~xref_base_uri:"" inline in
let inline =
String.concat ""
@@ List.map (Format.asprintf "%a" (Tyxml.Html.pp_elt ())) inline
Expand Down

0 comments on commit 9c4087c

Please sign in to comment.