prql icon indicating copy to clipboard operation
prql copied to clipboard

Doc comments

Open aljazerzen opened this issue 1 year ago • 7 comments

Followup for discussion #4110

Bottom line is that this will be the syntax for documentation comments:

  • #. doc comment for the next statement
  • #! doc comment for the parent module
  • @annotation for the next statement
  • @!annotation for the parent statement

As with annotations, doc comments can attach to any statements (variables, types, modules) and will be available in the AST. We can make a tool that extracts this information and converts it to HTML, so it can be published somehow.

ATM, this would be most useful with std.prql module, which would benefit from exposing a bit more documentation (especially with arithmetic functions).

I would ask to refrain bike-shedding the syntax, unless there is a serious concern about usability.

aljazerzen avatar Jan 29 '24 09:01 aljazerzen

I look forward to doc comments in the AST. I am working on some code to generate HTML documentation from a .prql file. I intend to integrate it with prqlc if that is okay.

vanillajonathan avatar Jan 29 '24 10:01 vanillajonathan

Sure - depending on how it is written it could be maintained in this repo as well. Would you be up for doing it in rust?

aljazerzen avatar Jan 29 '24 10:01 aljazerzen

Yes, it is written in Rust, and my intention is for it to be in this repo and part of the prqlc CLI tool.

vanillajonathan avatar Jan 29 '24 12:01 vanillajonathan

part of the prqlc CLI tool

It will probably have a bunch of HTML-related dependencies that we probably don't as dependencies of the prqlc. Could it be a separate binary?

aljazerzen avatar Jan 29 '24 13:01 aljazerzen

It will probably have a bunch of HTML-related dependencies that we probably don't as dependencies of the prqlc. Could it be a separate binary?

Yes, it could be a separate binary, however right now it doesn't have any dependencies at all, the HTML is just a string in Rust.

Like:

let mut html = String::new();

html.push_str("<html>");
html.push_str("</html>");

vanillajonathan avatar Jan 29 '24 13:01 vanillajonathan

Ah, ok that makes sense - I like your approach of making the initial version simple before adding too much dependencies. It can easily be part of prqlc then! Do you need any help with integrating with prqlc CLI?

aljazerzen avatar Jan 29 '24 15:01 aljazerzen

I created a PR at #4152, yes I would like some help integrating t with the prqlc CLI.

vanillajonathan avatar Jan 30 '24 15:01 vanillajonathan