Skip to content
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

Support references in code spans #756

Open
MisterDA opened this issue Oct 15, 2021 · 2 comments
Open

Support references in code spans #756

MisterDA opened this issue Oct 15, 2021 · 2 comments
Labels
enhancement New feature or request parser

Comments

@MisterDA
Copy link
Contributor

MisterDA commented Oct 15, 2021

I noticed that the Lwt documentation has doc comments like this:

There are straightforward ways to make promises canceled. One could create a
promise that {e starts out} canceled, with {!Lwt.fail}[ Lwt.Canceled]. It's
also possible to {e make} a promise canceled through its resolver, by
calling {!Lwt.wakeup_later_exn}[ r Lwt.Canceled].

The intent is to have a little code example with a reference to the
function used. The output however isn't very nice:

<p>There are straightforward ways to make promises canceled. One
could create a promise that <em>starts out</em> canceled, with
<a href="index.html#val-fail"><code>Lwt.fail</code></a><code>Lwt.Canceled</code>.
It's also possible to <em>make</em> a promise canceled through its resolver, by calling
<a href="index.html#val-wakeup_later_exn"><code>Lwt.wakeup_later_exn</code></a>
<code>r Lwt.Canceled</code>.</p>

It would be much nicer to merge the consecutive <code> tags, and to
be able to embed references in these short code blocks. Depending on
the document format or the CSS, it can get very ugly. Is there a way
to achieve that? If not, could odoc add support for it?

They also write this, and the result looks very weird imo:

If [f] raises an exception, it is passed to [!]{!Lwt.async_exception_hook}.
By default, this will terminate the process. *)

Thanks.

@panglesd
Copy link
Collaborator

This could be achieved (in code spans, not code blocks) by having a {c ...} (c for codespan) which renders as a codespan but contains odoc inline elements instead of plain text.

@panglesd panglesd changed the title Support references in code blocks Support references in code spans May 15, 2024
@ocaml ocaml deleted a comment from github-actions bot May 15, 2024
@favonia
Copy link
Contributor

favonia commented May 15, 2024

@panglesd This is a great idea! Personally I prefer {code ...} over {c ...} for several reasons: (1) for me it is easier to remember and (2) it matches the HTML tag <code>, just like {ul/ol/i/b... ...} and (3) we can still add {c ...} later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser
Projects
None yet
Development

No branches or pull requests

4 participants