fredrikekre / Literate.jl

Simple package for literate programming in Julia
https://fredrikekre.github.io/Literate.jl
Other
534 stars 61 forks source link

Standard multiline doc strings #216

Closed roland-KA closed 1 year ago

roland-KA commented 1 year ago

The standard way of documenting Julia elements (like functions, modules etc.) is to enclose a multiline comment in triple-".

But Literate doesn't seem to be able to identify them. The documentation says, that the following variant is possible:

md"""
some comment
"""

Did I miss something or is really not possible to extract standard multiline doc strings to markdown?

mortenpi commented 1 year ago

What do you mean by "identify them"? Literate doesn't really do anything with docstrings (that's more Documenter's responsibility). But if you load a Literate script into a Julia session (e.g. with include), the docstrings should be there.

roland-KA commented 1 year ago

I've expected that markdown creates a file where all comments (doc strings as well) are treated as "normal text" (and so get formatted this way when converted to PDF or HTML) and only Julia-code will be extracted as code blocks.

But I saw that only comments introduced by # are extracted as "normal text". Doc strings are treated like code. So Literate is unfortunately not very useful for my use case.

fredrikekre commented 1 year ago

Docstrings are code though, so I am a bit confused why you would expect something else. Can you elaborate?

roland-KA commented 1 year ago

Well, I was looking for a tool which would extract all documentation (not matter if it is documentation in comments or in doc-strings) from a Julia-file and convert it to a Markdown-file.

But then I learned, that Literate only works on comments this way and switched again to Documenter (which only extracts doc-strings). As the vast majority of my code is documented via doc-strings this was the better alternative.