Skip to content

Commit 912c9ce

Browse files
committed
Tidy Kotlin docs
1 parent 3385a34 commit 912c9ce

File tree

2 files changed

+18
-41
lines changed

2 files changed

+18
-41
lines changed
Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,27 @@
1-
import androidx.appcompat.app.AppCompatActivity
2-
import android.os.Bundle
3-
import kotlinx.coroutines.GlobalScope
4-
import kotlinx.coroutines.launch
51
import {{ sdk.namespace | caseDot }}.Client
62
{% if method.parameters.all | filter((param) => param.type == 'file') | length > 0 %}
73
import {{ sdk.namespace | caseDot }}.models.InputFile
84
{% endif %}
95
import {{ sdk.namespace | caseDot }}.services.{{ service.name | caseUcfirst }}
106

11-
class MainActivity : AppCompatActivity() {
12-
override fun onCreate(savedInstanceState: Bundle?) {
13-
super.onCreate(savedInstanceState)
14-
setContentView(R.layout.activity_main)
15-
16-
val client = Client(applicationContext)
7+
val client = Client(context)
178
{% if method.security|length > 0 %}
18-
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
9+
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1910
{% for node in method.security %}
2011
{% for key,header in node|keys %}
21-
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo']}}") // {{node[header].description}}
22-
{% endfor %}
23-
{% endfor %}
24-
{% endif %}
12+
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo']}}") // {{node[header].description}}
13+
{% endfor %}{% endfor %}{% endif %}
2514

26-
val {{ service.name | caseCamel }} = {{ service.name | caseUcfirst }}(client)
15+
val {{ service.name | caseCamel }} = {{ service.name | caseUcfirst }}(client)
2716

28-
GlobalScope.launch {
29-
{% if method.type == 'webAuth' %} {% elseif method.type == 'location' %} val result = {% else %} val response = {% endif %}{{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% if method.parameters.all | length == 0 %}){% endif %}
17+
{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %}val result = {% else %}val response = {% endif %}{{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% if method.parameters.all | length == 0 %}){% endif %}
3018

31-
{% if method.type == "webAuth" %}
32-
activity = this@MainActivity,
33-
{% endif %}
3419
{% for parameter in method.parameters.all %}
3520
{% if parameter.required %}
36-
{{parameter.name}} = {{ parameter | paramExample }}{% if not loop.last %},{% endif %}
21+
{{parameter.name}} = {{ parameter | paramExample }}{% if not loop.last %},{% endif %}
3722

3823
{% endif %}
3924
{% if loop.last %}
40-
)
25+
)
4126
{% endif %}
42-
{% endfor %}
43-
{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %} println(result); // Resource URL{% else %} val json = response.body?.string(){% endif %}
44-
45-
}
46-
}
47-
}
27+
{% endfor %}

templates/kotlin/docs/kotlin/example.md.twig

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@ import {{ sdk.namespace | caseDot }}.models.InputFile
44
{% endif %}
55
import {{ sdk.namespace | caseDot }}.services.{{ service.name | caseUcfirst }}
66

7-
suspend fun main() {
8-
val client = Client(context)
7+
val client = Client(context)
98
{% if method.security|length > 0 %}
10-
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
9+
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1110
{% for node in method.security %}
1211
{% for key,header in node|keys %}
13-
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo']}}") // {{node[header].description}}
12+
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo']}}") // {{node[header].description}}
1413
{% endfor %}{% endfor %}{% endif %}
1514

16-
val {{ service.name | caseCamel }} = {{ service.name | caseUcfirst }}(client{% if service.globalParams | length %}{% for parameter in service.globalParams %}, {{ parameter | paramExample }}{% endfor %}{% endif %})
17-
{% if method.type == 'webAuth' %} {% elseif method.type == 'location' %} val result = {% else %} val response = {% endif %}{{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% if method.parameters.all | length == 0 %}){% endif %}
15+
val {{ service.name | caseCamel }} = {{ service.name | caseUcfirst }}(client)
16+
17+
{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %}val result = {% else %}val response = {% endif %}{{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% if method.parameters.all | length == 0 %}){% endif %}
1818

1919
{% for parameter in method.parameters.all %}
2020
{% if parameter.required %}
21-
{{parameter.name}} = {{ parameter | paramExample }}{% if not loop.last %},{% endif %}
21+
{{parameter.name}} = {{ parameter | paramExample }}{% if not loop.last %},{% endif %}
2222

2323
{% endif %}
2424
{% if loop.last %}
25-
)
25+
)
2626
{% endif %}
27-
{% endfor %}
28-
{% if method.type == 'webAuth' %}{% elseif method.type == 'location' %} println(result); // Resource URL{% else %} val json = response.body?.string(){% endif %}
29-
30-
}
27+
{% endfor %}

0 commit comments

Comments
 (0)