mini_wiki package¶
Submodules¶
mini_wiki.models module¶
-
exception
mini_wiki.models.NoRenderEngineError[source]¶ Bases:
mini_wiki.models.PageErrorException 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
-
classmethod
from_file(filename)[source]¶ Given a path to a file, parse its contents and get the corresponding Page object.
-
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
-
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:
ExceptionA generic exception for all issues with pages.
-
exception
mini_wiki.models.ParseError[source]¶ Bases:
mini_wiki.models.PageErrorException raised when there was an error parsing a page.
mini_wiki.utils module¶
-
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 (“/”)