Skip to content

Add script to convert to Google Docstring style #2290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions util/convert_rst_to_google_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

https://github.com/pythonarcade/arcade/issues/1797
"""
print("Note: this is partially complete, use convert_rst_to_google_docs.sh instead!")
exit(1)

import glob
import re
Expand Down
78 changes: 78 additions & 0 deletions util/convert_rst_to_google_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash

# Easy Wrapper around the docconvert python package
# https://pypi.org/project/docconvert/

requires() {
cat <<EOF
Before using, please make sure to do the following:
1. Follow the contributor setup in CONTRIBUTING.md
2. pip install docconvert
EOF
}

if [ -z "$(which docconvert)" ]; then
echo "ERROR: Couldn't find docconvert!" 1>&2
requires 1>&2
exit 1
fi


Usage() {
cat <<EOF
$0 FILE_OR_FILES ...

An easy wrapper around the Python-based docconvert utility.
https://pypi.org/project/docconvert/

EOF
requires
cat <<EOF

After setup, use as follows:

1. $0 arcade/name.py
2. ./make.py serve
3. look at the pages in browser to make sure they're good

EOF
}

if [ "$#" -eq 0 ] || [ "$1" == "--help" ]; then
Usage
exit 0
fi


CONFIG_FILE="docconvert.json"
ensure_have_config() {
if [ -f "$CONFIG_FILE" ]; then
echo "Already have config file $CONFIG_FILE"
return
fi

echo "Writing a default config file to $CONFIG_FILE"
# This is a default file which sort-of does a decent job on
# current versions of docconvert. You may want use "guess" for
# the input style in some cases, either via editing the json
# of the -i flag. See the Usage for docconvert to learn more:
# https://pypi.org/project/docconvert/
cat <<EOF > $CONFIG_FILE
{
"input_style": "rest",
"output_style": "google",
"accepted_shebangs": [
"python"
],
"output": {
"first_line": true,
"remove_type_backticks": "false",
"use_types": false
}
}
EOF
}
ensure_have_config
echo "Attempting docconvert..."

docconvert --config $CONFIG_FILE --in-place "$@"
Loading