Created
August 23, 2011 13:36
-
-
Save timc3/1165136 to your computer and use it in GitHub Desktop.
DocString django template tag for organizing documentation into django templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
DocString node. | |
An example of a docstring django template tag. For example add to builtins by including in an imported file:: | |
from django.template import add_to_builtins | |
add_to_builtins('appname.templatetags.docstring') | |
""" | |
from django.template import (Library, Node) | |
register = Library() | |
class DocStringNode(Node): | |
def render(self, context): | |
return '' | |
@register.tag | |
def docstring(parser, token): | |
""" | |
Ignores the contents, but useful to be parsed out by documentation parser | |
Ignores everything between ``{% docstring %}`` and ``{% enddocstring %}``. | |
""" | |
parser.skip_past('enddocstring') | |
return DocStringNode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Going to followup with Sphinx documentation parser.