mini_wiki package

Submodules

mini_wiki.models module

exception mini_wiki.models.NoRenderEngineError[source]

Bases: mini_wiki.models.PageError

Exception raised when there are no supported render engines.

class mini_wiki.models.Page(filename=None, content=None, repo=None, config=None)[source]

Bases: object

commit(message, author)[source]

Commit the file. (i.e. run “git commit -m $message”)

Parameters:
  • message (str) – The commit message
  • author (git.Actor) – The person making a change to the file
format()[source]

Get a formatted form of the header and page content.

classmethod from_file(filename)[source]

Given a path to a file, parse its contents and get the corresponding Page object.

header()[source]

Create a jekyll-style header for the file.

static parse_text(text)[source]

Given a string of text, parse it and retrieve the header and content.

The text must have the following format: - Line with ‘—’ to specify the start of the header section - One or more lines of valid YAML that contain metadata about the file - Line with ‘—’ to specify the end of the header section - A blank line - Body of the document (may be empty)

Parameters:text (str) – The text to parse
Returns:
  • header (dict) – A dictionary containing metadata about the file
  • body (str) – The body of the file
Raises:ParseError – When the file isn’t formatted correctly
save()[source]

Write a copy of the

to_html()[source]

Get a html version of the page’s content.

Depending on the ‘format’ key in the page’s metadata, different rendering methods will be used.

Rendering Methods: markdown

Use the [markdown](https://pythonhosted.org/Markdown/) library.
html
Don’t do anything to the content and return it as-is.
exception mini_wiki.models.PageError[source]

Bases: Exception

A generic exception for all issues with pages.

exception mini_wiki.models.ParseError[source]

Bases: mini_wiki.models.PageError

Exception raised when there was an error parsing a page.

mini_wiki.utils module

class mini_wiki.utils.TreeNode(path, base_path)[source]

Bases: object

add_child(child_node)[source]
is_index()[source]
location()[source]

Get the location relative to the _site directory

name()[source]
mini_wiki.utils.add_children(parent_node, path, base_path)[source]
mini_wiki.utils.dict_keys_to_upper(some_dict)[source]
mini_wiki.utils.filename_to_title(filename)[source]

Turn a filename from a normal path to it’s equivalent title. This usually involves the following changes: - replacing all underscores with spaces - removing the extension - making it titlecase

mini_wiki.utils.title_to_filename(title, parent_dir='', ext='md')[source]

Turn a file’s title into it’s equivalent filename.

This usually involves: - replace all spaces with underscores - make everything lowercase - prepend the filename with it’s parent directory - add the appropriate extension

Raises:ValueError – If the filename contains a forward slash (“/”)
mini_wiki.utils.tree(root_dir)[source]
mini_wiki.utils.valid_page(path)[source]

mini_wiki.views module

mini_wiki.views.four_oh_four(e)[source]
mini_wiki.views.homepage()[source]
mini_wiki.views.server_error(e)[source]
mini_wiki.views.wiki_index()[source]
mini_wiki.views.wiki_page(page_path)[source]

Get the file located at page_path and render it as a html page.

Module contents

mini_wiki.create_app(config_dict)[source]