Skip to content

Generate documentation #930

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

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

Conversation

marvinborner
Copy link
Member

@marvinborner marvinborner commented Apr 8, 2025

  • annotate doc comments in Tree
    • right now this is only implemented as a POC (and breaks some Effekt code), we should combine this with the current efforts of annotating the tree with positions and types
  • add flags show-documentation and write-documentation for generating JSONs of documented nodes
    • these JSONs can be later used to generate API documentation for the website

@marvinborner
Copy link
Member Author

This is ready for review now.

Toplevel terms and selected 2nd level terms (such as operations or constructors in data/interface) now have a Doc attached. If documentation comments occur at invalid positions such as individual statements, the parser will crash (not a bug!)

We discussed my style of parsing doc comments, and I'm unsure what we've settled on. We may want to use the technique of @timsueberkrueb in #957 or the Scala 3 syntax. I think the current version looks fine though.

You can generate a JSON representation of files using effekt.sh --show-documentation <file> .. <file> or --write-documentation respectively. This JSON representation includes the top-level definitions as well as its relevant* fields. Importantly this includes definitions without documentation comments, since we don't use them everywhere yet.

*we may want to change/discuss the specifics in the future. For now this includes almost all non-statement/term fields of definitions.

Further work such as the frontend on which I worked in parallel will be merged in subsequent PRs (and in a different repository, most probably)

Also, should I add tests for documentation generation? (and where?)

@marvinborner marvinborner marked this pull request as ready for review April 26, 2025 15:59
@marvinborner marvinborner requested a review from b-studios April 26, 2025 15:59
@marzipankaiser
Copy link
Contributor

If documentation comments occur at invalid positions such as individual statements, the parser will crash (not a bug!)

Maybe adding a neg-Test for this would be useful (esp. since this also tests that doc-comments are at least detected in this case)?

@b-studios b-studios self-requested a review May 12, 2025 15:00
InterfaceDef(IdDef(id.name, id.span) withPositionOf op, tps, List(Operation(id, Many.empty(tps.span.synthesized), vps, bps, ret) withPositionOf op))
val doc = maybeDocumentation()
`effect` ~> operation(doc) match {
// TODO: which doc/span should be used when and where?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

@jiribenes jiribenes linked an issue May 20, 2025 that may be closed by this pull request
jiribenes added a commit that referenced this pull request May 22, 2025
IDK why, but on my machine, the output of `--time=json` uses decimal
commas instead decimal points, so `"lexer": { "my/awesome/file.effekt":
14,15 }, ...`
Let's not do that. :)

We should also think about using a proper JSON library, esp. if we use
it in both documentation (#930) and here, it might just be worth to
import
[`uJson`](http://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJSONforScala.html)
or something...
@timsueberkrueb
Copy link
Contributor

Great work 👍

There's one more TODO above for spans in a desugaring in the parser. I think the only way to guarantee they are correct is to create a test case. Let me know if I can help with that!
Otherwise it looks good to me, though I cannot guarantee that the spans not covered by the tests are correct.
I would write a test case for the TODO and then merge this.

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.

Extract documentation from comments
5 participants