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

Markdown -> Ocamldoc conversion #215

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

jfrolich
Copy link
Contributor

@jfrolich jfrolich commented Jul 4, 2020

Work in progress.

I am not stoked to introduce Str here, there's probably a better way to do this, I just wanted it to make it work first.

You can test it with the following:

create file test.md:

# this is a markdown test document

This is _important_ or **very important**, let's try the `code` fences.

```
let x = "bla"
```

Hello this is a ordered list

1. One
2. Two
3. Three

And this is a unordered list

- One
- Two
- Three

## Another header

Blah blah blah

> This is some quote

And this is a link [Hello](https://reasonml.org).

    another code block?

<https://reasonml.org> <-- A link

<module:Module> <-- An explicit cross reference

<ref:Module> <-- An inferred cross reference

Now get the result with the following command:

dune build && ./_build/default/tests/omd_ocamldoc.exe test.md

It yields:

{0 this is a markdown test document}

This is {e important} or {b very important}, let's try the [code] fences.

{[
let x = "bla"
]}

Hello this is a ordered list

+ One
+ Two
+ Three

And this is a unordered list

- One
- Two
- Three

{1 Another header}

Blah blah blah

{v
This is some quote
v}

And this is a link {{: https://reasonml.org} Hello}.

{[
another code block?
]}

{{: https://reasonml.org} https://reasonml.org} <-- A link

{!module:Module} <-- An explicit cross reference

{!Module} <-- An inferred cross reference

@nojb
Copy link
Contributor

nojb commented Jul 5, 2020

Thanks! Could you say a few words about the intended use-case for this?

@jfrolich
Copy link
Contributor Author

jfrolich commented Jul 5, 2020

We are looking to support markdown syntax for documentation in Reason to make documenting code more accessible for newcomers. As markdown is ubiquitous, ocamldoc is just another indirection that adds friction. Additionally markdown has proven itself to be much more readable in plain text, so that is more ergonomic when reading source code instead of generated documentation from ocamldoc.

If you don't think this printer should be in scope of omd that is fine.

By the way. Did you think about creating a markdown output, this will allow creating a pretty printer for markdown (automatic prose-wrapping)?

@jfrolich
Copy link
Contributor Author

jfrolich commented Jul 5, 2020

By the way. Did you think about creating a markdown output, this will allow creating a pretty printer for markdown (automatic prose-wrapping)?

There is a pretty extensive test suite with input/output snapshots in the prettier repo: https://github.com/prettier/prettier/tree/master/tests/markdown.

@nojb
Copy link
Contributor

nojb commented Jul 5, 2020

We are looking to support markdown syntax for documentation in Reason to make documenting code more accessible for newcomers. As markdown is ubiquitous, ocamldoc is just another indirection that adds friction. Additionally markdown has proven itself to be much more readable in plain text, so that is more ergonomic when reading source code instead of generated documentation from ocamldoc.

Sounds like a good idea, indeed.

If you don't think this printer should be in scope of omd that is fine.

Well, on the one hand, it sounds like a cute addition. On the other, it look like something slightly specific that can very well be coded client-side, and I am a bit reticent to add a feature that will be used by a single project. I would like to think about this a bit more.

By the way. Did you think about creating a markdown output, this will allow creating a pretty printer for markdown (automatic prose-wrapping)?

Yes, we used to have a Markdown backend, but I removed it because it was incomplete/buggy. However, recently someone else also requested a markdown backend, so am planning to put it back in (but haven't done so yet).

@mseri
Copy link
Contributor

mseri commented Mar 9, 2021

Nice, this would allow getting rid of https://github.com/mseri/md2mld

The rationale there was that many packages have extensive README that would be nice to bundle as documentation introductions or tutorials (instead of always relegating them to the repository)

@jfrolich
Copy link
Contributor Author

jfrolich commented Mar 9, 2021

this would allow getting rid of https://github.com/mseri

Yes!

@shonfeder
Copy link
Collaborator

We'll revisit this once we've stabilized the AST and have some answers to #205.

In the meantime, I wonder if it would make sense to connect with the ocamldoc maintainers to see how they feel about this kind of feature, and if they have any opinions/suggestions on how to execute in way that would work best with the rest of the ecosystem.

@mseri
Copy link
Contributor

mseri commented Apr 11, 2021

Sure! @jfrolich in the meantime, feel free to submit any improvement from this PR that you may need to md2mld

mseri added a commit to mseri/md2mld that referenced this pull request Jun 18, 2021
The interface of odoc has already changed since 2.0.0~alpha1,
this is based on @jfrolich PR ocaml-community/omd#215
and is intended as an intermediate step to ease the port to the next
release of omd. Issue #5 will not be closed for the time being.

In particular there is a regression in the way we deal with blockquotes.
These need to be addressed anyway, see #2.

Signed-off-by: Marcello Seri <[email protected]>
mseri added a commit to mseri/md2mld that referenced this pull request Jun 18, 2021
The interface of omd has already changed since 2.0.0~alpha1,
this is based on @jfrolich PR ocaml-community/omd#215
and is intended as an intermediate step to ease the port to the next
release of omd. Issue #5 will not be closed for the time being.

In particular there is a regression in the way we deal with blockquotes.
These need to be addressed anyway, see #2.

Signed-off-by: Marcello Seri <[email protected]>
mseri added a commit to mseri/opam-repository that referenced this pull request Jun 25, 2021
CHANGES:

- use html blockquotes
- port to omd 2.0.0~alpha1 -- including cross-linking features (from ocaml-community/omd#215)
- trim output
- modified argument parsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants