A human-friendly DSL for ATProto Lexicons
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix doc comments

+29 -7
+29 -7
mlf-codegen/src/lib.rs
··· 171 171 required.push(field.name.name.clone()); 172 172 } 173 173 174 - let field_json = generate_type_json(&field.ty, usage_counts, workspace, current_namespace); 174 + let mut field_json = generate_type_json(&field.ty, usage_counts, workspace, current_namespace); 175 + // Add description if the field has doc comments 176 + if !field.docs.is_empty() { 177 + if let Some(obj) = field_json.as_object_mut() { 178 + obj.insert("description".to_string(), json!(extract_docs(&field.docs))); 179 + } 180 + } 175 181 properties.insert(field.name.name.clone(), field_json); 176 182 } 177 183 ··· 262 268 if !param.optional { 263 269 params_required.push(param.name.name.clone()); 264 270 } 265 - let param_json = generate_type_json(&param.ty, usage_counts, workspace, current_namespace); 271 + let mut param_json = generate_type_json(&param.ty, usage_counts, workspace, current_namespace); 272 + // Add description if the parameter has doc comments 273 + if !param.docs.is_empty() { 274 + if let Some(obj) = param_json.as_object_mut() { 275 + obj.insert("description".to_string(), json!(extract_docs(&param.docs))); 276 + } 277 + } 266 278 params_properties.insert(param.name.name.clone(), param_json); 267 279 } 268 280 ··· 329 341 if !param.optional { 330 342 params_required.push(param.name.name.clone()); 331 343 } 332 - let param_json = generate_type_json(&param.ty, usage_counts, workspace, current_namespace); 344 + let mut param_json = generate_type_json(&param.ty, usage_counts, workspace, current_namespace); 345 + // Add description if the parameter has doc comments 346 + if !param.docs.is_empty() { 347 + if let Some(obj) = param_json.as_object_mut() { 348 + obj.insert("description".to_string(), json!(extract_docs(&param.docs))); 349 + } 350 + } 333 351 params_properties.insert(param.name.name.clone(), param_json); 334 352 } 335 353 ··· 423 441 if !field.optional { 424 442 required.push(field.name.name.clone()); 425 443 } 426 - properties.insert( 427 - field.name.name.clone(), 428 - generate_type_json(&field.ty, usage_counts, workspace, current_namespace), 429 - ); 444 + let mut field_json = generate_type_json(&field.ty, usage_counts, workspace, current_namespace); 445 + // Add description if the field has doc comments 446 + if !field.docs.is_empty() { 447 + if let Some(obj) = field_json.as_object_mut() { 448 + obj.insert("description".to_string(), json!(extract_docs(&field.docs))); 449 + } 450 + } 451 + properties.insert(field.name.name.clone(), field_json); 430 452 } 431 453 432 454 let mut obj = Map::new();