mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Merge e4a81d2903
into 5ea810d526
This commit is contained in:
commit
92c56d5d6f
|
@ -476,7 +476,7 @@ class SchemaGenerator(object):
|
|||
return formatting.dedent(smart_text(method_docstring))
|
||||
|
||||
description = view.get_view_description()
|
||||
lines = [line.strip() for line in description.splitlines()]
|
||||
lines = [line for line in description.splitlines()]
|
||||
current_section = ''
|
||||
sections = {'': ''}
|
||||
|
||||
|
|
|
@ -496,3 +496,45 @@ class Test4605Regression(TestCase):
|
|||
'/auth/convert-token/'
|
||||
])
|
||||
assert prefix == '/'
|
||||
|
||||
|
||||
class ExampleDocstringAPIView(APIView):
|
||||
"""
|
||||
=== title
|
||||
|
||||
* item a
|
||||
* item a-a
|
||||
* item a-b
|
||||
* item b
|
||||
|
||||
- item 1
|
||||
- item 2
|
||||
|
||||
code block begin
|
||||
code
|
||||
code
|
||||
code
|
||||
code block end
|
||||
|
||||
the end
|
||||
"""
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class TestDocstringIsNotStrippedByGetDescription(TestCase):
|
||||
def setUp(self):
|
||||
self.patterns = [
|
||||
url('^example/?$', ExampleDocstringAPIView.as_view()),
|
||||
]
|
||||
|
||||
def test_docstring(self):
|
||||
view = ExampleDocstringAPIView()
|
||||
generator = SchemaGenerator(title='Example API', patterns=self.patterns)
|
||||
descr = generator.get_description('example', 'get', view)
|
||||
# the first and last character are '\n' correctly removed by get_description
|
||||
assert descr == ExampleDocstringAPIView.__doc__[1:][:-1]
|
||||
|
|
Loading…
Reference in New Issue
Block a user