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 all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
python-version: ${{ matrix.python }}
- name: Install Requirements
run: |
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
pip install flake8 pylint pytest
pip install -r test/requirements.txt
python setup.py install
python3 setup.py install
- name: Run Linter
run: |
flake8 setup.py example stone test
pylint --rcfile=.pylintrc setup.py example stone test
python3 -m flake8 setup.py example stone test
python3 -m pylint --rcfile=.pylintrc setup.py example stone test
- name: Run Unit Tests
run: |
pytest
python3 -m pytest
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