Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python Backend Docstring #188

Merged
merged 2 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion stone/backends/python_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _generate_base_namespace_module(self, api, namespace):

if namespace.doc is not None:
self.emit('"""')
self.emit_raw(namespace.doc)
self.emit_raw(self.process_doc(namespace.doc, self._docf))
self.emit('"""')
self.emit()

Expand Down
44 changes: 44 additions & 0 deletions test/test_python_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def _evaluate_namespace(self, ns):
backend._generate_routes(route_schema, ns)
return backend.output_buffer_to_string()

def _evaluate_namespace_definition(self, api, ns):
# type: (ApiNamespace) -> typing.Text
backend = self._mock_backend()
backend._generate_base_namespace_module(api, ns)
return backend.output_buffer_to_string()

def _evaluate_struct(self, ns, struct):
# type: (ApiNamespace, Struct) -> typing.Text
backend = self._mock_backend()
Expand All @@ -53,6 +59,44 @@ def _evaluate_annotation_type(self, ns, annotation_type):
backend._generate_annotation_type_class(ns, annotation_type)
return backend.output_buffer_to_string()

def test_namespace_comments(self):
# type: () -> None
ns = ApiNamespace('files')
ns.add_doc("Test Doc testing a :type:`Type`.")

route_schema = self._mk_route_schema()

class ApiHolder(object):
pass

api = ApiHolder()
api.route_schema = route_schema

result = self._evaluate_namespace_definition(api, ns)

expected = textwrap.dedent("""\
# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa
# pylint: skip-file
\"\"\"
Test Doc testing a :class:`Type`.
\"\"\"

from __future__ import unicode_literals
from stone.backends.python_rsrc import stone_base as bb
from stone.backends.python_rsrc import stone_validators as bv

ROUTES = {
}

""")

self.assertEqual(result, expected)



def test_route_with_version_number(self):
# type: () -> None

Expand Down