Skip to content

Commit

Permalink
Update Python Backend Docstring (#188)
Browse files Browse the repository at this point in the history
* Update Python Backend Docstring

- Rather than emitting the doc directly run through process_doc
- Fix for ([PR #252](dropbox/dropbox-sdk-python#252))

* Update CI to run entirely python3
  • Loading branch information
rogebrd committed Oct 8, 2020
1 parent 150391e commit 20212c6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
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

0 comments on commit 20212c6

Please sign in to comment.