feat: support doc comments for functions args and validator params

- Add support to the formatter for these doc comments
- Add a new field to `Arg` `doc: Option<String>`
- Don't attach docs immediately after typechecking a module
  - instead we should do it on demand in docs, build, and lsp
  - the check command doesn't need to have any docs attached
  - doing it more lazily defers the computation until later making
    typechecking feedback a bit faster
- Add support for function arg and validator param docs in
  `attach_module_docs` methods
- Update some snapshots
- Add put_doc to Arg

closes #685
This commit is contained in:
rvcas
2023-10-16 13:33:14 -04:00
parent 10b9dc2042
commit e5801f9c19
16 changed files with 205 additions and 34 deletions

View File

@@ -82,6 +82,7 @@ pub fn param(is_validator_param: bool) -> impl Parser<Token, ast::UntypedArg, Er
.map_with_span(|(arg_name, annotation), span| ast::Arg {
location: span,
annotation,
doc: None,
tipo: (),
arg_name,
})

View File

@@ -17,6 +17,7 @@ Validator(
},
location: 21..26,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -28,6 +29,7 @@ Validator(
},
location: 28..32,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -39,6 +41,7 @@ Validator(
},
location: 34..37,
annotation: None,
doc: None,
tipo: (),
},
],
@@ -67,6 +70,7 @@ Validator(
},
location: 64..68,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -78,6 +82,7 @@ Validator(
},
location: 70..73,
annotation: None,
doc: None,
tipo: (),
},
],

View File

@@ -17,6 +17,7 @@ Validator(
},
location: 21..26,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -28,6 +29,7 @@ Validator(
},
location: 28..32,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -39,6 +41,7 @@ Validator(
},
location: 34..37,
annotation: None,
doc: None,
tipo: (),
},
],

View File

@@ -49,6 +49,7 @@ pub fn parser() -> impl Parser<Token, UntypedExpr, Error = ParseError> {
is_validator_param: false,
},
annotation: arg_annotation.clone(),
doc: None,
location,
tipo: (),
},
@@ -60,6 +61,7 @@ pub fn parser() -> impl Parser<Token, UntypedExpr, Error = ParseError> {
is_validator_param: false,
},
annotation: arg_annotation,
doc: None,
location,
tipo: (),
},

View File

@@ -50,6 +50,7 @@ pub fn params() -> impl Parser<Token, ast::UntypedArg, Error = ParseError> {
.map_with_span(|(arg_name, annotation), span| ast::Arg {
location: span,
annotation,
doc: None,
tipo: (),
arg_name,
})

View File

@@ -22,6 +22,7 @@ Fn {
arguments: [],
},
),
doc: None,
tipo: (),
},
],

View File

@@ -40,6 +40,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -58,6 +59,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -133,6 +135,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -151,6 +154,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -226,6 +230,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -244,6 +249,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -319,6 +325,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -337,6 +344,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -405,6 +413,7 @@ Sequence {
},
location: 106..108,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -416,6 +425,7 @@ Sequence {
},
location: 106..108,
annotation: None,
doc: None,
tipo: (),
},
],
@@ -484,6 +494,7 @@ Sequence {
},
location: 129..131,
annotation: None,
doc: None,
tipo: (),
},
Arg {
@@ -495,6 +506,7 @@ Sequence {
},
location: 129..131,
annotation: None,
doc: None,
tipo: (),
},
],
@@ -570,6 +582,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -588,6 +601,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -663,6 +677,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -681,6 +696,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -756,6 +772,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -774,6 +791,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -849,6 +867,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -867,6 +886,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -942,6 +962,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -960,6 +981,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -1035,6 +1057,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -1053,6 +1076,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],
@@ -1128,6 +1152,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
Arg {
@@ -1146,6 +1171,7 @@ Sequence {
arguments: [],
},
),
doc: None,
tipo: (),
},
],

View File

@@ -49,6 +49,7 @@ Sequence {
},
location: 0..0,
annotation: None,
doc: None,
tipo: (),
},
],
@@ -78,6 +79,7 @@ Sequence {
},
location: 52..53,
annotation: None,
doc: None,
tipo: (),
},
],