Replies: 3 comments 9 replies
-
Why do you provide this syntax ? It can only lead to absurdities like |
Beta Was this translation helpful? Give feedback.
-
I don't think I'm happy about the asset resolution scheme. It replicates all the problems you get with link references in HTML which are extremely brittle to structural changes. These problems can perfectly be avoided here and I think we should take the steps to do so. Two basic requirements to start from:
The reason for 1. is that this allows to move either assets or entities referring to them without having all references breaking. The reason for 2. is that packages do get renamed or split etc. and in this case you don't want to have to redo all you references. To give an example suppose I decide to simply have all my assets in a toplevel Regarding 1. I think that all Regarding 2. I'd propose perhaps to simply use a starting |
Beta Was this translation helpful? Give feedback.
-
Btw. since all this will likely happen in the reference parsing code please solve #865 along the way :-) |
Beta Was this translation helpful? Give feedback.
-
Odoc 3.0 Planning: Assets and medias in odoc
This discussion builds on #1097, focusing on assets and media elements.
Referencing assets
Recall from #1097:
Assets are part of the hierarchy. They are referenced in a similar way to pages. The new
asset
keyword can be used to disambiguate. Here are some examples of reference to assets:"data.json"
,asset-"data.json"
,data/"example.json"
, ordata/asset-"example.json"
.Asset path
When references are used in places where we know they should link to assets (see the "medias" section), some of the syntax for general references is not needed, but tedious to escape. In particular, dots (
.
) and dashes (-
) are often seen in filenames but interpreted by odoc, leading to additional"
, as in{!directory/"file.img"}
.In order to make it easier to write, we define asset path as normal references where the part after the last
/
is considered verbatim. So an asset pathdirname/file-name.extension
is parsed as the normal referencedirname/"file-name.extension"
.Resolving assets within a page
When resolving asset references/paths in a page within the hierarchy, assets can be resolved relatively or absolutely, up to the root of the documentation tree. For example, given the hierarchy (omitting
index.mld
files: all directories must contain anindex.mld
, even if they do not contain a page but only assets!):when resolving in
baz.mld
, the following are valid paths (assuming our package name ispkgname
):For completeness, here are the same path but written as references (instead of asset paths):
Resolving assets within a module
The same mechanism that adds a package's documentation pages to the scope also adds the corresponding assets. The asset path
/packagename/a/b/c/d.txt
would refer to the asset that usually ends up installed at<opam dir>/doc/<packagename>/odoc-pages/a/b/c/d.txt
Including media
The syntax for including media builds on the syntax for reference links. A media is inserted by
{<media><kind><target>}
where:<media>
can be eitherfigure
for figures,image
for images,audio
for audio, andvideo
for video, orasset
for asset links<kind>
is either!
if<target>
is an asset path, or:
if<target>
is a link.{asset:<link>}
renders the same as{:<link>}
.An additional "replacement", "caption" or "alternative" text can be added with the following syntax:
{{<media><kind><target>}<replacement text>}
. The replacement text can only contain inline elements.Here is the meaning of each media:
asset
image
video
audio
Here are some examples:
Figures
Medias can be included in (captioned) figures. This allows to reference them.
The syntax is as follows:
{figure<?:id> <media>}
or{{figure<?:id> <media>}<caption>}
where:<?:id>
is either empty or a:
followed by anid
. If noid
is given, one is autogenerated from the caption (if existant).<media>
is either an image, audio or video element,<caption>
consists of the inline elements that will be rendered as the caption for the figure.Figures are nestable block elements. They can be referenced by id (using the
label
prefix for disambiguation).Examples:
The last example, taken from here, shows that alternative text and caption are different.
Audio and video are also allowed in figures:
Rendering medias
HTML
Rendering media in html is easy thanks to HTML5 features.
The size for rendered images and figures depend on the size of the asset. Audio and video have controls embedded.
Latex
How medias are inserted in latex is made on a best-effort basis. Here are some ideas:
\includegraphics
.Medias are rendered without size specification: they use the original size of the media. They are block elements.
Assets for installed packages
Similarly to pages, assets for
<pkgname>
should be installed in the<pkgname>/odoc-pages/
hierarchy.Additionally, any file installed in
<pkgname>/odoc-assets/
will be equivalent to the file installed in<pkgname>/odoc-pages/_assets/
. This allows compatibility with theodig
convention.Beta Was this translation helpful? Give feedback.
All reactions