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

Document doc string formatter in def, defn, ... #36

Open
crocket opened this issue Jan 19, 2020 · 2 comments
Open

Document doc string formatter in def, defn, ... #36

crocket opened this issue Jan 19, 2020 · 2 comments

Comments

@crocket
Copy link

crocket commented Jan 19, 2020

https://janet-lang.org/docs/bindings.html and https://janet-lang.org/docs/functions.html don't explain how multiline doc strings are formatted by doc string formatter.

@crocket crocket changed the title Document doc string formatter in functions. Document doc string formatter in def, defn, ... Jan 19, 2020
@bakpakin
Copy link
Member

The docstring formatter is used only to print documentation by the doc function - otherwise, docstrings are stored as written. (defn) just prepends the argument list to the docstring.

@sogaiu
Copy link
Contributor

sogaiu commented Feb 4, 2024

At around the time of the last comment, I think the code for doc-format (which is what I think this issue was referring to) was like this. I think that basically did rewrapping if necessary.

I think it does more now though. IIUC, this PR and subsequent development made constructs from Markdown (e.g. lists and code blocks) mean something within docstrings.

Investigation so far suggests to me that the docstring is parsed into a stack of tuples / arrays (which represent "blocks", which can in some cases be nested) and these are then re-emitted in the form of a buffer, accounting for markup (bold, code, italic, underline), indentation, width, and color settings. There appears to be specific handling for ordered / unordered lists as well as code blocks (fenced and indented may be).

Update: The Formatting with Markdown section does describe some (most/all?) of the supported constructs.

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

No branches or pull requests

3 participants