Skip to content

Instantly share code, notes, and snippets.

@timc3
Created August 23, 2011 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timc3/1165136 to your computer and use it in GitHub Desktop.
Save timc3/1165136 to your computer and use it in GitHub Desktop.
DocString django template tag for organizing documentation into django templates
"""
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()
@timc3
Copy link
Author

timc3 commented Aug 23, 2011

Going to followup with Sphinx documentation parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment