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

D104: Missing docstring in public package #127

merged 3 commits into from Aug 5, 2015
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -18,7 +18,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.join(os.path.abspath('.'), '..'))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

# -- General configuration ------------------------------------------------

@@ -266,8 +266,9 @@
issuetracker = 'github'
issuetracker_project = 'GreenSteam/pep257'

def generate_error_code_table():
from ..pep257 import ErrorRegistry
from pep257 import ErrorRegistry
with open(os.path.join('snippets', 'error_code_table.rst'), 'wt') as outf:

@@ -5,7 +5,12 @@ Release Notes
Current Development Version

Nothing here yet!
New Features

* Added the D104 error code - "Missing docstring in public package". This new
error is turned on by default. Missing docstring in `` files which
previously resulted in D100 errors ("Missing docstring in public module")
will now result in D104 (#105, #127).

0.6.0 - July 20th, 2015
@@ -141,6 +141,11 @@ def __str__(self):
return 'at module level'

class Package(Module):

"""A package is a module."""

class Function(Definition):

_nest = staticmethod(lambda s: {'def': NestedFunction,
@@ -397,8 +402,11 @@ def parse_module(self):
children = list(self.parse_definitions(Module, all=True))
assert self.current is None, self.current
end = self.line
module = Module(self.filename, self.source, start, end,
[], docstring, children, None, self.all)
cls = Module
if self.filename.endswith(''):
cls = Package
module = cls(self.filename, self.source, start, end,
[], docstring, children, None, self.all)
for child in module.children:
child.parent = module
log.debug("finished parsing module.")
@@ -579,6 +587,7 @@ def to_rst(cls):
D101 = D1xx.create_error('D101', 'Missing docstring in public class')
D102 = D1xx.create_error('D102', 'Missing docstring in public method')
D103 = D1xx.create_error('D103', 'Missing docstring in public function')
D104 = D1xx.create_error('D104', 'Missing docstring in public package')

D2xx = ErrorRegistry.create_group('D2', 'Whitespace Issues')
D200 = D2xx.create_error('D200', 'One-line docstring should fit on one line '
@@ -925,7 +934,8 @@ def check_docstring_missing(self, definition, docstring):
if (not docstring and definition.is_public or
docstring and is_blank(eval(docstring))):
codes = {Module: D100, Class: D101, NestedClass: D101,
Method: D102, Function: D103, NestedFunction: D103}
Method: D102, Function: D103, NestedFunction: D103,
Package: D104}
return codes[type(definition)]()

@@ -279,3 +279,13 @@ def foo():
assert code == 0
assert 'D301' not in err
assert 'D302' not in err

def test_missing_docstring_in_package():
with Pep257Env() as env:
with'', 'wt') as init:
pass # an empty package file
out, err, code = env.invoke_pep257()
assert code == 1
assert 'D100' not in err # shouldn't be treated as a module
assert 'D104' in err # missing docstring in package
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.