Skip to content

Commit c19a73f

Browse files
authored
Comment for client function (#469)
This change adds comments for the functions that each client has for YARD and IDE purposes. Since YARD seems to report errors if the comments are incorrect, This change also ensures that the command is executed in the CI job.
1 parent 3e4ceea commit c19a73f

18 files changed

Lines changed: 1086 additions & 350 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- run: bundle install
3636
- run: bundle exec rubocop
3737
- run: bundle exec rspec
38+
- run: bundle exec yard stats ./lib/line/bot/v2 --fail-on-warning
3839

3940
rbs:
4041
runs-on: ubuntu-latest

CONTRIBUTING.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
## How to contribute to LINE Bot SDK for Ruby project
1+
# How to contribute to LINE Bot SDK for Ruby project
22

3-
First of all, thank you so much for taking your time to contribute! LINE Bot SDK for Ruby is not very different from any other open
4-
source projects you are aware of. It will be amazing if you could help us by doing any of the following:
3+
First of all, thank you so much for taking your time to contribute!
4+
LINE Bot SDK for Ruby is not very different from any other open source projects you are aware of.
5+
It will be amazing if you could help us by doing any of the following:
56

6-
- File an issue in [the issue tracker](https://github.com/line/line-bot-sdk-ruby/issues) to report bugs and propose new features and
7-
improvements.
7+
- File an issue in [the issue tracker](https://github.com/line/line-bot-sdk-ruby/issues) to report bugs and propose new features and improvements.
88
- Ask a question using [the issue tracker](https://github.com/line/line-bot-sdk-ruby/issues).
99
- Contribute your work by sending [a pull request](https://github.com/line/line-bot-sdk-ruby/pulls).
1010

11+
## Development
12+
13+
### YARD
14+
15+
We use [YARD](https://yardoc.org) to generate and maintain our code documentation.
16+
**Please make sure your new or modified code is also covered by proper YARD doc comments.**
17+
Good documentation ensures that contributors and users can easily read and understand how the methods and classes work.
18+
19+
#### How to generate and view documentation locally
20+
21+
##### 1. **Start a local documentation server**
22+
23+
Run the following command to start a local YARD server that will automatically reload when files change:
24+
25+
```bash
26+
bundle exec yard server --reload
27+
```
28+
29+
Then open the printed URL in your browser (e.g., http://localhost:8808).
30+
31+
##### 2. **Validate your documentation**
32+
33+
Before pushing your changes, run the following command to check YARD documentation coverage and warnings:
34+
```bash
35+
bundle exec yard stats ./lib/line/bot/v2 --fail-on-warning
36+
```
37+
This will fail if there are missing doc comments or any YARD-specific warnings.
38+
Make sure to fix any issues before creating a pull request.
39+
40+
For more details on how to write YARD doc comments, refer to YARD’s official [Getting Started guide](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md).
41+
1142
### Contributor license agreement
1243

13-
When you are sending a pull request and it's a non-trivial change beyond fixing typos, please make sure to sign
14-
[the ICLA (individual contributor license agreement)](https://cla-assistant.io/line/line-bot-sdk-ruby). Please
15-
[contact us](mailto:dl_oss_dev@linecorp.com) if you need the CCLA (corporate contributor license agreement).
44+
When you are sending a pull request and it's a non-trivial change beyond fixing typos, please make sure to sign [the ICLA (individual contributor license agreement)](https://cla-assistant.io/line/line-bot-sdk-ruby).
45+
Please [contact us](mailto:dl_oss_dev@linecorp.com) if you need the CCLA (corporate contributor license agreement).

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ gem 'multipart-post', '~> 2.4.1', require: false
66

77
group :development, :test do
88
# ref: http://docs.rubocop.org/en/latest/installation/
9+
gem 'rack', '~> 2.2'
910
gem 'rubocop', '~> 1.75.0', require: false
11+
gem 'webrick', '~> 1.9.1'
1012
gem 'yard', '~> 0.9.20'
1113
end
1214

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ GEM
2727
prism (1.4.0)
2828
public_suffix (6.0.1)
2929
racc (1.8.1)
30+
rack (2.2.13)
3031
rainbow (3.1.1)
3132
rake (13.2.1)
3233
regexp_parser (2.10.0)
@@ -66,20 +67,24 @@ GEM
6667
addressable (>= 2.8.0)
6768
crack (>= 0.3.2)
6869
hashdiff (>= 0.4.0, < 2.0.0)
70+
webrick (1.9.1)
6971
yard (0.9.37)
7072

7173
PLATFORMS
74+
arm64-darwin-21
7275
arm64-darwin-22
7376
x86_64-linux
7477

7578
DEPENDENCIES
7679
addressable (~> 2.3)
7780
line-bot-api!
7881
multipart-post (~> 2.4.1)
82+
rack (~> 2.2)
7983
rake (~> 13.0)
8084
rspec (~> 3.13.0)
8185
rubocop (~> 1.75.0)
8286
webmock (~> 3.25.0)
87+
webrick (~> 1.9.1)
8388
yard (~> 0.9.20)
8489

8590
BUNDLED WITH

generator/src/main/resources/line-bot-sdk-ruby-generator/api.pebble

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ module Line
5555
{%- for op in operations.operation %}
5656

5757
# {{ op.notes }}
58+
# This requests to <code>{{ op.httpMethod }} {{ endpoint(operations.classname) }}{{ op.path }}</code>
5859
#
59-
{% if op.summary -%}
60-
# @summary {{ op.summary }}
61-
{% endif -%}
6260
{% for param in op.allParams -%}
63-
# @param {{param.paramName}} {{param.description}}
61+
# @param {{param.paramName}} [{{ param.dataType }}{{ param.required ? '' : ', nil' }}] {{param.description}}
6462
{% endfor -%}
6563
{% if op.isDeprecated -%}
6664
# @deprecated
@@ -70,7 +68,15 @@ module Line
7068
{% endif -%}
7169
{% if op.externalDocs.url != null -%}
7270
# @see {{op.externalDocs.url}}
73-
{% endif -%}
71+
{%- endif %}
72+
# @return [response body, response status code, and response headers]
73+
{%- for response in op.responses %}
74+
{%- if response.content['application/json'].schema.complexType != null %}
75+
# @return [Array(Line::Bot::V2::{{ packageName | camelize }}::{{ response.content['application/json'].schema.complexType }}, Integer, Hash{String => String})] when HTTP status code is {{ response.code }}
76+
{%- else %}
77+
# @return [Array(String(nilable), Integer, Hash{String => String})] when HTTP status code is {{ response.code }}
78+
{%- endif %}
79+
{%- endfor %}
7480
def {{op.nickname}}_with_http_info({% for param in op.allParams %}
7581
{{param.paramName}}:{{ param.required ? '' : ' nil' }}{{ loop.last ? '' : ',' -}}
7682
{% endfor %}
@@ -120,12 +126,11 @@ module Line
120126
end
121127

122128
# {{ op.notes }}
129+
# This requests to <code>{{ op.httpMethod }} {{ endpoint(operations.classname) }}{{ op.path }}</code>
130+
# When you want to get HTTP status code or response headers, use {{ '{#' }}{{op.nickname}}_with_http_info} instead of this.
123131
#
124-
{% if op.summary -%}
125-
# @summary {{ op.summary }}
126-
{% endif -%}
127132
{% for param in op.allParams -%}
128-
# @param {{param.paramName}} {{param.description}}
133+
# @param {{param.paramName}} [{{ param.dataType }}{{ param.required ? '' : ', nil' }}] {{param.description}}
129134
{% endfor -%}
130135
{% if op.isDeprecated -%}
131136
# @deprecated
@@ -135,7 +140,14 @@ module Line
135140
{% endif -%}
136141
{% if op.externalDocs.url != null -%}
137142
# @see {{op.externalDocs.url}}
138-
{% endif -%}
143+
{%- endif %}
144+
{%- for response in op.responses %}
145+
{%- if response.content['application/json'].schema.complexType != null %}
146+
# @return [Line::Bot::V2::{{ packageName | camelize }}::{{ response.content['application/json'].schema.complexType }}] when HTTP status code is {{ response.code }}
147+
{%- else %}
148+
# @return [String, nil] when HTTP status code is {{ response.code }}
149+
{%- endif %}
150+
{%- endfor %}
139151
def {{op.nickname}}({% for param in op.allParams %}
140152
{{param.paramName}}:{{ param.required ? '' : ' nil' }}{{ loop.last ? '' : ',' -}}
141153
{% endfor %}

generator/src/main/resources/line-bot-sdk-ruby-rbs-generator/api.pebble

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ module Line
1919

2020
# {{ op.notes }}
2121
#
22-
{% if op.summary -%}
23-
# @summary {{ op.summary }}
24-
{% endif -%}
2522
{% for param in op.allParams -%}
2623
# @param {{ param.paramName }} {{ param.description }}
2724
{% endfor -%}
@@ -42,9 +39,6 @@ module Line
4239

4340
# {{ op.notes }}
4441
#
45-
{% if op.summary -%}
46-
# @summary {{ op.summary }}
47-
{% endif -%}
4842
{% for param in op.allParams -%}
4943
# @param {{ param.paramName }} {{ param.description }}
5044
{% endfor -%}

0 commit comments

Comments
 (0)