1.1.1.2.1.2.1.2. nikola.plugins.compile.rest package

reStructuredText compiler for Nikola.

class nikola.plugins.compile.rest.CompileRest

Bases: 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, '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: Reader

Nikola-specific docutils reader.

config_section = 'nikola'

The name of the config file section specific to this component (lowercase, no brackets). Override in subclasses.

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: Transform

Remove docinfo nodes.

apply()

Remove docinfo nodes.

default_priority = 870

Numerical priority of this transform, 0 through 999 (override).

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().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='html5_polyglot', 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.

nikola.plugins.compile.rest.visit_literal(self, node)

Output <code> for double backticks.

1.1.1.2.1.2.1.2.1. Submodules

1.1.1.2.1.2.1.2.2. 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: Directive

reStructuredText extension for inserting charts as SVG.

Usage:
has_content = True

May the directive have content?

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

Mapping of option names to validator functions.

required_arguments = 1

Number of required directive arguments.

run()

Run the directive.

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

Bases: RestExtension

Plugin for chart role.

name = 'rest_chart'
set_site(site)

Set Nikola site.

1.1.1.2.1.2.1.2.3. nikola.plugins.compile.rest.doc module

reST role for linking to other documents.

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

Bases: 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.

1.1.1.2.1.2.1.2.4. 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: Directive

Embed GitHub Gist.

Usage:

or

final_argument_whitespace = True

May the final argument contain whitespace?

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

May the directive have content?

option_spec = {'file': <function unchanged>}

Mapping of option names to validator functions.

optional_arguments = 1

Number of optional arguments after the required arguments.

required_arguments = 1

Number of required directive arguments.

run()

Run the gist directive.

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

Bases: RestExtension

Plugin for gist directive.

name = 'rest_gist'
set_site(site)

Set Nikola site.

1.1.1.2.1.2.1.2.5. 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: Directive

Parse and mark up content of a code block.

has_content = True

May the directive have content?

option_spec = {'class': <function class_option>, 'emphasize-lines': <function unchanged_required>, 'linenos': <function unchanged>, 'name': <function unchanged>, 'number-lines': <function unchanged>, 'tab-width': <function nonnegative_int>}

Mapping of option names to validator functions.

optional_arguments = 1

Number of optional arguments after the required arguments.

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: 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

May the directive have content?

option_spec = {'class': <function class_option>, 'code': <function unchanged>, 'encoding': <function encoding>, 'end-before': <function unchanged_required>, 'end-line': <class 'int'>, 'linenos': <function unchanged>, 'literal': <function flag>, 'name': <function unchanged>, 'number-lines': <function unchanged>, 'parser': <function parser_name>, 'start-after': <function unchanged_required>, 'start-line': <class 'int'>, 'tab-width': <class 'int'>}

Mapping of option names to validator functions.

optional_arguments = 1

Number of optional arguments after the required arguments.

required_arguments = 1

Number of required directive arguments.

run()

Run listing directive.

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

Bases: RestExtension

Plugin for listing directive.

name = 'rest_listing'
set_site(site)

Set Nikola site.

1.1.1.2.1.2.1.2.6. 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: Directive

reST extension for inserting any sort of media using micawber.

has_content = False

May the directive have content?

optional_arguments = 999

Number of optional arguments after the required arguments.

required_arguments = 1

Number of required directive arguments.

run()

Run media directive.

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

Bases: RestExtension

Plugin for reST media directive.

name = 'rest_media'
set_site(site)

Set Nikola site.

1.1.1.2.1.2.1.2.7. nikola.plugins.compile.rest.post_list module

Post list directive for reStructuredText.

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

Bases: 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: Directive

Provide a reStructuredText directive to create a list of posts.

option_spec = {'categories': <function unchanged>, 'date': <function unchanged>, 'id': <function unchanged>, 'lang': <function unchanged>, 'post_type': <function unchanged>, 'require_all_tags': <function flag>, 'reverse': <function flag>, 'sections': <function unchanged>, 'slugs': <function unchanged>, 'sort': <function unchanged>, 'start': <class 'int'>, 'stop': <class 'int'>, 'tags': <function unchanged>, 'template': <function path>, 'type': <function unchanged>}

Mapping of option names to validator functions.

run()

Run post-list directive.

1.1.1.2.1.2.1.2.8. nikola.plugins.compile.rest.soundcloud module

SoundCloud directive for reStructuredText.

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

Bases: 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: Directive

reST extension for inserting SoundCloud embedded music.

Usage:
check_content()

Emit a deprecation warning if there is content.

has_content = True

May the directive have content?

option_spec = {'align': <function _align_choice>, 'height': <function positive_int>, 'width': <function positive_int>}

Mapping of option names to validator functions.

preslug = 'tracks'
required_arguments = 1

Number of required directive arguments.

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: SoundCloud

reST directive for SoundCloud playlists.

preslug = 'playlists'

1.1.1.2.1.2.1.2.9. nikola.plugins.compile.rest.thumbnail module

Thumbnail directive for reStructuredText.

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

Bases: 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: Figure

Thumbnail directive for reST.

align()

Return thumbnail alignment.

figwidth_value()

Return figure width.

has_content = True

May the directive have content?

option_spec = {'align': <function Image.align>, 'alt': <function unchanged>, 'class': <function class_option>, 'figclass': <function class_option>, 'figwidth': <function Thumbnail.figwidth_value>, 'height': <function length_or_unitless>, 'name': <function unchanged>, 'scale': <function percentage>, 'target': <function unchanged_required>, 'width': <function length_or_percentage_or_unitless>}

Mapping of option names to validator functions.

run()

Run the thumbnail directive.

1.1.1.2.1.2.1.2.10. nikola.plugins.compile.rest.vimeo module

Vimeo directive for reStructuredText.

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

Bases: 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: Directive

reST extension for inserting vimeo embedded videos.

Usage:
check_content()

Check if content exists.

check_modules()

Check modules.

has_content = True

May the directive have content?

option_spec = {'align': <function _align_choice>, 'height': <function positive_int>, 'width': <function positive_int>}

Mapping of option names to validator functions.

request_size = True
required_arguments = 1

Number of required directive arguments.

run()

Run the vimeo directive.

set_video_size()

Set video size.

1.1.1.2.1.2.1.2.11. nikola.plugins.compile.rest.youtube module

YouTube directive for reStructuredText.

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

Bases: 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: Directive

reST extension for inserting youtube embedded videos.

Usage:
check_content()

Check if content exists.

has_content = True

May the directive have content?

option_spec = {'align': <function _align_choice>, 'height': <function unchanged>, 'start_at': <function unchanged>, 'width': <function unchanged>}

Mapping of option names to validator functions.

required_arguments = 1

Number of required directive arguments.

run()

Run the youtube directive.