Skip to content

Commit 8b6f60f

Browse files
authoredJan 9, 2025··
Merge pull request #9 from svix/jplatte/deprecated-ops
Generate deprecation annotations / javadoc markers
2 parents 21ea921 + 3dfe183 commit 8b6f60f

4 files changed

+22
-2
lines changed
 

‎src/template.rs

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ pub(crate) fn env() -> Result<minijinja::Environment<'static>, minijinja::Error>
4646
.to_string())
4747
},
4848
);
49+
env.add_filter(
50+
"with_javadoc_deprecation",
51+
|s: Cow<'_, str>, deprecated: bool| {
52+
if deprecated {
53+
if s.is_empty() {
54+
"@deprecated".to_owned()
55+
} else {
56+
s.into_owned() + "\n\n@deprecated"
57+
}
58+
} else {
59+
s.into_owned()
60+
}
61+
},
62+
);
4963

5064
Ok(env)
5165
}

‎templates/svix_lib_resource.kt.jinja

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ class {{ resource_type_name }} internal constructor(token: String, options: Svix
5050
{% set has_required_query_params =
5151
op.query_params | selectattr("required") | length > 0 -%}
5252
{% set has_header_params = op.header_params | length > 0 -%}
53-
{{ op.description | to_doc_comment(style="kotlin") }}
53+
{{ op.description | with_javadoc_deprecation(op.deprecated) | to_doc_comment(style="kotlin") }}
54+
{% if op.deprecated -%}
55+
@Deprecated
56+
{% endif -%}
5457
suspend fun {{ op.name | to_lower_camel_case }}(
5558
{# path parameters -#}
5659
{% for p in op.path_params -%}

‎templates/svix_lib_resource.rs.jinja

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ impl<'a> {{ resource_type_name }}<'a> {
5555
{% if op.description is defined -%}
5656
{{ op.description | to_doc_comment(style="rust") }}
5757
{% endif -%}
58+
{% if op.deprecated -%}
59+
#[deprecated]
60+
{% endif -%}
5861
pub async fn {{ op.name | to_snake_case }}(
5962
&self,
6063

‎templates/svix_lib_resource.ts.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class {{ resource_type_name }} {
4141
{% set has_header_params = op.header_params | length > 0 -%}
4242
{% set response_type =
4343
op.response_body_schema_name | default("void") | replace("_", "") -%}
44-
{{ op.description | to_doc_comment(style="js") }}
44+
{{ op.description | with_javadoc_deprecation(op.deprecated) | to_doc_comment(style="js") }}
4545
public {{ op.name | to_lower_camel_case }}(
4646
{# path parameters -#}
4747
{% for p in op.path_params -%}

0 commit comments

Comments
 (0)
Please sign in to comment.