Skip to content

Commit 37a3a6f

Browse files
authored
Improve make script ergonomics & documentation (#1739)
* Allow make script to be run with ./make.py on *NIX systems * Cover enabling ./make.py syntax in CONTRIBUTING.md * Improve top-level docstring of make.py * Add shell completion setup instructions * Move optional Mac & Linux instructions to the end of CONTRIBUTING.md * Make execution permission user-specific * Improve whichshell subcommand * Tweak phrasing at end of CONTRIBUTING.md
1 parent 3b94e5a commit 37a3a6f

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ Upgrade by running the following command:
6464
pip install --upgrade pip
6565
```
6666

67+
Mac & Linux users can improve their development experience further by following the optional
68+
steps at the end of this document.
69+
6770
## Testing
6871

6972
You should test your changes locally before submitting a pull request
@@ -135,3 +138,56 @@ python -m http.server -d doc/build/html
135138
You can now open [http://localhost:8000](http://localhost:8000) in your browser to preview the doc.
136139

137140
Be sure to re-run build & refresh to update after making changes!
141+
142+
## Optional: Improve Ergonomics on Mac and Linux
143+
144+
### Enable `./make.py`
145+
146+
On Mac & Linux, you can enable running `make.py` using `./make.py` instead
147+
of `python make.py` as follows:
148+
149+
1. Make sure you are in the root directory of the repo
150+
2. Run `chmod u+x make.py`
151+
152+
You can run the make script with `./make.py` instead of `python make.py`.
153+
154+
For example, this command:
155+
```commandline
156+
python make.py lint
157+
```
158+
159+
can now be run this way:
160+
```shell
161+
./make.py lint
162+
```
163+
164+
### Enable Shell Completions
165+
166+
After enabling the short-form syntax as outlined above, you can also enable tab
167+
completion for commands on the following supported shells:
168+
169+
* `bash` (the most common default shell)
170+
* `zsh`
171+
* `fish`
172+
* `powershell`
173+
* `powersh`
174+
175+
For example, if you have typed the following...
176+
```shell
177+
./make.py h
178+
```
179+
180+
Tab completion would allow you to press tab to auto-complete the command:
181+
```shell
182+
./make.py html
183+
```
184+
185+
To enable this feature, most users can follow these steps:
186+
187+
1. Run `./make.py whichshell` to find out what your default shell is
188+
2. If it is one of the supported shells, run `./make.py --install-completion $(basename "$SHELL")`
189+
3. Restart your terminal
190+
191+
If your default shell is not the shell you prefer using for arcade development,
192+
you may need to specify it to the command above directly instead of using
193+
autodetection.

make.py

100644100755
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
#!/usr/bin/env python3
12
"""
2-
Build script for documentation
3+
Build script to simplify running:
4+
5+
* Tests
6+
* Code quality checks
7+
* Documentation builds
8+
9+
For help, see the following:
10+
11+
* CONTRIBUTING.md
12+
* The output of python make.py --help
313
"""
414
import os
515
from contextlib import contextmanager
@@ -444,5 +454,26 @@ def test():
444454
run([PYTEST, UNITTESTS])
445455

446456

457+
SHELLS_WITH_AUTOCOMPLETE = (
458+
'bash',
459+
'zsh',
460+
'fish',
461+
'powershell',
462+
'powersh'
463+
)
464+
465+
466+
@app.command()
467+
def whichshell():
468+
"""to find out which shell your system seems to be running"""
469+
470+
shell_name = Path(os.environ.get('SHELL')).stem
471+
print(f"Your default shell appears to be: {shell_name}")
472+
473+
if shell_name in SHELLS_WITH_AUTOCOMPLETE:
474+
print("This shell is known to support tab-completion!")
475+
print("See CONTRIBUTING.md for more information on how to enable it.")
476+
477+
447478
if __name__ == "__main__":
448479
app()

0 commit comments

Comments
 (0)