Skip to content

Commit ef437fb

Browse files
author
Petr Vesely
committed
[UR] Address review feedback
1 parent bbcf6f3 commit ef437fb

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

scripts/add_experimental_feature.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
from util import makoWrite
1212
import re
13+
import subprocess
1314

1415
def verify_kebab_case(input: str) -> bool:
1516
# kebab case regex from https://github.com/expandjs/expandjs/blob/master/lib/kebabCaseRegex.js
@@ -20,16 +21,34 @@ def verify_kebab_case(input: str) -> bool:
2021
return True
2122

2223

24+
def get_user_name_email_from_git_config():
25+
proc = subprocess.run(["git", "config", "user.name"], stdout=subprocess.PIPE)
26+
if proc.returncode != 0:
27+
raise Exception("Failed to get user name from git config.")
28+
user_name = proc.stdout.decode().strip()
29+
30+
proc = subprocess.run(["git", "config", "user.email"], stdout=subprocess.PIPE)
31+
if proc.returncode != 0:
32+
raise Exception("Failed to get user email from git config.")
33+
user_email = proc.stdout.decode().strip()
34+
35+
return user_name, user_email
36+
37+
2338
def main():
2439

2540
argParser = argparse.ArgumentParser()
2641
argParser.add_argument("name", help="must be lowercase and kebab case i.e. command-buffer", type=str)
42+
argParser.add_argument("--dry_run", help="run the script without generating any files", action='store_true')
2743
args = argParser.parse_args()
2844

2945
if not verify_kebab_case(args.name):
3046
print("Name must be lowercase and kebab-case i.e. command-buffer.")
3147
sys.exit(1)
3248

49+
user_name, user_email = get_user_name_email_from_git_config()
50+
user = {'email':user_email, 'name': user_name}
51+
3352
exp_feat_name = args.name
3453

3554
out_yml_name = f"exp-{exp_feat_name}.yml"
@@ -40,8 +59,9 @@ def main():
4059
out_yml_path = f"./scripts/core/{out_yml_name}"
4160
out_rst_path = f"./scripts/core/{out_rst_name}"
4261

43-
makoWrite(yaml_template_path, out_yml_path, name=exp_feat_name)
44-
makoWrite(rst_template_path, out_rst_path, name=exp_feat_name)
62+
if not args.dry_run:
63+
makoWrite(yaml_template_path, out_yml_path, name=exp_feat_name)
64+
makoWrite(rst_template_path, out_rst_path, name=exp_feat_name, user=user)
4565

4666

4767
print(f"""\

scripts/templates/exp_feat.rst.mako

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
${" ".join(name.split("-")).title()}
1111
================================================================================
1212

13-
.. _warning:
13+
.. warning::
1414

1515
Experimental features:
1616

@@ -20,63 +20,60 @@ ${" ".join(name.split("-")).title()}
2020
* Do not require conformance testing of their own additions.
2121

2222

23-
--------------------------------------------------------------------------------
2423
Terminology
2524
--------------------------------------------------------------------------------
26-
If your experimental feature introduces a new concept or terminoloyg. Please
27-
provide a detailed explanation in this section. If this does not apply to your
28-
feature you may freely delete this section.
25+
.. comment:
26+
If your experimental feature introduces a new concept or terminology. Please
27+
provide a detailed explanation in this section. If this does not apply to
28+
your feature you may freely delete this section.
2929

30-
--------------------------------------------------------------------------------
3130
Motivation
3231
--------------------------------------------------------------------------------
33-
In this section you *must* justify your motivation for adding this experimental
34-
feature. You should also state at least one adapter upon which this feature can
35-
be supported.
32+
.. comment:
33+
In this section you *must* justify your motivation for adding this
34+
experimental feature. You should also state at least one adapter upon which
35+
this feature can be supported.
3636

37-
--------------------------------------------------------------------------------
3837
API
3938
--------------------------------------------------------------------------------
40-
In this section you *must* list all additions your experimental feature will
41-
make to the Unified Runtime specification. If your experimental feature does not
42-
include additions from one or more of the sections listed below, you may freely
43-
remove them.
39+
.. comment:
40+
In this section you *must* list all additions your experimental feature will
41+
make to the Unified Runtime specification. If your experimental feature does
42+
not include additions from one or more of the sections listed below, you may
43+
freely remove them.
4444

45-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4645
Macros
4746
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4847
* <%text>${x}</%text>_EXP_MACRO
4948

50-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5149
Enums
5250
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5351
* <%text>${x}</%text>_exp_enum_t
5452

55-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5653
Structs
5754
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5855
* <%text>${x}</%text>_exp_struct_t
5956

60-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6157
Functions
6258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6359
* <%text>${x}</%text>FunctionExp
6460

65-
--------------------------------------------------------------------------------
6661
Changelog
6762
--------------------------------------------------------------------------------
63+
.. comment:
64+
When making a change to an experimental feature, increment the version and
65+
provide a brief description of the change in the table below.
6866

6967
+-----------+------------------------+
7068
| Revision | Changes |
7169
+===========+========================+
7270
| 1.0 | Intial Draft |
7371
+-----------+------------------------+
7472

75-
--------------------------------------------------------------------------------
7673
Contributors
7774
--------------------------------------------------------------------------------
78-
Please list all people who wish to be credited for contribution to this
79-
experimental feature.
75+
.. comment:
76+
Please list all people who wish to be credited for contribution to this
77+
experimental feature.
8078

81-
* Contributor One `contrib.one@email.com <contrib.one@email.com>`_
82-
* Contributor Two `contrib.two@email.com <contrib.one@email.com>`_
79+
* ${user['name']} `${user['email']} <${user['email']}>`_

0 commit comments

Comments
 (0)