-
Notifications
You must be signed in to change notification settings - Fork 100
Asset references #1002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asset references #1002
Changes from 10 commits
7df2c1f
92a9862
78577ae
68f572d
c87f9eb
d046ffe
790dc28
d9911e3
367601a
272d8e7
41ef4d7
19ed6f2
266858b
81a2df4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,17 +175,17 @@ installed and might be used by a different driver. | |
In order for drivers to build consistent documentation for a package, the | ||
following convention should be followed. | ||
|
||
- [.mld] pages are installed in a package's [share] directory, under the | ||
- [.mld] pages and assets are installed in a package's [share] directory, under the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should assets be installed in a particular directory, or with a particular name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems fine to me, as long as we mention this caveat.
panglesd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[odoc-pages] sub-directory. | ||
panglesd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- A page is the parent of every installed pages. The driver can freely name this | ||
- A page is the parent of every installed pages and assets. The driver can freely name this | ||
page, for example it can be named after the package. In what follows, we | ||
refer to this page as the [pkg] page. | ||
- If there is an installed [index.mld] file, the driver has to use it as | ||
content for the [pkg] page. | ||
- If there is no installed [index.mld] page, the driver has to generate some | ||
content for the [pkg] page. | ||
|
||
This convention is followed by the | ||
This convention (excluding assets) is followed by the | ||
{{:https://github.com/ocaml-doc/voodoo}driver for ocaml.org}, | ||
by the driver {{:https://erratique.ch/software/odig/doc/packaging.html}Odig} | ||
and by the build system {{:https://github.com/ocaml/dune}Dune}. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ let match_extra_odoc_reference_kind (_location as loc) s : | |
Some `TLabel | ||
| Some "module-type" -> Some `TModuleType | ||
| Some "page" -> Some `TPage | ||
| Some "asset" -> Some `TAsset | ||
| Some "value" -> | ||
d loc "value" "val"; | ||
Some `TValue | ||
|
@@ -298,6 +299,26 @@ let parse whole_reference_location s : | |
|> Error.raise_exception) | ||
in | ||
|
||
let page (kind, identifier, location) tokens : Page.t = | ||
let kind = match_reference_kind location kind in | ||
match tokens with | ||
| [] -> ( | ||
match kind with | ||
| (`TUnknown | `TPage) as kind -> `Root (identifier, kind) | ||
| _ -> expected [ "page" ] location |> Error.raise_exception) | ||
| next_token :: tokens -> ( | ||
match kind with | ||
| `TUnknown -> `Dot (label_parent next_token tokens, identifier) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think |
||
| _ -> | ||
let suggestion = | ||
Printf.sprintf "'page-%s' should be first." identifier | ||
in | ||
not_allowed ~what:"Page label" | ||
~in_what:"the last component of a reference path" ~suggestion | ||
location | ||
|> Error.raise_exception) | ||
panglesd marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this error message and suggestion. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, there was something wrong here! Pages reference cannot have a parent, and I want to preserve this behavior in this PR. Should be better now. |
||
in | ||
|
||
let start_from_last_component (kind, identifier, location) old_kind tokens = | ||
let new_kind = match_reference_kind location kind in | ||
let kind = | ||
|
@@ -363,6 +384,8 @@ let parse whole_reference_location s : | |
| `TLabel -> | ||
`Label | ||
(label_parent next_token tokens, LabelName.make_std identifier) | ||
| `TAsset -> | ||
`Asset (page next_token tokens, AssetName.make_std identifier) | ||
| `TChildPage | `TChildModule -> | ||
let suggestion = | ||
Printf.sprintf "'child-%s' should be first." identifier | ||
|
Uh oh!
There was an error while loading. Please reload this page.