django-docutils


Namedjango-docutils JSON
Version 0.25.0 PyPI version JSON
download
home_pagehttps://django-docutils.git-pull.com
SummaryDocutils (a.k.a. reStructuredText, reST, RST) support for django.
upload_time2024-03-24 17:55:49
maintainerNone
docs_urlNone
authorTony Narlock
requires_python<4.0,>=3.8
licenseMIT
keywords django docutils restructuredtext rst rest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-docutils &middot; [![Python Package](https://img.shields.io/pypi/v/django-docutils.svg)](https://pypi.org/project/django-docutils/) [![License](https://img.shields.io/github/license/tony/django-docutils.svg)](https://github.com/tony/django-docutils/blob/master/LICENSE)

docutils (a.k.a. reStructuredText / rst / reST) support for Django.

## Quickstart

Install django-docutils:

```console
$ pip install django-docutils
```

Next, add `django_docutils` to your `INSTALLED_APPS` in your settings file:

```python
INSTALLED_APPS = [
    # ... your default apps,
    'django_docutils'
]
```

## Template tag

In your template:

```django
{% load django_docutils %}
{% rst %}
# hey
# how's it going
A. hows
B. it

C. going
D. today

**hi**
*hi*
{% endrst %}
```

## Template filter

In your template:

```django
{% load django_docutils %}
{% filter rst %}
# hey
# how's it going
A. hows
B. it

C. going
D. today

**hi**
*hi*
{% endfilter %}
```

## Template engine (class-based view)

You can also use a class-based view to render reStructuredText (reST).

If you want to use reStructuredText as a django template engine, `INSTALLED_APPS` _isn't_ required,
instead you add this to your `TEMPLATES` variable in your settings:

```python
TEMPLATES = [
    # ... Other engines
    {
        "NAME": "docutils",
        "BACKEND": "django_docutils.template.DocutilsTemplates",
        "DIRS": [],
        "APP_DIRS": True,
    }
]
```

Now django will be able to scan for .rst files and process them. In your view:

```python
from django_docutils.views import DocutilsView

class HomeView(DocutilsView):
    template_name = 'base.html'
    rst_name = 'home.rst'
```

# Settings

```python
# Optional, automatically maps roles, directives and transformers
DJANGO_DOCUTILS_LIB_RST = {
    "docutils": {
        "raw_enabled": True,
        "strip_comments": True,
        "initial_header_level": 2,
    },
    "roles": {
        "local": {
            "gh": "django_docutils.lib.roles.github.github_role",
            "twitter": "django_docutils.lib.roles.twitter.twitter_role",
            "email": "django_docutils.lib.roles.email.email_role",
        }
    },
    "directives": {
        "code-block": "django_docutils.lib.directives.code.CodeBlock",
    }
}

# Optional
DJANGO_DOCUTILS_LIB_TEXT = {
    "uncapitalized_word_filters": ["project.my_module.my_capitalization_fn"]
}
```

## More information

- Python 3.8+
- Django 3.2+

[![Docs](https://github.com/tony/django-docutils/workflows/docs/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22Docs%22)
[![Build Status](https://github.com/tony/django-docutils/workflows/tests/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22tests%22)
[![Code Coverage](https://codecov.io/gh/tony/django-docutils/branch/master/graph/badge.svg)](https://codecov.io/gh/tony/django-docutils)


            

Raw data

            {
    "_id": null,
    "home_page": "https://django-docutils.git-pull.com",
    "name": "django-docutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "django, docutils, reStructuredText, rst, reST",
    "author": "Tony Narlock",
    "author_email": "tony@git-pull.com",
    "download_url": "https://files.pythonhosted.org/packages/b2/b3/aaa0b992b725a7287159129b5c76922ca57b5a0fe6b0d8c41fb2c66b49c3/django_docutils-0.25.0.tar.gz",
    "platform": null,
    "description": "# django-docutils &middot; [![Python Package](https://img.shields.io/pypi/v/django-docutils.svg)](https://pypi.org/project/django-docutils/) [![License](https://img.shields.io/github/license/tony/django-docutils.svg)](https://github.com/tony/django-docutils/blob/master/LICENSE)\n\ndocutils (a.k.a. reStructuredText / rst / reST) support for Django.\n\n## Quickstart\n\nInstall django-docutils:\n\n```console\n$ pip install django-docutils\n```\n\nNext, add `django_docutils` to your `INSTALLED_APPS` in your settings file:\n\n```python\nINSTALLED_APPS = [\n    # ... your default apps,\n    'django_docutils'\n]\n```\n\n## Template tag\n\nIn your template:\n\n```django\n{% load django_docutils %}\n{% rst %}\n# hey\n# how's it going\nA. hows\nB. it\n\nC. going\nD. today\n\n**hi**\n*hi*\n{% endrst %}\n```\n\n## Template filter\n\nIn your template:\n\n```django\n{% load django_docutils %}\n{% filter rst %}\n# hey\n# how's it going\nA. hows\nB. it\n\nC. going\nD. today\n\n**hi**\n*hi*\n{% endfilter %}\n```\n\n## Template engine (class-based view)\n\nYou can also use a class-based view to render reStructuredText (reST).\n\nIf you want to use reStructuredText as a django template engine, `INSTALLED_APPS` _isn't_ required,\ninstead you add this to your `TEMPLATES` variable in your settings:\n\n```python\nTEMPLATES = [\n    # ... Other engines\n    {\n        \"NAME\": \"docutils\",\n        \"BACKEND\": \"django_docutils.template.DocutilsTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n    }\n]\n```\n\nNow django will be able to scan for .rst files and process them. In your view:\n\n```python\nfrom django_docutils.views import DocutilsView\n\nclass HomeView(DocutilsView):\n    template_name = 'base.html'\n    rst_name = 'home.rst'\n```\n\n# Settings\n\n```python\n# Optional, automatically maps roles, directives and transformers\nDJANGO_DOCUTILS_LIB_RST = {\n    \"docutils\": {\n        \"raw_enabled\": True,\n        \"strip_comments\": True,\n        \"initial_header_level\": 2,\n    },\n    \"roles\": {\n        \"local\": {\n            \"gh\": \"django_docutils.lib.roles.github.github_role\",\n            \"twitter\": \"django_docutils.lib.roles.twitter.twitter_role\",\n            \"email\": \"django_docutils.lib.roles.email.email_role\",\n        }\n    },\n    \"directives\": {\n        \"code-block\": \"django_docutils.lib.directives.code.CodeBlock\",\n    }\n}\n\n# Optional\nDJANGO_DOCUTILS_LIB_TEXT = {\n    \"uncapitalized_word_filters\": [\"project.my_module.my_capitalization_fn\"]\n}\n```\n\n## More information\n\n- Python 3.8+\n- Django 3.2+\n\n[![Docs](https://github.com/tony/django-docutils/workflows/docs/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22Docs%22)\n[![Build Status](https://github.com/tony/django-docutils/workflows/tests/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22tests%22)\n[![Code Coverage](https://codecov.io/gh/tony/django-docutils/branch/master/graph/badge.svg)](https://codecov.io/gh/tony/django-docutils)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Docutils (a.k.a. reStructuredText, reST, RST) support for django.",
    "version": "0.25.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/tony/django-docutils/issues",
        "Changes": "https://github.com/tony/django-docutils/blob/master/CHANGES",
        "Documentation": "https://django-docutils.git-pull.com",
        "Homepage": "https://django-docutils.git-pull.com",
        "Q & A": "https://github.com/tony/django-docutils/discussions",
        "Repository": "https://github.com/tony/django-docutils"
    },
    "split_keywords": [
        "django",
        " docutils",
        " restructuredtext",
        " rst",
        " rest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc517c84b40523f9305d67f677f473bc858d63de14c56591b216e9564da4a883",
                "md5": "a9366e3519cc708f54fc2622051930f9",
                "sha256": "b32b6f204d0de88b9c329b0ec8506e7b122d3a0fe6f3fb1c4c8dad9c0c6c072a"
            },
            "downloads": -1,
            "filename": "django_docutils-0.25.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a9366e3519cc708f54fc2622051930f9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 44759,
            "upload_time": "2024-03-24T17:55:46",
            "upload_time_iso_8601": "2024-03-24T17:55:46.615110Z",
            "url": "https://files.pythonhosted.org/packages/dc/51/7c84b40523f9305d67f677f473bc858d63de14c56591b216e9564da4a883/django_docutils-0.25.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2b3aaa0b992b725a7287159129b5c76922ca57b5a0fe6b0d8c41fb2c66b49c3",
                "md5": "99f4b3bfb941ffef8089f728b3b2b3d1",
                "sha256": "f1550ec53ae0ce9d8569c5750e2c1cccd63e2a3e86dd96753fde466e5c07fc65"
            },
            "downloads": -1,
            "filename": "django_docutils-0.25.0.tar.gz",
            "has_sig": false,
            "md5_digest": "99f4b3bfb941ffef8089f728b3b2b3d1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 33566,
            "upload_time": "2024-03-24T17:55:49",
            "upload_time_iso_8601": "2024-03-24T17:55:49.401479Z",
            "url": "https://files.pythonhosted.org/packages/b2/b3/aaa0b992b725a7287159129b5c76922ca57b5a0fe6b0d8c41fb2c66b49c3/django_docutils-0.25.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 17:55:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tony",
    "github_project": "django-docutils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-docutils"
}
        
Elapsed time: 0.21256s