Skip to content

Add docstrings to everything  #109

Description

@KevinHock

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions