Welcome to Flask RSTPages’s documentation!

Flask-RSTPages adds support for reStructuredText to your Flask application, allowing to convert a reStructuredText file to html. Source code is rendered via Pygments.


Install the extension with one of the following commands:

$ easy_install Flask-RSTPages

or alternatively if you have pip installed:

$ pip install Flask-RSTPages

How to Use

To get started you must construct a RSTPages object with your Flask instance:

from flask.ext.rstpages import RSTPages
pages = RSTPages(app)

Then, you can use the RSTPages.get() method to convert your reStructuredText file to html:

def get_page(page):
    html = pages.get(page)
    return render_template("page.html", page=html)

The RSTPages.get() method returns an object with title and body attributes.


Flask-RSTPages accepts the following configuration values.

Path to the directory where to look for page files. Defaults to pages.
The view function used to route pages. This is used to support the :doc:`page` markup of Sphinx to cross-reference documents. Defaults to get_rstpage.
Dict with configuration for the docutils html4css1 writer. Defaults to {'initial_header_level': 2}.

API Reference

class flask_rstpages.RSTPages(app=None)

reStructuredText to html renderer

Parameters:app (Flask instance) – your application. Can be omited if you call init_app() later.

Convert a reStructuredText file to html

Return a rstDocument object with the html title and body.

Parameters:page (path) – path to a reStructuredText file

Initialize an application


Version 0.3

Released on 2012-12-13.

Fix a bug introduced with the 0.2 release.

Version 0.2

Released on 2012-12-13.

Add a setting to configure the docutils html writer.

Version 0.1

Released on 2012-11-03.

First public release.