nikola.plugins.compile.rest package

Submodules

nikola.plugins.compile.rest.chart module

Chart directive for reSTructuredText.

class nikola.plugins.compile.rest.chart.Chart(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

reStructuredText extension for inserting charts as SVG.

Usage:
has_content = True
option_spec = {'box_mode': <function unchanged at 0x7f5a423aea60>, 'classes': <function unchanged at 0x7f5a423aea60>, 'css': <function unchanged at 0x7f5a423aea60>, 'data_file': <function unchanged at 0x7f5a423aea60>, 'defs': <function unchanged at 0x7f5a423aea60>, 'disable_xml_declaration': <function unchanged at 0x7f5a423aea60>, 'dots_size': <function unchanged at 0x7f5a423aea60>, 'dynamic_print_values': <function unchanged at 0x7f5a423aea60>, 'explicit_size': <function unchanged at 0x7f5a423aea60>, 'fill': <function unchanged at 0x7f5a423aea60>, 'force_uri_protocol': <function unchanged at 0x7f5a423aea60>, 'half_pie': <function unchanged at 0x7f5a423aea60>, 'height': <function unchanged at 0x7f5a423aea60>, 'human_readable': <function unchanged at 0x7f5a423aea60>, 'include_x_axis': <function unchanged at 0x7f5a423aea60>, 'inner_radius': <function unchanged at 0x7f5a423aea60>, 'interpolate': <function unchanged at 0x7f5a423aea60>, 'interpolation_parameters': <function unchanged at 0x7f5a423aea60>, 'interpolation_precision': <function unchanged at 0x7f5a423aea60>, 'inverse_y_axis': <function unchanged at 0x7f5a423aea60>, 'js': <function unchanged at 0x7f5a423aea60>, 'legend_at_bottom': <function unchanged at 0x7f5a423aea60>, 'legend_at_bottom_columns': <function unchanged at 0x7f5a423aea60>, 'legend_box_size': <function unchanged at 0x7f5a423aea60>, 'logarithmic': <function unchanged at 0x7f5a423aea60>, 'margin': <function unchanged at 0x7f5a423aea60>, 'margin_bottom': <function unchanged at 0x7f5a423aea60>, 'margin_left': <function unchanged at 0x7f5a423aea60>, 'margin_right': <function unchanged at 0x7f5a423aea60>, 'margin_top': <function unchanged at 0x7f5a423aea60>, 'max_scale': <function unchanged at 0x7f5a423aea60>, 'min_scale': <function unchanged at 0x7f5a423aea60>, 'missing_value_fill_truncation': <function unchanged at 0x7f5a423aea60>, 'no_data_text': <function unchanged at 0x7f5a423aea60>, 'no_prefix': <function unchanged at 0x7f5a423aea60>, 'order_min': <function unchanged at 0x7f5a423aea60>, 'pretty_print': <function unchanged at 0x7f5a423aea60>, 'print_labels': <function unchanged at 0x7f5a423aea60>, 'print_values': <function unchanged at 0x7f5a423aea60>, 'print_values_position': <function unchanged at 0x7f5a423aea60>, 'print_zeroes': <function unchanged at 0x7f5a423aea60>, 'range': <function unchanged at 0x7f5a423aea60>, 'rounded_bars': <function unchanged at 0x7f5a423aea60>, 'secondary_range': <function unchanged at 0x7f5a423aea60>, 'show_dots': <function unchanged at 0x7f5a423aea60>, 'show_legend': <function unchanged at 0x7f5a423aea60>, 'show_minor_x_labels': <function unchanged at 0x7f5a423aea60>, 'show_minor_y_labels': <function unchanged at 0x7f5a423aea60>, 'show_only_major_dots': <function unchanged at 0x7f5a423aea60>, 'show_x_guides': <function unchanged at 0x7f5a423aea60>, 'show_x_labels': <function unchanged at 0x7f5a423aea60>, 'show_y_guides': <function unchanged at 0x7f5a423aea60>, 'show_y_labels': <function unchanged at 0x7f5a423aea60>, 'spacing': <function unchanged at 0x7f5a423aea60>, 'stack_from_top': <function unchanged at 0x7f5a423aea60>, 'strict': <function unchanged at 0x7f5a423aea60>, 'stroke': <function unchanged at 0x7f5a423aea60>, 'stroke_style': <function unchanged at 0x7f5a423aea60>, 'style': <function unchanged at 0x7f5a423aea60>, 'title': <function unchanged at 0x7f5a423aea60>, 'tooltip_border_radius': <function unchanged at 0x7f5a423aea60>, 'truncate_label': <function unchanged at 0x7f5a423aea60>, 'truncate_legend': <function unchanged at 0x7f5a423aea60>, 'value_formatter': <function unchanged at 0x7f5a423aea60>, 'width': <function unchanged at 0x7f5a423aea60>, 'x_label_rotation': <function unchanged at 0x7f5a423aea60>, 'x_labels': <function unchanged at 0x7f5a423aea60>, 'x_labels_major': <function unchanged at 0x7f5a423aea60>, 'x_labels_major_count': <function unchanged at 0x7f5a423aea60>, 'x_labels_major_every': <function unchanged at 0x7f5a423aea60>, 'x_title': <function unchanged at 0x7f5a423aea60>, 'x_value_formatter': <function unchanged at 0x7f5a423aea60>, 'xrange': <function unchanged at 0x7f5a423aea60>, 'y_label_rotation': <function unchanged at 0x7f5a423aea60>, 'y_labels': <function unchanged at 0x7f5a423aea60>, 'y_labels_major': <function unchanged at 0x7f5a423aea60>, 'y_labels_major_count': <function unchanged at 0x7f5a423aea60>, 'y_labels_major_every': <function unchanged at 0x7f5a423aea60>, 'y_title': <function unchanged at 0x7f5a423aea60>, 'zero': <function unchanged at 0x7f5a423aea60>}
required_arguments = 1
run()

Run the directive.

class nikola.plugins.compile.rest.chart.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for chart role.

name = 'rest_chart'
set_site(site)

Set Nikola site.

nikola.plugins.compile.rest.doc module

reST role for linking to other documents.

class nikola.plugins.compile.rest.doc.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for doc role.

name = 'rest_doc'
set_site(site)

Set Nikola site.

nikola.plugins.compile.rest.doc.doc_role(name, rawtext, text, lineno, inliner, options={}, content=[])

Handle the doc role.

nikola.plugins.compile.rest.doc.doc_shortcode(*args, **kwargs)

Implement the doc shortcode.

Make a reST link node.

nikola.plugins.compile.rest.gist module

Gist directive for reStructuredText.

class nikola.plugins.compile.rest.gist.GitHubGist(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

Embed GitHub Gist.

Usage:

or

final_argument_whitespace = True
get_raw_gist(gistID)

Get raw gist text.

get_raw_gist_with_filename(gistID, filename)

Get raw gist text for a filename.

has_content = False
option_spec = {'file': <function unchanged at 0x7f5a423aea60>}
optional_arguments = 1
required_arguments = 1
run()

Run the gist directive.

class nikola.plugins.compile.rest.gist.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for gist directive.

name = 'rest_gist'
set_site(site)

Set Nikola site.

nikola.plugins.compile.rest.listing module

Define and register a listing directive using the existing CodeBlock.

class nikola.plugins.compile.rest.listing.CodeBlock(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

Parse and mark up content of a code block.

has_content = True
option_spec = {'class': <function class_option at 0x7f5a423aeea0>, 'linenos': <function unchanged at 0x7f5a423aea60>, 'name': <function unchanged at 0x7f5a423aea60>, 'number-lines': <function unchanged at 0x7f5a423aea60>, 'tab-width': <function nonnegative_int at 0x7f5a423aebf8>}
optional_arguments = 1
run()

Run code block directive.

class nikola.plugins.compile.rest.listing.Listing(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.directives.misc.Include`

Create a highlighted block of code from a file in listings/.

Usage:

assert_has_content()

Override check from superclass with nothing.

Listing has no content, override check from superclass.

get_code_from_file(data)

Create CodeBlock nodes from file object content.

has_content = False
option_spec = {'class': <function class_option at 0x7f5a423aeea0>, 'code': <function unchanged at 0x7f5a423aea60>, 'encoding': <function encoding at 0x7f5a42349268>, 'end-before': <function unchanged_required at 0x7f5a423ae9d8>, 'end-line': <class 'int'>, 'linenos': <function unchanged at 0x7f5a423aea60>, 'literal': <function flag at 0x7f5a423ae950>, 'name': <function unchanged at 0x7f5a423aea60>, 'number-lines': <function unchanged at 0x7f5a423aea60>, 'start-after': <function unchanged_required at 0x7f5a423ae9d8>, 'start-line': <class 'int'>, 'tab-width': <class 'int'>}
optional_arguments = 1
required_arguments = 1
run()

Run listing directive.

class nikola.plugins.compile.rest.listing.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for listing directive.

name = 'rest_listing'
set_site(site)

Set Nikola site.

nikola.plugins.compile.rest.media module

Media directive for reStructuredText.

class nikola.plugins.compile.rest.media.Media(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

reST extension for inserting any sort of media using micawber.

has_content = False
optional_arguments = 999
required_arguments = 1
run()

Run media directive.

class nikola.plugins.compile.rest.media.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for reST media directive.

name = 'rest_media'
set_site(site)

Set Nikola site.

nikola.plugins.compile.rest.post_list module

Post list directive for reStructuredText.

class nikola.plugins.compile.rest.post_list.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for reST post-list directive.

name = 'rest_post_list'
set_site(site)

Set Nikola site.

class nikola.plugins.compile.rest.post_list.PostListDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

Provide a reStructuredText directive to create a list of posts.

option_spec = {'categories': <function unchanged at 0x7f5a423aea60>, 'date': <function unchanged at 0x7f5a423aea60>, 'id': <function unchanged at 0x7f5a423aea60>, 'lang': <function unchanged at 0x7f5a423aea60>, 'post_type': <function unchanged at 0x7f5a423aea60>, 'require_all_tags': <function flag at 0x7f5a423ae950>, 'reverse': <function flag at 0x7f5a423ae950>, 'sections': <function unchanged at 0x7f5a423aea60>, 'slugs': <function unchanged at 0x7f5a423aea60>, 'sort': <function unchanged at 0x7f5a423aea60>, 'start': <class 'int'>, 'stop': <class 'int'>, 'tags': <function unchanged at 0x7f5a423aea60>, 'template': <function path at 0x7f5a423aeae8>, 'type': <function unchanged at 0x7f5a423aea60>}
run()

Run post-list directive.

nikola.plugins.compile.rest.slides module

nikola.plugins.compile.rest.soundcloud module

SoundCloud directive for reStructuredText.

class nikola.plugins.compile.rest.soundcloud.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for soundclound directive.

name = 'rest_soundcloud'
set_site(site)

Set Nikola site.

class nikola.plugins.compile.rest.soundcloud.SoundCloud(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

reST extension for inserting SoundCloud embedded music.

Usage:
check_content()

Emit a deprecation warning if there is content.

has_content = True
option_spec = {'align': <function _align_choice at 0x7f5a3e825c80>, 'height': <function positive_int at 0x7f5a42349158>, 'width': <function positive_int at 0x7f5a42349158>}
preslug = 'tracks'
required_arguments = 1
run()

Run the soundcloud directive.

class nikola.plugins.compile.rest.soundcloud.SoundCloudPlaylist(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`nikola.plugins.compile.rest.soundcloud.SoundCloud`

reST directive for SoundCloud playlists.

preslug = 'playlists'

nikola.plugins.compile.rest.thumbnail module

Thumbnail directive for reStructuredText.

class nikola.plugins.compile.rest.thumbnail.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for thumbnail directive.

name = 'rest_thumbnail'
set_site(site)

Set Nikola site.

class nikola.plugins.compile.rest.thumbnail.Thumbnail(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.directives.images.Figure`

Thumbnail directive for reST.

align()

Return thumbnail alignment.

figwidth_value()

Return figure width.

has_content = True
option_spec = {'align': <function Image.align at 0x7f5a3fce8a60>, 'alt': <function unchanged at 0x7f5a423aea60>, 'class': <function class_option at 0x7f5a423aeea0>, 'figclass': <function class_option at 0x7f5a423aeea0>, 'figwidth': <function Thumbnail.figwidth_value at 0x7f5a359aa1e0>, 'height': <function length_or_unitless at 0x7f5a423aed90>, 'name': <function unchanged at 0x7f5a423aea60>, 'scale': <function percentage at 0x7f5a423aec80>, 'target': <function unchanged_required at 0x7f5a423ae9d8>, 'width': <function length_or_percentage_or_unitless at 0x7f5a423aee18>}
run()

Run the thumbnail directive.

nikola.plugins.compile.rest.vimeo module

Vimeo directive for reStructuredText.

class nikola.plugins.compile.rest.vimeo.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for vimeo reST directive.

name = 'rest_vimeo'
set_site(site)

Set Nikola site.

class nikola.plugins.compile.rest.vimeo.Vimeo(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

reST extension for inserting vimeo embedded videos.

Usage:
check_content()

Check if content exists.

check_modules()

Check modules.

has_content = True
option_spec = {'align': <function _align_choice at 0x7f5a3e825c80>, 'height': <function positive_int at 0x7f5a42349158>, 'width': <function positive_int at 0x7f5a42349158>}
request_size = True
required_arguments = 1
run()

Run the vimeo directive.

set_video_size()

Set video size.

nikola.plugins.compile.rest.youtube module

YouTube directive for reStructuredText.

class nikola.plugins.compile.rest.youtube.Plugin

Bases: :class:`nikola.plugin_categories.RestExtension`

Plugin for the youtube directive.

name = 'rest_youtube'
set_site(site)

Set Nikola site.

class nikola.plugins.compile.rest.youtube.Youtube(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: :class:`docutils.parsers.rst.Directive`

reST extension for inserting youtube embedded videos.

Usage:
check_content()

Check if content exists.

has_content = True
option_spec = {'align': <function _align_choice at 0x7f5a3e825c80>, 'height': <function unchanged at 0x7f5a423aea60>, 'width': <function unchanged at 0x7f5a423aea60>}
required_arguments = 1
run()

Run the youtube directive.

Module contents

reStructuredText compiler for Nikola.

class nikola.plugins.compile.rest.CompileRest

Bases: :class:`nikola.plugin_categories.PageCompiler`

Compile reStructuredText into HTML.

compile(source, dest, is_two_file=True, post=None, lang=None)

Compile the source file into HTML and save as dest.

compile_string(data, source_path=None, is_two_file=True, post=None, lang=None)

Compile reST into HTML strings.

create_post(path, **kw)

Create a new post.

demote_headers = True
friendly_name = 'reStructuredText'
logger = None
metadata_conditions = [(<MetaCondition.config_bool: 1>, 'USE_REST_DOCINFO_METADATA')]
name = 'rest'
read_metadata(post, lang=None)

Read the metadata from a post, and return a metadata dict.

set_site(site)

Set Nikola site.

supports_metadata = True
class nikola.plugins.compile.rest.NikolaReader(*args, **kwargs)

Bases: :class:`docutils.readers.standalone.Reader`

Nikola-specific docutils reader.

config_section = 'nikola'
get_transforms()

Get docutils transforms.

new_document()

Create and return a new empty document tree (root node).

class nikola.plugins.compile.rest.RemoveDocinfo(document, startnode=None)

Bases: :class:`docutils.transforms.Transform`

Remove docinfo nodes.

apply()

Remove docinfo nodes.

default_priority = 870
nikola.plugins.compile.rest.add_node(node, visit_function=None, depart_function=None)

Register a Docutils node class.

This function is completely optional. It is a same concept as Sphinx add_node function.

For example:

class Plugin(RestExtension):

    name = "rest_math"

    def set_site(self, site):
        self.site = site
        directives.register_directive('math', MathDirective)
        add_node(MathBlock, visit_Math, depart_Math)
        return super(Plugin, self).set_site(site)

class MathDirective(Directive):
    def run(self):
        node = MathBlock()
        return [node]

class Math(docutils.nodes.Element): pass

def visit_Math(self, node):
    self.body.append(self.starttag(node, 'math'))

def depart_Math(self, node):
    self.body.append('</math>')

For full example, you can refer to Microdata plugin

nikola.plugins.compile.rest.get_observer(settings)

Return an observer for the docutils Reporter.

nikola.plugins.compile.rest.rst2html(source, source_path=None, source_class=<class 'docutils.io.StringInput'>, destination_path=None, reader=None, parser=None, parser_name='restructuredtext', writer=None, writer_name='html', settings=None, settings_spec=None, settings_overrides=None, config_section='nikola', enable_exit_status=None, logger=None, l_add_ln=0, transforms=None)

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.

For encoded string input, be sure to set the ‘input_encoding’ setting to the desired encoding. Set it to ‘unicode’ for unencoded Unicode string input. Here’s how:

publish_parts(..., settings_overrides={'input_encoding': 'unicode'})

For a description of the parameters, see publish_programmatically.

WARNING: reader should be None (or NikolaReader()) if you want Nikola to report
reStructuredText syntax errors.
nikola.plugins.compile.rest.shortcode_role(name, rawtext, text, lineno, inliner, options={}, content=[])

Return a shortcode role that passes through raw inline HTML.