Using doc comments instead of docstrings for attributes.

This commit is contained in:
Benoît Bryon 2013-02-06 19:07:23 +01:00
parent e94054bcba
commit 02f0b7aa0d
2 changed files with 18 additions and 21 deletions

View file

@ -12,27 +12,26 @@ from demoproject.download.models import Document
# Some initializations.
#: Directory containing code of :py:module:`demoproject.download.views`.
app_dir = dirname(abspath(__file__))
"""Directory containing code of :py:module:`demoproject.download.views`."""
#: Directory containing files fixtures.
fixtures_dir = join(app_dir, 'fixtures')
"""Directory containing files fixtures."""
#: Path to a text file that says 'Hello world!'.
hello_world_path = join(fixtures_dir, 'hello-world.txt')
"""Path to a text file that says 'Hello world!'."""
#: Storage for fixtures.
fixtures_storage = FileSystemStorage(location=fixtures_dir)
"""Storage for fixtures."""
# Here are the views.
#: Direct download of one file, based on an absolute path.
#:
#: You could use this example as a shortcut, inside other views.
download_hello_world = PathDownloadView.as_view(path=hello_world_path)
"""Direct download of one file, based on an absolute path.
You could use this example as a shortcut, inside other views.
"""
class CustomPathDownloadView(PathDownloadView):
@ -52,14 +51,14 @@ class CustomPathDownloadView(PathDownloadView):
path = super(CustomPathDownloadView, self).get_path()
return join(fixtures_dir, path)
#: Pre-configured :py:class:`CustomPathDownloadView`.
download_fixture_from_path = CustomPathDownloadView.as_view()
"""Pre-configured :py:class:`CustomPathDownloadView`."""
#: Pre-configured view using a storage.
download_fixture_from_storage = StorageDownloadView.as_view(
storage=fixtures_storage)
"""Pre-configured view using a storage."""
#: Pre-configured download view for :py:class:`Document` model.
download_document = ObjectDownloadView.as_view(model=Document)
"""Pre-configured download view for :py:class:`Document` model."""

View file

@ -70,16 +70,14 @@ class BaseDownloadView(DownloadMixin, View):
class PathDownloadView(BaseDownloadView):
"""Serve a file using filename."""
#: Server-side name (including path) of the file to serve.
#:
#: Filename is supposed to be an absolute filename of a file located on the
#: local filesystem.
path = None
"""Server-side name (including path) of the file to serve.
Filename is supposed to be an absolute filename of a file located on the
local filesystem.
"""
#: Name of the URL argument that contains path.
path_url_kwarg = 'path'
"""Name of the URL argument that contains path."""
def get_path(self):
"""Return actual path of the file to serve.
@ -100,11 +98,11 @@ class PathDownloadView(BaseDownloadView):
class StorageDownloadView(PathDownloadView):
"""Serve a file using storage and filename."""
#: Storage the file to serve belongs to.
storage = DefaultStorage()
"""Storage the file to serve belongs to."""
#: Path to the file to serve relative to storage.
path = None # Override docstring.
"""Path to the file to serve relative to storage."""
def get_path(self):
"""Return path of the file to serve, relative to storage.