-
Notifications
You must be signed in to change notification settings - Fork 102
Markdown output #1341
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 output #1341
Conversation
* 'master' of github.com:/ocaml/odoc: (31 commits) Update docs Parser: Ensure parser can be called concurrently Parser: Fixes following PR review Parser: more tests Parser: Allow \ddd escape sequence in code-block metadata Parser: Use lexer for quoted strings in code block metadata Simplify code-block tag types and parser Warn on escaped character that does not need escaping Tag parsing: Unescape everything Make ocamlformat ignore cppo file Fix odoc_of_md wrt new tag type Fix typo Disable extract-code on OCaml < 4.10 Extract code: handle error Add location to the whole tag block Add location to binding key and value Add location for tag/binding Fix unescaping of quoted strings Parse code block tags OCaml 4.14 compatibility ...
…-cmarkit * 'markdown-output' of github.com:davesnx/odoc: Remove copyright from markdown generation Use cppo to hide Generator from dune build remove 'tree' from cram Install cmarkit on 4.14 Expose Config and Generator
Implement our own markdown rendering
|
I updated this PR with davesnx#1 without the cmarkit library. I worked on a separate branch to make the review easier. I added an attribution comment, but should other attribution be made on the LICENSE? |
| ```ocaml | ||
| let x = 42 | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not very familiar with source-impl, but I wanted to add the implementation in case was helpful somewhow, would be nice to ensure this is correct
|
I was playing around with this and found that the module type X = sig
type t = int
end
module type T = sig
include X
endthe output file # Module type `Foo.T` |
|
I've also been playing with Claude code, so there's a commit fixing it on my fork here: jonludlam@926cca1 - do with that what you will :-) |
|
I can't reproduce the issue, even though the code might make sense. Pushed a cram update here: df7f5f1 |
|
I've dumped the contents of the two new modules in the test - do you see what I mean now? |
|
Gotcha, includes on their respective pages |
|
Merged! |
CHANGES: ### Added - Exposed sherlodoc libraries for use in other projects (@jonludlam, ocaml/odoc#1349) - OCaml 5.4.0 support (@Octachron, ocaml/odoc#1355) - New arguments to LaTeX generator, --shorten-beyond-depth and --remove-functor-arg-link (@Octachron, ocaml/odoc#1337) - New experimental markdown generator (@davesnx, ocaml/odoc#1341) ### Changed - Remove cmdliner compatibility layer, no longer needed (@dbuenzli, ocaml/odoc#1328) - Drop support for OCaml < 4.08 (@jonludlam, ocaml/odoc#1300) - Allow referencing libraries from package added in `odoc-config.sexp` (@panglesd, ocaml/odoc#1343) - Use full path in heading labels in LaTeX backend (@Octachron, ocaml/odoc#1332) - Separate page from anchor in LaTeX labels to prevent collisions (@Octachron, ocaml/odoc#1337) ### Fixed - Fix bug in parsing META files when there are no dependencies (@jonludlam, ocaml/odoc#1352) - Fix ocaml/odoc#1335 - incorrect rendering when on medium screen size with no global sidebar (@lukemaurer, ocaml/odoc#1361) - Fixed generation of occurrences for docs CI (@jonludlam, ocaml/odoc#1362)
CHANGES: - Exposed sherlodoc libraries for use in other projects (@jonludlam, ocaml/odoc#1349) - OCaml 5.4.0 support (@Octachron, ocaml/odoc#1355) - New arguments to LaTeX generator, --shorten-beyond-depth and --remove-functor-arg-link (@Octachron, ocaml/odoc#1337) - New experimental markdown generator (@davesnx, ocaml/odoc#1341) - Remove cmdliner compatibility layer, no longer needed (@dbuenzli, ocaml/odoc#1328) - Drop support for OCaml < 4.08 (@jonludlam, ocaml/odoc#1300) - Allow referencing libraries from package added in `odoc-config.sexp` (@panglesd, ocaml/odoc#1343) - Use full path in heading labels in LaTeX backend (@Octachron, ocaml/odoc#1332) - Separate page from anchor in LaTeX labels to prevent collisions (@Octachron, ocaml/odoc#1337) - Fix bug in parsing META files when there are no dependencies (@jonludlam, ocaml/odoc#1352) - Fix ocaml/odoc#1335 - incorrect rendering when on medium screen size with no global sidebar (@lukemaurer, ocaml/odoc#1361) - Fixed generation of occurrences for docs CI (@jonludlam, ocaml/odoc#1362)
| @@ -0,0 +1,608 @@ | |||
| (* This module is based on cmarkit (https://github.com/dbuenzli/cmarkit) which is distributed under the ISC License. *) | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this please be properly attributed. It's a bit baffling, I publish the code of my projects under one of the simplest license to abide to and people still fail to comply with it when they cut and paste or modify the code. The terms here seem pretty clear (emphasis is mine):
Copyright (c) 2020 The cmarkit programmers
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
Is it that complicated ?
Now I'm extra nice and won't complain if you add a simple spdx-license identifier rather than the full permission notice.
Basically just retain the simple header you can find in absolutely each of the sources you copy from. So that would be, at your formatting convenience:
(*---------------------------------------------------------------------------
Copyright (c) 2020 The cmarkit programmers. All rights reserved.
SPDX-License-Identifier: ISC
---------------------------------------------------------------------------*)
Or if you prefer:
(* Part of this code is:
Copyright (c) 2020 The cmarkit programmers. All rights reserved.
SPDX-License-Identifier: ISC *)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really sorry, Daniel, you're right. I'll fix this.
CHANGES: ### Added - Exposed sherlodoc libraries for use in other projects (@jonludlam, ocaml/odoc#1349) - OCaml 5.4.0 support (@Octachron, ocaml/odoc#1355) - New arguments to LaTeX generator, --shorten-beyond-depth and --remove-functor-arg-link (@Octachron, ocaml/odoc#1337) - New experimental markdown generator (@davesnx, ocaml/odoc#1341) ### Changed - Remove cmdliner compatibility layer, no longer needed (@dbuenzli, ocaml/odoc#1328) - Drop support for OCaml < 4.08 (@jonludlam, ocaml/odoc#1300) - Allow referencing libraries from package added in `odoc-config.sexp` (@panglesd, ocaml/odoc#1343) - Use full path in heading labels in LaTeX backend (@Octachron, ocaml/odoc#1332) - Separate page from anchor in LaTeX labels to prevent collisions (@Octachron, ocaml/odoc#1337) ### Fixed - Fix bug in parsing META files when there are no dependencies (@jonludlam, ocaml/odoc#1352) - Fix ocaml/odoc#1335 - incorrect rendering when on medium screen size with no global sidebar (@lukemaurer, ocaml/odoc#1361) - Fixed generation of occurrences for docs CI (@jonludlam, ocaml/odoc#1362) - Partial fix for ocaml/odoc#1369 - ensure that we never create a link to a hidden page (@jonludlam, ocaml/odoc#1370)
CHANGES: - Exposed sherlodoc libraries for use in other projects (@jonludlam, ocaml/odoc#1349) - OCaml 5.4.0 support (@Octachron, ocaml/odoc#1355) - New arguments to LaTeX generator, --shorten-beyond-depth and --remove-functor-arg-link (@Octachron, ocaml/odoc#1337) - New experimental markdown generator (@davesnx, ocaml/odoc#1341) - Remove cmdliner compatibility layer, no longer needed (@dbuenzli, ocaml/odoc#1328) - Drop support for OCaml < 4.08 (@jonludlam, ocaml/odoc#1300) - Allow referencing libraries from package added in `odoc-config.sexp` (@panglesd, ocaml/odoc#1343) - Use full path in heading labels in LaTeX backend (@Octachron, ocaml/odoc#1332) - Separate page from anchor in LaTeX labels to prevent collisions (@Octachron, ocaml/odoc#1337) - Fix bug in parsing META files when there are no dependencies (@jonludlam, ocaml/odoc#1352) - Fix ocaml/odoc#1335 - incorrect rendering when on medium screen size with no global sidebar (@lukemaurer, ocaml/odoc#1361) - Fixed generation of occurrences for docs CI (@jonludlam, ocaml/odoc#1362) - Partial fix for ocaml/odoc#1369 - ensure that we never create a link to a hidden page (@jonludlam, ocaml/odoc#1370)
Hi,
This PR might come out of the blue, but there's a good reason. Let me explain myself in the "Why" below.
Also, when I was half done, I discovered a stale PR (#791) targeting the same problem, and I thought it could be helpful to other people.
Why
We use
odocin Melange's documentation, to generate API references for Melange libraries, such as Belt, Js, and Stdlib. While the rest of the documentation is handled by vitepress a static site generator working with Markdown files, with a lot of interesting features.This works reasonably well, but creates a big barrier between the documentation sites:
For this reason, I wanted to generate markdown from odoc and (in the melange case) have another process that manipulates those markdown files to expand the documentation.
Another big use case for Markdown generation is Github, or any markdown renderer platform really.
How
I forked the HTML backend into a
markdown2, removed what's unnecessary, and implemented Markdown construction with cmarkit.I currently name it
markdown2since there isodoc_mdanddoc_of_mdunder the markdown folder. I suggest renamingmarkdown -> odoc-md(or justmd) andmarkdown2 -> markdownin a new PRNotes about implementation
--allow-htmlwhere I enable this functionality of outputting HTMLmarkdown-with-belt.tandmarkdown.t). I could probably split them or organise them differently.Example
melange-re/melange-re.github.io#224
Future work
—allow-htmloption I mentioned above