Skip to content
Permalink
Browse files

Fix docstrings

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 23, 2015
1 parent eaf1d30 commit 0543e7a8adefb050dfe9b9f1cd72b55a16434147
Showing with 9 additions and 9 deletions.
  1. +1 −2 nikola/nikola.py
  2. +8 −7 nikola/shortcodes.py
@@ -1301,8 +1301,7 @@ def register_shortcode(self, name, f):
self.shortcode_registry[name] = f

def apply_shortcodes(self, data):
"""Apply shortcodes from the registry into data."""

"""Apply shortcodes from the registry on data."""
return shortcodes.apply_shortcodes(data, self.shortcode_registry)

def generic_rss_renderer(self, lang, title, link, description, timeline, output_path,
@@ -24,7 +24,7 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

"""Support for hugo-style shortcodes."""
"""Support for Hugo-style shortcodes."""

try:
from html.parser import HTMLParser
@@ -33,7 +33,7 @@


def apply_shortcodes(data, registry, site=None):
"""Support for hugo-style shortcodes.
"""Apply Hugo-style shortcodes on data.
{{% name parameters %}} will end up calling the registered "name" function with the given parameters.
{{% name parameters %}} something {{% /name %}} will call name with the parameters and
@@ -45,9 +45,7 @@ def apply_shortcodes(data, registry, site=None):
'==> baz <=='
>>> apply_shortcodes('==> {{% foo bar=baz %}}some data{{% /foo %}} <==', {'foo': lambda *a, **k: k['bar']+k['data']})
'==> bazsome data <=='
"""

shortcodes = list(_find_shortcodes(data))
# Calculate shortcode results
for sc in shortcodes:
@@ -65,7 +63,7 @@ def apply_shortcodes(data, registry, site=None):


def _find_shortcodes(data):
""" Find starta and end of shortcode markers.
"""Find start and end of shortcode markers.
>>> list(_find_shortcodes('{{% foo %}}{{% bar %}}'))
[['foo', ([], {}), 0, 11], ['bar', ([], {}), 11, 22]]
@@ -75,8 +73,8 @@ def _find_shortcodes(data):
>>> list(_find_shortcodes('{{% foo bar bat=baz%}}some data{{% /foo %}}'))
[['foo', (['bar'], {'bat': 'baz', 'data': 'some data'}), 0, 43]]
"""
"""
# FIXME: this is really space-intolerant

parser = SCParser()
@@ -101,9 +99,11 @@ def _find_shortcodes(data):


class SCParser(HTMLParser):
"""Because shortcode attributes are HTML-like abusing the HTML parser parser."""
"""Parser for shortcode arguments."""
# Because shortcode attributes are HTML-like, we are abusing the HTML parser.

def parse_sc(self, data):
"""Parse shortcode arguments into a tuple."""
self.name = None
self.attrs = {}
self.feed(data)
@@ -117,5 +117,6 @@ def parse_sc(self, data):
return self.name, (args, kwargs)

def handle_starttag(self, tag, attrs):
"""Set start tag information on parser object."""
self.name = tag
self.attrs = attrs

0 comments on commit 0543e7a

Please sign in to comment.
You can’t perform that action at this time.