aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile/rest
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/plugins/compile/rest')
-rw-r--r--nikola/plugins/compile/rest/__init__.py40
-rw-r--r--nikola/plugins/compile/rest/chart.plugin16
-rw-r--r--nikola/plugins/compile/rest/chart.py25
-rw-r--r--nikola/plugins/compile/rest/doc.plugin16
-rw-r--r--nikola/plugins/compile/rest/doc.py7
-rw-r--r--nikola/plugins/compile/rest/gist.plugin16
-rw-r--r--nikola/plugins/compile/rest/gist.py19
-rw-r--r--nikola/plugins/compile/rest/listing.plugin16
-rw-r--r--nikola/plugins/compile/rest/listing.py17
-rw-r--r--nikola/plugins/compile/rest/media.plugin16
-rw-r--r--nikola/plugins/compile/rest/media.py9
-rw-r--r--nikola/plugins/compile/rest/post_list.plugin17
-rw-r--r--nikola/plugins/compile/rest/post_list.py26
-rw-r--r--nikola/plugins/compile/rest/slides.plugin16
-rw-r--r--nikola/plugins/compile/rest/slides.py12
-rw-r--r--nikola/plugins/compile/rest/soundcloud.plugin16
-rw-r--r--nikola/plugins/compile/rest/soundcloud.py17
-rw-r--r--nikola/plugins/compile/rest/thumbnail.plugin17
-rw-r--r--nikola/plugins/compile/rest/thumbnail.py10
-rw-r--r--nikola/plugins/compile/rest/vimeo.plugin10
-rw-r--r--nikola/plugins/compile/rest/vimeo.py20
-rw-r--r--nikola/plugins/compile/rest/youtube.plugin12
-rw-r--r--nikola/plugins/compile/rest/youtube.py13
23 files changed, 266 insertions, 117 deletions
diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py
index d446fe8..b99e872 100644
--- a/nikola/plugins/compile/rest/__init__.py
+++ b/nikola/plugins/compile/rest/__init__.py
@@ -24,6 +24,8 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""reStructuredText compiler for Nikola."""
+
from __future__ import unicode_literals
import io
import os
@@ -36,10 +38,11 @@ import docutils.readers.standalone
import docutils.writers.html4css1
from nikola.plugin_categories import PageCompiler
-from nikola.utils import unicode_str, get_logger, makedirs, write_metadata
+from nikola.utils import unicode_str, get_logger, makedirs, write_metadata, STDERR_HANDLER
class CompileRest(PageCompiler):
+
"""Compile reStructuredText into HTML."""
name = "rest"
@@ -48,7 +51,7 @@ class CompileRest(PageCompiler):
logger = None
def _read_extra_deps(self, post):
- """Reads contents of .dep file and returns them as a list"""
+ """Read contents of .dep file and returns them as a list."""
dep_path = post.base_path + '.dep'
if os.path.isfile(dep_path):
with io.open(dep_path, 'r+', encoding='utf8') as depf:
@@ -57,11 +60,11 @@ class CompileRest(PageCompiler):
return []
def register_extra_dependencies(self, post):
- """Adds dependency to post object to check .dep file."""
+ """Add dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')
def compile_html_string(self, data, source_path=None, is_two_file=True):
- """Compile reSt into HTML strings."""
+ """Compile reST into HTML strings."""
# If errors occur, this will be added to the line number reported by
# docutils so the line number matches the actual line number (off by
# 7 with default metadata, could be more or less depending on the post).
@@ -88,7 +91,7 @@ class CompileRest(PageCompiler):
return output, error_level, deps
def compile_html(self, source, dest, is_two_file=True):
- """Compile reSt into HTML files."""
+ """Compile source file into HTML and save as dest."""
makedirs(os.path.dirname(dest))
error_level = 100
with io.open(dest, "w+", encoding="utf8") as out_file:
@@ -110,6 +113,7 @@ class CompileRest(PageCompiler):
return False
def create_post(self, path, **kw):
+ """Create a new post."""
content = kw.pop('content', None)
onefile = kw.pop('onefile', False)
# is_page is not used by create_post as of now.
@@ -127,23 +131,17 @@ class CompileRest(PageCompiler):
fd.write(content)
def set_site(self, site):
+ """Set Nikola site."""
+ super(CompileRest, self).set_site(site)
self.config_dependencies = []
- for plugin_info in site.plugin_manager.getPluginsOfCategory("RestExtension"):
- if plugin_info.name in site.config['DISABLED_PLUGINS']:
- site.plugin_manager.removePluginFromCategory(plugin_info, "RestExtension")
- continue
-
- site.plugin_manager.activatePluginByName(plugin_info.name)
+ for plugin_info in self.get_compiler_extensions():
self.config_dependencies.append(plugin_info.name)
- plugin_info.plugin_object.set_site(site)
plugin_info.plugin_object.short_help = plugin_info.description
- self.logger = get_logger('compile_rest', site.loghandlers)
+ self.logger = get_logger('compile_rest', STDERR_HANDLER)
if not site.debug:
self.logger.level = 4
- return super(CompileRest, self).set_site(site)
-
def get_observer(settings):
"""Return an observer for the docutils Reporter."""
@@ -175,11 +173,15 @@ def get_observer(settings):
class NikolaReader(docutils.readers.standalone.Reader):
+ """Nikola-specific docutils reader."""
+
def __init__(self, *args, **kwargs):
+ """Initialize the reader."""
self.transforms = kwargs.pop('transforms', [])
docutils.readers.standalone.Reader.__init__(self, *args, **kwargs)
def get_transforms(self):
+ """Get docutils transforms."""
return docutils.readers.standalone.Reader(self).get_transforms() + self.transforms
def new_document(self):
@@ -191,8 +193,8 @@ class NikolaReader(docutils.readers.standalone.Reader):
def add_node(node, visit_function=None, depart_function=None):
- """
- Register a Docutils node class.
+ """Register a Docutils node class.
+
This function is completely optional. It is a same concept as
`Sphinx add_node function <http://sphinx-doc.org/ext/appapi.html#sphinx.application.Sphinx.add_node>`_.
@@ -236,8 +238,8 @@ def rst2html(source, source_path=None, source_class=docutils.io.StringInput,
writer_name='html', settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
enable_exit_status=None, logger=None, l_add_ln=0, transforms=None):
- """
- Set up & run a `Publisher`, and return a dictionary of document parts.
+ """Set up & run a ``Publisher``, and return a dictionary of document parts.
+
Dictionary keys are the names of parts, and values are Unicode strings;
encoding is up to the client. For programmatic use with string I/O.
diff --git a/nikola/plugins/compile/rest/chart.plugin b/nikola/plugins/compile/rest/chart.plugin
index 3e27a25..438abe4 100644
--- a/nikola/plugins/compile/rest/chart.plugin
+++ b/nikola/plugins/compile/rest/chart.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_chart
-Module = chart
+name = rest_chart
+module = chart
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Chart directive based in PyGal
+author = Roberto Alsina
+version = 0.1
+website = http://getnikola.com
+description = Chart directive based in PyGal
diff --git a/nikola/plugins/compile/rest/chart.py b/nikola/plugins/compile/rest/chart.py
index 59b9dc7..88fdff3 100644
--- a/nikola/plugins/compile/rest/chart.py
+++ b/nikola/plugins/compile/rest/chart.py
@@ -24,6 +24,8 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""Chart directive for reSTructuredText."""
+
from ast import literal_eval
from docutils import nodes
@@ -42,9 +44,12 @@ _site = None
class Plugin(RestExtension):
+ """Plugin for chart role."""
+
name = "rest_chart"
def set_site(self, site):
+ """Set Nikola site."""
global _site
_site = self.site = site
directives.register_directive('chart', Chart)
@@ -52,17 +57,18 @@ class Plugin(RestExtension):
class Chart(Directive):
- """ Restructured text extension for inserting charts as SVG
- Usage:
- .. chart:: Bar
- :title: 'Browser usage evolution (in %)'
- :x_labels: ["2002", "2003", "2004", "2005", "2006", "2007"]
+ """reStructuredText extension for inserting charts as SVG.
+
+ Usage:
+ .. chart:: Bar
+ :title: 'Browser usage evolution (in %)'
+ :x_labels: ["2002", "2003", "2004", "2005", "2006", "2007"]
- 'Firefox', [None, None, 0, 16.6, 25, 31]
- 'Chrome', [None, None, None, None, None, None]
- 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
- 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
+ 'Firefox', [None, None, 0, 16.6, 25, 31]
+ 'Chrome', [None, None, None, None, None, None]
+ 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
+ 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
"""
has_content = True
@@ -129,6 +135,7 @@ class Chart(Directive):
}
def run(self):
+ """Run the directive."""
if pygal is None:
msg = req_missing(['pygal'], 'use the Chart directive', optional=True)
return [nodes.raw('', '<div class="text-error">{0}</div>'.format(msg), format='html')]
diff --git a/nikola/plugins/compile/rest/doc.plugin b/nikola/plugins/compile/rest/doc.plugin
index 1984f52..facdd03 100644
--- a/nikola/plugins/compile/rest/doc.plugin
+++ b/nikola/plugins/compile/rest/doc.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_doc
-Module = doc
+name = rest_doc
+module = doc
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Manuel Kaufmann
-Version = 0.1
-Website = http://getnikola.com
-Description = Role to link another page / post from the blog
+author = Manuel Kaufmann
+version = 0.1
+website = http://getnikola.com
+description = Role to link another page / post from the blog
diff --git a/nikola/plugins/compile/rest/doc.py b/nikola/plugins/compile/rest/doc.py
index 703c234..99cce81 100644
--- a/nikola/plugins/compile/rest/doc.py
+++ b/nikola/plugins/compile/rest/doc.py
@@ -24,6 +24,7 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""reST role for linking to other documents."""
from docutils import nodes
from docutils.parsers.rst import roles
@@ -34,9 +35,12 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for doc role."""
+
name = 'rest_doc'
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
roles.register_canonical_role('doc', doc_role)
doc_role.site = site
@@ -45,7 +49,7 @@ class Plugin(RestExtension):
def doc_role(name, rawtext, text, lineno, inliner,
options={}, content=[]):
-
+ """Handle the doc role."""
# split link's text and post's slug in role content
has_explicit_title, title, slug = split_explicit_title(text)
# check if the slug given is part of our blog posts/pages
@@ -82,5 +86,6 @@ def doc_role(name, rawtext, text, lineno, inliner,
def make_link_node(rawtext, text, url, options):
+ """Make a reST link node."""
node = nodes.reference(rawtext, text, refuri=url, *options)
return node
diff --git a/nikola/plugins/compile/rest/gist.plugin b/nikola/plugins/compile/rest/gist.plugin
index 8f498ec..9fa2e82 100644
--- a/nikola/plugins/compile/rest/gist.plugin
+++ b/nikola/plugins/compile/rest/gist.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_gist
-Module = gist
+name = rest_gist
+module = gist
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Gist directive
+author = Roberto Alsina
+version = 0.1
+website = http://getnikola.com
+description = Gist directive
diff --git a/nikola/plugins/compile/rest/gist.py b/nikola/plugins/compile/rest/gist.py
index ab4d56d..736ee37 100644
--- a/nikola/plugins/compile/rest/gist.py
+++ b/nikola/plugins/compile/rest/gist.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# This file is public domain according to its author, Brian Hsu
+"""Gist directive for reStructuredText."""
+
import requests
from docutils.parsers.rst import Directive, directives
from docutils import nodes
@@ -10,26 +12,28 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for gist directive."""
+
name = "rest_gist"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('gist', GitHubGist)
return super(Plugin, self).set_site(site)
class GitHubGist(Directive):
- """ Embed GitHub Gist.
-
- Usage:
- .. gist:: GIST_ID
+ """Embed GitHub Gist.
- or
+ Usage:
- .. gist:: GIST_URL
+ .. gist:: GIST_ID
+ or
+ .. gist:: GIST_URL
"""
required_arguments = 1
@@ -39,10 +43,12 @@ class GitHubGist(Directive):
has_content = False
def get_raw_gist_with_filename(self, gistID, filename):
+ """Get raw gist text for a filename."""
url = '/'.join(("https://gist.github.com/raw", gistID, filename))
return requests.get(url).text
def get_raw_gist(self, gistID):
+ """Get raw gist text."""
url = "https://gist.github.com/raw/{0}".format(gistID)
try:
return requests.get(url).text
@@ -50,6 +56,7 @@ class GitHubGist(Directive):
raise self.error('Cannot get gist for url={0}'.format(url))
def run(self):
+ """Run the gist directive."""
if 'https://' in self.arguments[0]:
gistID = self.arguments[0].split('/')[-1].strip()
else:
diff --git a/nikola/plugins/compile/rest/listing.plugin b/nikola/plugins/compile/rest/listing.plugin
index 4c9883e..85c780f 100644
--- a/nikola/plugins/compile/rest/listing.plugin
+++ b/nikola/plugins/compile/rest/listing.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_listing
-Module = listing
+name = rest_listing
+module = listing
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Extension for source listings
+author = Roberto Alsina
+version = 0.1
+website = http://getnikola.com
+description = Extension for source listings
diff --git a/nikola/plugins/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py
index b8340cf..4871bf3 100644
--- a/nikola/plugins/compile/rest/listing.py
+++ b/nikola/plugins/compile/rest/listing.py
@@ -25,7 +25,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-""" Define and register a listing directive using the existing CodeBlock """
+"""Define and register a listing directive using the existing CodeBlock."""
from __future__ import unicode_literals
@@ -55,7 +55,9 @@ from nikola.plugin_categories import RestExtension
# A sanitized version of docutils.parsers.rst.directives.body.CodeBlock.
class CodeBlock(Directive):
+
"""Parse and mark up content of a code block."""
+
optional_arguments = 1
option_spec = {'class': directives.class_option,
'name': directives.unchanged,
@@ -65,6 +67,7 @@ class CodeBlock(Directive):
has_content = True
def run(self):
+ """Run code block directive."""
self.assert_has_content()
if 'linenos' in self.options:
@@ -124,9 +127,12 @@ docutils.parsers.rst.directives.misc.CodeBlock = CodeBlock
class Plugin(RestExtension):
+ """Plugin for listing directive."""
+
name = "rest_listing"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
# Even though listings don't use CodeBlock anymore, I am
# leaving these to make the code directive work with
@@ -146,7 +152,8 @@ listing_spec['linenos'] = directives.unchanged
class Listing(Include):
- """ listing directive: create a highlighted block of code from a file in listings/
+
+ """Create a highlighted block of code from a file in listings/.
Usage:
@@ -154,12 +161,14 @@ class Listing(Include):
:number-lines:
"""
+
has_content = False
required_arguments = 1
optional_arguments = 1
option_spec = listing_spec
def run(self):
+ """Run listing directive."""
_fname = self.arguments.pop(0)
fname = _fname.replace('/', os.sep)
lang = self.arguments.pop(0)
@@ -185,9 +194,9 @@ class Listing(Include):
return generated_nodes
def get_code_from_file(self, data):
- """ Create CodeBlock nodes from file object content """
+ """Create CodeBlock nodes from file object content."""
return super(Listing, self).run()
def assert_has_content(self):
- """ Listing has no content, override check from superclass """
+ """Listing has no content, override check from superclass."""
pass
diff --git a/nikola/plugins/compile/rest/media.plugin b/nikola/plugins/compile/rest/media.plugin
index 5f5276b..9803c8f 100644
--- a/nikola/plugins/compile/rest/media.plugin
+++ b/nikola/plugins/compile/rest/media.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_media
-Module = media
+name = rest_media
+module = media
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Directive to support oembed via micawber
+author = Roberto Alsina
+version = 0.1
+website = http://getnikola.com
+description = Directive to support oembed via micawber
diff --git a/nikola/plugins/compile/rest/media.py b/nikola/plugins/compile/rest/media.py
index 0363d28..345e331 100644
--- a/nikola/plugins/compile/rest/media.py
+++ b/nikola/plugins/compile/rest/media.py
@@ -24,6 +24,7 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""Media directive for reStructuredText."""
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -40,21 +41,27 @@ from nikola.utils import req_missing
class Plugin(RestExtension):
+ """Plugin for reST media directive."""
+
name = "rest_media"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('media', Media)
return super(Plugin, self).set_site(site)
class Media(Directive):
- """ Restructured text extension for inserting any sort of media using micawber."""
+
+ """reST extension for inserting any sort of media using micawber."""
+
has_content = False
required_arguments = 1
optional_arguments = 999
def run(self):
+ """Run media directive."""
if micawber is None:
msg = req_missing(['micawber'], 'use the media directive', optional=True)
return [nodes.raw('', '<div class="text-error">{0}</div>'.format(msg), format='html')]
diff --git a/nikola/plugins/compile/rest/post_list.plugin b/nikola/plugins/compile/rest/post_list.plugin
index 82450a0..48969bf 100644
--- a/nikola/plugins/compile/rest/post_list.plugin
+++ b/nikola/plugins/compile/rest/post_list.plugin
@@ -1,9 +1,14 @@
[Core]
-Name = rest_post_list
-Module = post_list
+name = rest_post_list
+module = post_list
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Udo Spallek
-Version = 0.1
-Website = http://getnikola.com
-Description = Includes a list of posts with tag and slide based filters.
+author = Udo Spallek
+version = 0.1
+website = http://getnikola.com
+description = Includes a list of posts with tag and slide based filters.
+
diff --git a/nikola/plugins/compile/rest/post_list.py b/nikola/plugins/compile/rest/post_list.py
index ddbd82d..a22ee85 100644
--- a/nikola/plugins/compile/rest/post_list.py
+++ b/nikola/plugins/compile/rest/post_list.py
@@ -23,6 +23,9 @@
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+"""Post list directive for reStructuredText."""
+
from __future__ import unicode_literals
import os
@@ -40,9 +43,13 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+
+ """Plugin for reST post-list directive."""
+
name = "rest_post_list"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('post-list', PostList)
PostList.site = site
@@ -50,14 +57,15 @@ class Plugin(RestExtension):
class PostList(Directive):
- """
+
+ """Provide a reStructuredText directive to create a list of posts.
+
Post List
=========
:Directive Arguments: None.
- :Directive Options: lang, start, stop, reverse, sort, tags, template, id
+ :Directive Options: lang, start, stop, reverse, sort, tags, categories, slugs, all, template, id
:Directive Content: None.
- Provides a reStructuredText directive to create a list of posts.
The posts appearing in the list can be filtered by options.
*List slicing* is provided with the *start*, *stop* and *reverse* options.
@@ -87,6 +95,10 @@ class PostList(Directive):
Filter posts to show only posts having at least one of the ``tags``.
Defaults to None.
+ ``categories`` : string [, string...]
+ Filter posts to show only posts having one of the ``categories``.
+ Defaults to None.
+
``slugs`` : string [, string...]
Filter posts to show only posts having at least one of the ``slugs``.
Defaults to None.
@@ -107,12 +119,14 @@ class PostList(Directive):
A manual id for the post list.
Defaults to a random name composed by 'post_list_' + uuid.uuid4().hex.
"""
+
option_spec = {
'start': int,
'stop': int,
'reverse': directives.flag,
'sort': directives.unchanged,
'tags': directives.unchanged,
+ 'categories': directives.unchanged,
'slugs': directives.unchanged,
'all': directives.flag,
'lang': directives.unchanged,
@@ -121,11 +135,14 @@ class PostList(Directive):
}
def run(self):
+ """Run post-list directive."""
start = self.options.get('start')
stop = self.options.get('stop')
reverse = self.options.get('reverse', False)
tags = self.options.get('tags')
tags = [t.strip().lower() for t in tags.split(',')] if tags else []
+ categories = self.options.get('categories')
+ categories = [c.strip().lower() for c in categories.split(',')] if categories else []
slugs = self.options.get('slugs')
slugs = [s.strip() for s in slugs.split(',')] if slugs else []
show_all = self.options.get('all', False)
@@ -145,6 +162,9 @@ class PostList(Directive):
else:
timeline = [p for p in self.site.timeline if p.use_in_feeds]
+ if categories:
+ timeline = [p for p in timeline if p.meta('category', lang=lang).lower() in categories]
+
for post in timeline:
if tags:
cont = True
diff --git a/nikola/plugins/compile/rest/slides.plugin b/nikola/plugins/compile/rest/slides.plugin
index cee4b06..5c05b89 100644
--- a/nikola/plugins/compile/rest/slides.plugin
+++ b/nikola/plugins/compile/rest/slides.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_slides
-Module = slides
+name = rest_slides
+module = slides
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Slides directive
+author = Roberto Alsina
+version = 0.1
+website = http://getnikola.com
+description = Slides directive
diff --git a/nikola/plugins/compile/rest/slides.py b/nikola/plugins/compile/rest/slides.py
index 7826f6a..2522e55 100644
--- a/nikola/plugins/compile/rest/slides.py
+++ b/nikola/plugins/compile/rest/slides.py
@@ -24,6 +24,8 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""Slides directive for reStructuredText."""
+
from __future__ import unicode_literals
import uuid
@@ -36,9 +38,12 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for reST slides directive."""
+
name = "rest_slides"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('slides', Slides)
Slides.site = site
@@ -46,11 +51,14 @@ class Plugin(RestExtension):
class Slides(Directive):
- """ Restructured text extension for inserting slideshows."""
+
+ """reST extension for inserting slideshows."""
+
has_content = True
def run(self):
- if len(self.content) == 0:
+ """Run the slides directive."""
+ if len(self.content) == 0: # pragma: no cover
return
if self.site.invariant: # for testing purposes
diff --git a/nikola/plugins/compile/rest/soundcloud.plugin b/nikola/plugins/compile/rest/soundcloud.plugin
index 1d31a8f..75469e4 100644
--- a/nikola/plugins/compile/rest/soundcloud.plugin
+++ b/nikola/plugins/compile/rest/soundcloud.plugin
@@ -1,10 +1,14 @@
[Core]
-Name = rest_soundcloud
-Module = soundcloud
+name = rest_soundcloud
+module = soundcloud
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Soundcloud directive
+author = Roberto Alsina
+version = 0.1
+website = http://getnikola.com
+description = Soundcloud directive
diff --git a/nikola/plugins/compile/rest/soundcloud.py b/nikola/plugins/compile/rest/soundcloud.py
index a26806c..30134a9 100644
--- a/nikola/plugins/compile/rest/soundcloud.py
+++ b/nikola/plugins/compile/rest/soundcloud.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
+"""SoundCloud directive for reStructuredText."""
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -10,9 +11,12 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for soundclound directive."""
+
name = "rest_soundcloud"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('soundcloud', SoundCloud)
directives.register_directive('soundcloud_playlist', SoundCloudPlaylist)
@@ -27,7 +31,8 @@ src="https://w.soundcloud.com/player/?url=http://api.soundcloud.com/{preslug}/""
class SoundCloud(Directive):
- """ Restructured text extension for inserting SoundCloud embedded music
+
+ """reST extension for inserting SoundCloud embedded music.
Usage:
.. soundcloud:: <sound id>
@@ -35,6 +40,7 @@ class SoundCloud(Directive):
:width: 600
"""
+
has_content = True
required_arguments = 1
option_spec = {
@@ -44,7 +50,7 @@ class SoundCloud(Directive):
preslug = "tracks"
def run(self):
- """ Required by the Directive interface. Create docutils nodes """
+ """Run the soundcloud directive."""
self.check_content()
options = {
'sid': self.arguments[0],
@@ -56,12 +62,15 @@ class SoundCloud(Directive):
return [nodes.raw('', CODE.format(**options), format='html')]
def check_content(self):
- """ Emit a deprecation warning if there is content """
- if self.content:
+ """Emit a deprecation warning if there is content."""
+ if self.content: # pragma: no cover
raise self.warning("This directive does not accept content. The "
"'key=value' format for options is deprecated, "
"use ':key: value' instead")
class SoundCloudPlaylist(SoundCloud):
+
+ """reST directive for SoundCloud playlists."""
+
preslug = "playlists"
diff --git a/nikola/plugins/compile/rest/thumbnail.plugin b/nikola/plugins/compile/rest/thumbnail.plugin
index 3b73340..0084310 100644
--- a/nikola/plugins/compile/rest/thumbnail.plugin
+++ b/nikola/plugins/compile/rest/thumbnail.plugin
@@ -1,9 +1,14 @@
[Core]
-Name = rest_thumbnail
-Module = thumbnail
+name = rest_thumbnail
+module = thumbnail
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Author = Pelle Nilsson
-Version = 0.1
-Website = http://getnikola.com
-Description = reST directive to facilitate enlargeable images with thumbnails
+author = Pelle Nilsson
+version = 0.1
+website = http://getnikola.com
+description = reST directive to facilitate enlargeable images with thumbnails
+
diff --git a/nikola/plugins/compile/rest/thumbnail.py b/nikola/plugins/compile/rest/thumbnail.py
index 5388d8d..1fae06c 100644
--- a/nikola/plugins/compile/rest/thumbnail.py
+++ b/nikola/plugins/compile/rest/thumbnail.py
@@ -24,6 +24,8 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""Thumbnail directive for reStructuredText."""
+
import os
from docutils.parsers.rst import directives
@@ -34,9 +36,12 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for thumbnail directive."""
+
name = "rest_thumbnail"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('thumbnail', Thumbnail)
return super(Plugin, self).set_site(site)
@@ -44,10 +49,14 @@ class Plugin(RestExtension):
class Thumbnail(Figure):
+ """Thumbnail directive for reST."""
+
def align(argument):
+ """Return thumbnail alignment."""
return directives.choice(argument, Image.align_values)
def figwidth_value(argument):
+ """Return figure width."""
if argument.lower() == 'image':
return 'image'
else:
@@ -59,6 +68,7 @@ class Thumbnail(Figure):
has_content = True
def run(self):
+ """Run the thumbnail directive."""
uri = directives.uri(self.arguments[0])
self.options['target'] = uri
self.arguments[0] = '.thumbnail'.join(os.path.splitext(uri))
diff --git a/nikola/plugins/compile/rest/vimeo.plugin b/nikola/plugins/compile/rest/vimeo.plugin
index e0ff3f1..688f981 100644
--- a/nikola/plugins/compile/rest/vimeo.plugin
+++ b/nikola/plugins/compile/rest/vimeo.plugin
@@ -1,7 +1,11 @@
[Core]
-Name = rest_vimeo
-Module = vimeo
+name = rest_vimeo
+module = vimeo
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Description = Vimeo directive
+description = Vimeo directive
diff --git a/nikola/plugins/compile/rest/vimeo.py b/nikola/plugins/compile/rest/vimeo.py
index bc44b0e..c694a87 100644
--- a/nikola/plugins/compile/rest/vimeo.py
+++ b/nikola/plugins/compile/rest/vimeo.py
@@ -24,6 +24,7 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""Vimeo directive for reStructuredText."""
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -37,9 +38,12 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for vimeo reST directive."""
+
name = "rest_vimeo"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('vimeo', Vimeo)
return super(Plugin, self).set_site(site)
@@ -56,14 +60,16 @@ VIDEO_DEFAULT_WIDTH = 281
class Vimeo(Directive):
- """ Restructured text extension for inserting vimeo embedded videos
- Usage:
- .. vimeo:: 20241459
- :height: 400
- :width: 600
+ """reST extension for inserting vimeo embedded videos.
+
+ Usage:
+ .. vimeo:: 20241459
+ :height: 400
+ :width: 600
"""
+
has_content = True
required_arguments = 1
option_spec = {
@@ -75,6 +81,7 @@ class Vimeo(Directive):
request_size = True
def run(self):
+ """Run the vimeo directive."""
self.check_content()
options = {
'vimeo_id': self.arguments[0],
@@ -90,9 +97,11 @@ class Vimeo(Directive):
return [nodes.raw('', CODE.format(**options), format='html')]
def check_modules(self):
+ """Check modules."""
return None
def set_video_size(self):
+ """Set video size."""
# Only need to make a connection if width and height aren't provided
if 'height' not in self.options or 'width' not in self.options:
self.options['height'] = VIDEO_DEFAULT_HEIGHT
@@ -111,6 +120,7 @@ class Vimeo(Directive):
pass
def check_content(self):
+ """Check if content exists."""
if self.content:
raise self.warning("This directive does not accept content. The "
"'key=value' format for options is deprecated, "
diff --git a/nikola/plugins/compile/rest/youtube.plugin b/nikola/plugins/compile/rest/youtube.plugin
index 01275be..5fbd67b 100644
--- a/nikola/plugins/compile/rest/youtube.plugin
+++ b/nikola/plugins/compile/rest/youtube.plugin
@@ -1,8 +1,12 @@
[Core]
-Name = rest_youtube
-Module = youtube
+name = rest_youtube
+module = youtube
+
+[Nikola]
+compiler = rest
+plugincategory = CompilerExtension
[Documentation]
-Version = 0.1
-Description = Youtube directive
+version = 0.1
+description = Youtube directive
diff --git a/nikola/plugins/compile/rest/youtube.py b/nikola/plugins/compile/rest/youtube.py
index 7c6bba1..6c5c211 100644
--- a/nikola/plugins/compile/rest/youtube.py
+++ b/nikola/plugins/compile/rest/youtube.py
@@ -24,6 +24,8 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""YouTube directive for reStructuredText."""
+
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -33,9 +35,12 @@ from nikola.plugin_categories import RestExtension
class Plugin(RestExtension):
+ """Plugin for the youtube directive."""
+
name = "rest_youtube"
def set_site(self, site):
+ """Set Nikola site."""
self.site = site
directives.register_directive('youtube', Youtube)
return super(Plugin, self).set_site(site)
@@ -49,7 +54,8 @@ src="//www.youtube.com/embed/{yid}?rel=0&amp;hd=1&amp;wmode=transparent"
class Youtube(Directive):
- """ Restructured text extension for inserting youtube embedded videos
+
+ """reST extension for inserting youtube embedded videos.
Usage:
.. youtube:: lyViVmaBQDg
@@ -57,6 +63,7 @@ class Youtube(Directive):
:width: 600
"""
+
has_content = True
required_arguments = 1
option_spec = {
@@ -65,6 +72,7 @@ class Youtube(Directive):
}
def run(self):
+ """Run the youtube directive."""
self.check_content()
options = {
'yid': self.arguments[0],
@@ -75,7 +83,8 @@ class Youtube(Directive):
return [nodes.raw('', CODE.format(**options), format='html')]
def check_content(self):
- if self.content:
+ """Check if content exists."""
+ if self.content: # pragma: no cover
raise self.warning("This directive does not accept content. The "
"'key=value' format for options is deprecated, "
"use ':key: value' instead")