Skip to content

Commit

Permalink
Document Url.from_identifier's result return type
Browse files Browse the repository at this point in the history
  • Loading branch information
panglesd committed Nov 7, 2024
1 parent 1968ab8 commit dd59841
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/document/url.mli
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ type t = Anchor.t
val from_path : Path.t -> t

val from_identifier : stop_before:bool -> Identifier.t -> (t, Error.t) result
(** [from_identifier] turns an identifier to an url.
Some identifiers can be accessed in different ways. For instance,
submodules generate a dedicated page, but they can also be linked to at
their parent page, using a hash to the declaration.
The [stop_before] boolean controls that: with [~stop_before:true], the url
will point to the parent page when applicable.
There are several wrong ways to use [from_identifier]:
- Using [~stop_before:false] with a module that does not contain an
expansion, such as a module alias. This will return [Ok url] but [url]
leads to a 404.
- Using [~stop_before:true] with a module that does not contain a parent,
such as a root module. This will ouput return an [Error _] value.
- Calling it with an unlinkable id, such as a core type. This will return
an [Error _] value.
Please, reader, go and fix this API. Thanks. *)

val from_asset_identifier : Identifier.AssetFile.t -> t

Expand Down

0 comments on commit dd59841

Please sign in to comment.