Skip to content

Commit c8a5ffd

Browse files
authoredApr 19, 2017
Merge pull request #2729 from getnikola/adjusting-to-new-pydocstyle-rules
Fixing docstrings so the new version of pydocstyle likes them.
2 parents 91ae017 + ab2f668 commit c8a5ffd

16 files changed

+35
-30
lines changed
 

‎nikola/nikola.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class Nikola(object):
389389
"""
390390

391391
def __init__(self, **config):
392-
"""Setup proper environment for running tasks."""
392+
"""Initialize proper environment for running tasks."""
393393
# Register our own path handlers
394394
self.path_handlers = {
395395
'slug': self.slug_path,
@@ -1873,7 +1873,7 @@ def root_path(self, name, lang):
18731873
return []
18741874

18751875
def slug_path(self, name, lang):
1876-
"""A link to a post with given slug, if not ambiguous.
1876+
"""Return a link to a post with given slug, if not ambiguous.
18771877
18781878
Example:
18791879
@@ -2180,7 +2180,7 @@ def scan_posts(self, really=False, ignore_quit=False, quiet=False):
21802180
signal('scanned').send(self)
21812181

21822182
def generic_renderer(self, lang, output_name, template_name, filters, file_deps=None, uptodate_deps=None, context=None, context_deps_remove=None, post_deps_dict=None, url_type=None, is_fragment=False):
2183-
"""Helper function for rendering pages and post lists and other related pages.
2183+
"""Create tasks for rendering pages and post lists and other related pages.
21842184
21852185
lang is the current language.
21862186
output_name is the destination file name.

‎nikola/plugin_categories.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def create_post(self, path, content=None, onefile=False, is_page=False, **kw):
325325
raise NotImplementedError()
326326

327327
def extension(self):
328-
"""The preferred extension for the output of this compiler."""
328+
"""Return the preferred extension for the output of this compiler."""
329329
return ".html"
330330

331331
def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False, lang=None):
@@ -690,9 +690,10 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
690690
raise NotImplementedError()
691691

692692
def get_overview_path(self, lang, dest_type='page'):
693-
"""A path handler for the classification overview.
693+
"""Return path for classification overview.
694694
695-
Must return one or two values (in this order):
695+
This path handler for the classification overview must return one or
696+
two values (in this order):
696697
* a list or tuple of strings: the path relative to OUTPUT_DIRECTORY;
697698
* a string with values 'auto', 'always' or 'never', indicating whether
698699
INDEX_FILE should be added or not.
@@ -710,9 +711,10 @@ def get_overview_path(self, lang, dest_type='page'):
710711
raise NotImplementedError()
711712

712713
def get_path(self, classification, lang, dest_type='page'):
713-
"""A path handler for the given classification.
714+
"""Return path to the classification page.
714715
715-
Must return one to three values (in this order):
716+
This path handler for the given classification must return one to
717+
three values (in this order):
716718
* a list or tuple of strings: the path relative to OUTPUT_DIRECTORY;
717719
* a string with values 'auto', 'always' or 'never', indicating whether
718720
INDEX_FILE should be added or not;

‎nikola/plugins/command/serve.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ def log_message(self, *args):
203203
# Note that it might break in future versions of Python, in which case we
204204
# would need to do even more magic.
205205
def send_head(self):
206-
"""Common code for GET and HEAD commands.
206+
"""Send response code and MIME header.
207207
208-
This sends the response code and MIME headers.
208+
This is common code for GET and HEAD commands.
209209
210210
Return value is either a file object (which has to be copied
211211
to the outputfile by the caller unless the command was HEAD,

‎nikola/plugins/compile/markdown/mdx_podcast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def handleMatch(self, m):
6969

7070

7171
class PodcastExtension(MarkdownExtension, Extension):
72-
""""Podcast extension for Markdown."""
72+
"""Podcast extension for Markdown."""
7373

7474
def __init__(self, configs={}):
7575
"""Initialize extension."""

‎nikola/plugins/compile/rest/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def new_document(self):
203203

204204
def shortcode_role(name, rawtext, text, lineno, inliner,
205205
options={}, content=[]):
206-
"""A shortcode role that passes through raw inline HTML."""
206+
"""Return a shortcode role that passes through raw inline HTML."""
207207
return [docutils.nodes.raw('', text, format='html')], []
208208

209209

@@ -270,7 +270,7 @@ def rst2html(source, source_path=None, source_class=docutils.io.StringInput,
270270
271271
publish_parts(..., settings_overrides={'input_encoding': 'unicode'})
272272
273-
Parameters: see `publish_programmatically`.
273+
For a description of the parameters, see `publish_programmatically`.
274274
275275
WARNING: `reader` should be None (or NikolaReader()) if you want Nikola to report
276276
reStructuredText syntax errors.

‎nikola/plugins/compile/rest/listing.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,8 @@ def get_code_from_file(self, data):
204204
return super(Listing, self).run()
205205

206206
def assert_has_content(self):
207-
"""Listing has no content, override check from superclass."""
207+
"""Override check from superclass with nothing.
208+
209+
Listing has no content, override check from superclass.
210+
"""
208211
pass

‎nikola/plugins/task/archive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
132132
return self.site.MESSAGES[lang]['{month} {day}, {year}'].format(year=year, month=month, day=day)
133133

134134
def get_path(self, classification, lang, dest_type='page'):
135-
"""A path handler for the given classification."""
135+
"""Return a path for the given classification."""
136136
components = [self.site.config['ARCHIVE_PATH']]
137137
if classification:
138138
components.extend(classification)

‎nikola/plugins/task/authors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def get_classification_friendly_name(self, author, lang, only_last_component=Fal
9494
return author
9595

9696
def get_overview_path(self, lang, dest_type='page'):
97-
"""A path handler for the list of all classifications."""
97+
"""Return a path for the list of all classifications."""
9898
return [self.site.config['AUTHOR_PATH'](lang)], 'always'
9999

100100
def get_path(self, author, lang, dest_type='page'):
101-
"""A path handler for the given classification."""
101+
"""Return a path for the given classification."""
102102
if self.site.config['SLUG_AUTHOR_PATH']:
103103
slug = utils.slugify(author, lang)
104104
else:

‎nikola/plugins/task/categories.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
9898
return classification[-1] if classification else ''
9999

100100
def get_overview_path(self, lang, dest_type='page'):
101-
"""A path handler for the list of all classifications."""
101+
"""Return a path for the list of all classifications."""
102102
if self.site.config['CATEGORIES_INDEX_PATH'](lang):
103103
path = self.site.config['CATEGORIES_INDEX_PATH'](lang)
104104
if path.endswith('/index'): # TODO: remove in v8
@@ -128,7 +128,7 @@ def slugify_category_name(self, path, lang):
128128
return result
129129

130130
def get_path(self, classification, lang, dest_type='page'):
131-
"""A path handler for the given classification."""
131+
"""Return a path for the given classification."""
132132
return [_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f] + self.slugify_category_name(classification, lang), 'auto'
133133

134134
def extract_hierarchy(self, classification):

‎nikola/plugins/task/indexes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
9191
return self.site.config["BLOG_TITLE"](lang)
9292

9393
def get_path(self, classification, lang, dest_type='page'):
94-
"""A path handler for the given classification."""
94+
"""Return a path for the given classification."""
9595
if dest_type == 'rss':
9696
return [self.site.config['RSS_PATH'](lang)], True
9797
# 'page' (index) or 'feed' (Atom)

‎nikola/plugins/task/listings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f
260260
}, self.kw["filters"])
261261

262262
def listing_source_path(self, name, lang):
263-
"""A link to the source code for a listing.
263+
"""Return a link to the source code for a listing.
264264
265265
It will try to use the file name if it's not ambiguous, or the file path.
266266
@@ -276,7 +276,7 @@ def listing_source_path(self, name, lang):
276276
return result
277277

278278
def listing_path(self, namep, lang):
279-
"""A link to a listing.
279+
"""Return a link to a listing.
280280
281281
It will try to use the file name if it's not ambiguous, or the file path.
282282

‎nikola/plugins/task/page_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_classification_friendly_name(self, dirname, lang, only_last_component=Fa
7676
return dirname
7777

7878
def get_path(self, hierarchy, lang, dest_type='page'):
79-
"""A path handler for the given classification."""
79+
"""Return a path for the given classification."""
8080
return hierarchy, 'always'
8181

8282
def extract_hierarchy(self, dirname):

‎nikola/plugins/task/sections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_classification_friendly_name(self, section, lang, only_last_component=Fa
9797
return self._get_section_name(section, lang)
9898

9999
def get_path(self, section, lang, dest_type='page'):
100-
"""A path handler for the given classification."""
100+
"""Return a path for the given classification."""
101101
result = [_f for _f in [section] if _f]
102102
if dest_type == 'rss':
103103
return result + ['rss.xml'], 'never'

‎nikola/plugins/task/tags.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def slugify_tag_name(self, name, lang):
102102
return name
103103

104104
def get_overview_path(self, lang, dest_type='page'):
105-
"""A path handler for the list of all classifications."""
105+
"""Return a path for the list of all classifications."""
106106
if self.site.config['TAGS_INDEX_PATH'](lang):
107107
path = self.site.config['TAGS_INDEX_PATH'](lang)
108108
if path.endswith('/index'): # TODO: remove in v8
@@ -113,7 +113,7 @@ def get_overview_path(self, lang, dest_type='page'):
113113
return [_f for _f in [self.site.config['TAG_PATH'](lang)] if _f], 'always'
114114

115115
def get_path(self, classification, lang, dest_type='page'):
116-
"""A path handler for the given classification."""
116+
"""Return a path for the given classification."""
117117
return [_f for _f in [
118118
self.site.config['TAG_PATH'](lang),
119119
self.slugify_tag_name(classification, lang)] if _f], 'auto'

‎nikola/post.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def _has_pretty_url(self, lang):
295295

296296
@property
297297
def is_mathjax(self):
298-
"""True if this post has the mathjax tag in the current language or is a python notebook."""
298+
"""Return True if this post has the mathjax tag in the current language or is a python notebook."""
299299
if self.compiler.name == 'ipynb':
300300
return True
301301
lang = nikola.utils.LocaleBorg().current_lang
@@ -724,7 +724,7 @@ def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_li
724724

725725
@property
726726
def reading_time(self):
727-
"""Reading time based on length of text."""
727+
"""Return reading time based on length of text."""
728728
if self._reading_time is None:
729729
text = self.text(strip_html=True)
730730
words_per_minute = 220

‎nikola/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class CustomEncoder(json.JSONEncoder):
529529
"""Custom JSON encoder."""
530530

531531
def default(self, obj):
532-
"""Default encoding handler."""
532+
"""Create default encoding handler."""
533533
try:
534534
return super(CustomEncoder, self).default(obj)
535535
except TypeError:
@@ -1671,7 +1671,7 @@ def adjust_name_for_index_link(name, i, displayed_i, lang, site, force_addition=
16711671

16721672

16731673
def create_redirect(src, dst):
1674-
""""Create a redirection."""
1674+
"""Create a redirection."""
16751675
makedirs(os.path.dirname(src))
16761676
with io.open(src, "w+", encoding="utf8") as fd:
16771677
fd.write('<!DOCTYPE html>\n<head>\n<meta charset="utf-8">\n'

0 commit comments

Comments
 (0)
Please sign in to comment.