Skip to content
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

Add docstrings to everything #109

Open
KevinHock opened this issue Apr 15, 2018 · 0 comments
Open

Add docstrings to everything #109

KevinHock opened this issue Apr 15, 2018 · 0 comments

Comments

@KevinHock
Copy link
Collaborator

KevinHock commented Apr 15, 2018

You can do:

pip install pydocstyle
and then run this script while in the pyt directory

import os
import re
import subprocess
import sys


os.chdir(os.path.join('pyt'))

try:
    docstyle = subprocess.run(["pydocstyle", "--ignore=D105,D203,D212,D213"],
                              stderr=subprocess.PIPE, universal_newlines=True)
except FileNotFoundError:
    print('Error: Install pydocstyle with pip for python 3.'
          ' Something like: "sudo python -m pip install pydocstyle"')
    sys.exit()

lines = re.split('\n', docstyle.stderr)

errors = zip(lines[0::2], lines[1::2])

errors = [x + "\n\t" + y for x, y in errors]

errors = [error for error in errors if 'visit_' not in error]

for error in errors:
    print(error + '\n')

print("Total errors: {}".format(len(errors)))

It'll spit out which functions don't have docstrings or complain about something non-PEP 257 compliant.

This is a great way to learn the codebase, and everyone will love you for it.

The imports code for example does not have docstrings, for example.

For an example of great docstrings, see the user-defined function calls code.

Afterwards, we can maybe add it as a pre-commit hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant