Skip to content

Commit

Permalink
Improves the README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
rgs258 committed Jul 8, 2020
1 parent 341dd08 commit 2ee6771
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.0.3 (2020-07-08)
------------------
#. Correct a typo the README.rst
#. Add settings to the README.rst

0.0.2 (2020-07-06)
------------------
#. Remove support for Django pre-2.2
Expand Down
58 changes: 54 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Installation

#. Install with ``pip install django-markdown-view``.

#. Add ``'markdown_view'`` to your ``INSTALLED_APPS`` setting.
#. Add ``'markdown_view'`` to your ``INSTALLED_APPS`` settings.

.. code-block:: python
Expand All @@ -44,7 +44,8 @@ Installation
...
]
#. (OPTIONAL) Add ``BASE_DIR`` setting (dictionary of app base), for example:
#. (OPTIONAL) Add ``MARKDOWN_VIEW_BASE_DIR`` or ``BASE_DIR`` to settings
The dictionary of the application's base. For example:

.. code-block:: python
Expand All @@ -58,13 +59,62 @@ Views
~~~~~

Use one of ``MarkdownView``, ``LoggedInMarkdownView``, or ``StaffMarkdownView``
to serve a .md file
from ``markdown_view.views`` to serve a .md file

.. code-block:: python
from markdown_view import StaffMarkdownView
from markdown_view.views import StaffMarkdownView
path('readme/',
StaffMarkdownView.as_view(file_name='my_app/README.md'),
name="readme"),
Settings
~~~~~~~~
All settings are optional. See **markdown_view/constants.py** for the defaults.

* `MARKDOWN_VIEW_BASE_DIR` and `BASE_DIR`

When present, the location to append to the list of dirs that Django's
`django.template.utils.get_app_template_dirs` will return. Looks for
`BASE_DIR` if `MARKDOWN_VIEW_BASE_DIR` is not found. This is used to
allow .md files in the root of the project to be located.

* `MARKDOWN_VIEW_LOADERS`

The loader that finds .md files in the context of any installed app or
one of `MARKDOWN_VIEW_BASE_DIR` or `BASE_DIR`.

* `DEFAULT_MARKDOWN_VIEW_EXTENSIONS`

The extensions to enable. See https://python-markdown.github.io/extensions/ and
https://github.com/Python-Markdown/markdown/wiki/Third-Party-Extensions for more
extensions. Note that `markdown_view.markdown_extensions.ImageExtension` is enabled
and makes images responsive in bootstrap4. You can add you own extensions by
following https://github.com/Python-Markdown/markdown/wiki/Tutorial-1---Writing-Extensions-for-Python-Markdown

* `DEFAULT_MARKDOWN_VIEW_TEMPLATE`

The Django template that'll be used to render the HTML that is generated from the
Markdown. Set your own template to style your pages. Context includes:

* `markdown_content`: The HTML produced from the Markdown
* `markdown_toc`: A table of contents from the headers of the Markdown
* `page_title`: A guess at a page title, for now it's the first row of the TOC

Experimental Settings
~~~~~~~~~~~~~~~~~~~~~

* `DEFAULT_MARKDOWN_VIEW_USE_REQUEST_CONTEXT`

If the request context should be used as a base when creating the context with
which to render the Markdown internally. This is because the Markdown is rendered
once first in order to prepend it with `{% load static %}`.
This is not well tested; YMMV.

* `DEFAULT_MARKDOWN_VIEW_EXTRA_CONTEXT`

Any extra context to send to the internal render of the Markdown. Can be used
to expose context to template tags embedded in the Markdown.
This is not well tested; YMMV.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='django-markdown-view',
version='0.0.2',
version='0.0.3',
description='Serve .md pages as Django templates.',
long_description=long_desc,
author='Ryan J. Sullivan',
Expand Down

0 comments on commit 2ee6771

Please sign in to comment.