Skip to content

Commit d694ff1

Browse files
kmykkyuridenamida
authored andcommitted
Add PR to the default templates (kyuridenamida#117)
* kyuridenamida#113 Add PR to the default templates * Fix the sentence of PR based on the review comment kyuridenamida#117 (comment)
1 parent e62a095 commit d694ff1

File tree

9 files changed

+18
-1
lines changed

9 files changed

+18
-1
lines changed

atcodertools/codegen/template_engine.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from jinja2 import Environment
66

7+
from atcodertools.release_management.version import __version__
8+
79

810
def _substitute(s, reps):
911
# http://stackoverflow.com/questions/36739667/python-templates-for-generating-python-code-with-proper-multiline-indentation
@@ -25,6 +27,13 @@ def _substitute(s, reps):
2527

2628

2729
def render(template, **kwargs):
30+
# TODO: refactoring: this should not be here.
31+
# TODO: refactoring: the URL should be imported from other module
32+
kwargs['atcodertools'] = {
33+
'version': __version__,
34+
'url': 'https://github.com/kyuridenamida/atcoder-tools',
35+
}
36+
2837
if "${" in template:
2938
# If the template is old, render with the old engine.
3039
# This logic is for backward compatibility

atcodertools/tools/templates/default_template.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ void solve({{ formal_arguments }}){
1717
}
1818
{% endif %}
1919

20+
// Generated by {{ atcodertools.version }} {{ atcodertools.url }} (tips: You use the default template now. You can remove this line by using your custom template)
2021
int main(){
2122
{% if prediction_success %}
2223
{{input_part}}
@@ -25,4 +26,4 @@ int main(){
2526
// Failed to predict input format
2627
{% endif %}
2728
return 0;
28-
}
29+
}

atcodertools/tools/templates/default_template.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Main {
1212
static final String NO = "{{ no_str }}";
1313
{% endif %}
1414

15+
// Generated by {{ atcodertools.version }} {{ atcodertools.url }} (tips: You use the default template now. You can remove this line by using your custom template)
1516
public static void main(String[] args) throws Exception {
1617
final Scanner sc = new Scanner(System.in);
1718
{% if prediction_success %}

atcodertools/tools/templates/default_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def solve({{ formal_arguments }}):
1919

2020
{% endif %}
2121

22+
# Generated by {{ atcodertools.version }} {{ atcodertools.url }} (tips: You use the default template now. You can remove this line by using your custom template)
2223
def main():
2324
{% if prediction_success %}
2425
def iterate_tokens():

atcodertools/tools/templates/default_template.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn solve({{ formal_arguments }}) {
1616
}
1717
{% endif %}
1818

19+
// Generated by {{ atcodertools.version }} {{ atcodertools.url }} (tips: You use the default template now. You can remove this line by using your custom template)
1920
fn main() {
2021
{% if prediction_success %}
2122
{{input_part}}

tests/resources/test_codegen/test_default_code_generators_and_templates/cpp/expected_default_generated_code.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void solve(long long N, long long M, std::vector<std::vector<std::string>> H, st
99

1010
}
1111

12+
// Generated by 1.1.2 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
1213
int main(){
1314
long long N;
1415
scanf("%lld",&N);

tests/resources/test_codegen/test_default_code_generators_and_templates/java/expected_default_generated_code.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Main {
66
static final String YES = "yes";
77
static final String NO = "NO";
88

9+
// Generated by 1.1.2 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
910
public static void main(String[] args) throws Exception {
1011
final Scanner sc = new Scanner(System.in);
1112
long N;

tests/resources/test_codegen/test_default_code_generators_and_templates/python/expected_default_generated_code.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def solve(N: int, M: int, H: "List[List[str]]", A: "List[int]", B: "List[float]"
99
return
1010

1111

12+
# Generated by 1.1.2 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
1213
def main():
1314
def iterate_tokens():
1415
for line in sys.stdin:

tests/resources/test_codegen/test_default_code_generators_and_templates/rust/expected_default_generated_code.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn solve(N: i64, M: i64, H: Vec<Vec<String>>, A: Vec<i64>, B: Vec<f64>, Q: i64,
88

99
}
1010

11+
// Generated by 1.1.2 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
1112
fn main() {
1213
let con = read_string();
1314
let mut scanner = Scanner::new(&con);

0 commit comments

Comments
 (0)