-
Notifications
You must be signed in to change notification settings - Fork 94
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 markdown syntax. #352
Comments
The systems I know of do not use markdown, but markdown plus some extra stuff because markdown doesn't let you express everything you need for API docs, so we'd need to give that some thought. There is also the question of which flavour markdown to use, and probably some debate to be had about markdown vs some of the other popular alternatives (e.g. rst, asciidoc, org mode).
ocamldoc always supported a mode where comments had this other format, so we'd need to check to see whether much existing code is using it. A simpler alternative to this might be to just add some of the classic markdown syntax to odoc's syntax. I think that only the reference syntax directly conflicts with existing stuff. |
On the topic of Markdown parsing, the omd parser has recently had a rewrite and is CommonMark compliant. However, it still has a few missing features before trunk can be released, so those interested in Markdown in odoc are encouraged to contribute fixes over there so that we have a robust implementation in OCaml first. |
I don't think it's a good idea to multiply syntaxes. Use of the But then I'm not sure markdown is such a good idea. For example inline code block are not well adapted to OCaml, I can never remember how to write a polymorphic variant with it. And as @lpw25 mentioned it misses important features that IIRC even CommonMark failed to add (e.g. section ids and references) so you'll need to invent something anyways at which point you can ask whether simply using I'm surprised by @lpw25's comment regarding that |
Along similar lines, I would definitely like to see odoc able to support a 'url resolution' mode, where you could use it as a preprocessor to resolve odoc references (written as a url). This would allow support documentation to link to types/modules/etc whilst being written in markdown/rst/whatever. Even better, eventually we could run it in a mode where the links would be resolved to a canonical source - docs.ocaml.org for example - and then you could use them in blog posts and the like. |
@jonludlam something similar is requested here. |
Ah yes, I'd missed that somehow. I'm thinking of some sort of uri schema: |
Why not; the argument on the cli of the request I mentioned could actually have that syntax. Note however that I think we should rather put more effort in fleshing out the |
A good way to tell if markdown syntax should be used is if the comments are of the form:
`(**
* This is a markdown comment. Typically people will always have leading
* stars to the left, aligned in a perfect vertical line. That is probably pretty
* well distinguished from a list of ocamldoc items.
*)`
Recent versions of tuareg are using this style of comment by default. So I don't think that you could use this style as a pattern to detect what you want. https://github.com/ocaml/tuareg/blob/master/tuareg.el#L2453
In addition, it seems that using this style of comment with leading characters is bad for accessibility reasons. At least for users relying on a text-to-speach program.
|
Why does it seem to be good enough for all the other languages' comments? (They also have @Khady: For taureg mode, shouldn't it only insert the |
@lpw25 I definitely agree markdown alone won't be sufficient. Maybe we could come up with a list of features that aren't directly available in markdown, but is available in ocamldoc, and then if we can come up with at least one way to create those features as special cases of markdown (not even implementing them, just showing it's possible), it would be enough to at least get the ball rolling on the most basic features, then encourage people to help fill out the longer tail of features. Merely adding the features to ocamldoc sounds appealing but I realized that one of the most important/common markdown constructs directly clashes with ocamldoc - the URL:
|
Another solution is to just create something that is "markdown-like". It wouldn't be a superset of ocamldoc (because of the conflicts I mentioned). But this other mode would let 90% of the things people try to do, just work on the first try. The primary conflicts are links, and inline code examples. Most of ocamldoc's This purpose of this feature request is to help newcomers by making their workflows more familiar. I think if odoc had a mode that supported the following, in addition to most of the features of
|
I've created a separate task for the Reason repo to explore performing this parsing transformation in the Reason parser itself. The upside would be that all the tools like odoc and merlin will just work. The downside is that it creates different conventions for Reason users than existing OCaml users. However that tends to match the interests/demands of OCaml and Reason users respectively, and the implementation would perform an automated translation at least in one direction. Does this sound like a better approach? |
@jordwalke to be honest I'm not sure you are making your users a service. The familiarity you are seeking for will quickly vanish as soon as those will have to write a section heading or references. They will also likely read code elsewhere and will meet an unfamiliar syntax so they will have to learn it anyways. But meanwhile you diluted the semantics of the language by providing more than one way of performing the same thing which is a cognitive and usability burden for everyone. That said from the above list you gave it would be interesting to keep the |
Some more context: This is a highly requested feature for new Reason syntax users. (Reason is a gateway for the web community). People writing Reason tend to write doc comments in markdown even if they are aware there is some other syntax (ocamldoc) for doing so. It's natural to them and they want their code to be more approachable to their non-Reason, non-OCaml coworkers who will not take the time to look up conventions of ocamldoc. (Rust also uses markdown as the convention). Markdown doc comments remove one more point of friction for newcomers.
The goal would be to increase support for mapping over markdown into ocamldoc including heading, and section heading references, and where there is no markdown equivalent, use |
Btw, I agree about downsides of confusion for there being two ways to do things, but the appeal of doing it at the Reason syntax toolchain is that you already have different syntax convention for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
I remain doubtful about the idea but people interested in the idea can give it a try with ocaml-doc/odoc-parser#15 |
Many in the web community use markdown syntax for their source documentation.
I know there is not a clean one to one mapping between markdown and ocamldoc syntax, but it would be nice to support even just the most basic markdown syntax.
A good way to tell if markdown syntax should be used is if the comments are of the form:
I've noticed that most ocamldoc comments are of the form:
Which allows you to pretty easily distinguish a list in ocamldoc format:
Is the markdown detection I suggested in the first example fairly robust?
The text was updated successfully, but these errors were encountered: