当前位置: 首页>>代码示例>>Python>>正文


Python restdoc.DocumentStructure类代码示例

本文整理汇总了Python中botocore.docs.bcdoc.restdoc.DocumentStructure的典型用法代码示例。如果您正苦于以下问题:Python DocumentStructure类的具体用法?Python DocumentStructure怎么用?Python DocumentStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DocumentStructure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_docstring

 def _create_docstring(self):
     docstring_structure = DocumentStructure('docstring')
     # Call the document method function with the args and kwargs
     # passed to the class.
     self._write_docstring(
         docstring_structure, *self._gen_args,
         **self._gen_kwargs)
     return docstring_structure.flush_structure().decode('utf-8')
开发者ID:monkeysecurity,项目名称:botocore,代码行数:8,代码来源:docstring.py

示例2: setUp

    def setUp(self):
        self.root_dir = tempfile.mkdtemp()
        self.version_dirs = os.path.join(
            self.root_dir, 'myservice', '2014-01-01')
        os.makedirs(self.version_dirs)

        self.model_file = os.path.join(self.version_dirs, 'service-2.json')
        self.waiter_model_file = os.path.join(
            self.version_dirs, 'waiters-2.json')
        self.paginator_model_file = os.path.join(
            self.version_dirs, 'paginators-1.json')
        self.resource_model_file = os.path.join(
            self.version_dirs, 'resources-1.json')

        self.json_model = {}
        self.waiter_json_model = {}
        self.paginator_json_model = {}
        self.resource_json_model = {}
        self._setup_models()
        self._write_models()

        self.doc_name = 'MyDoc'
        self.doc_structure = DocumentStructure(self.doc_name)

        self.loader = Loader(extra_search_paths=[self.root_dir])
        self.botocore_session = botocore.session.get_session()
        self.botocore_session.register_component('data_loader', self.loader)
        self.session = Session(botocore_session=self.botocore_session)
        self.client = self.session.client('myservice', 'us-east-1')
        self.resource = self.session.resource('myservice', 'us-east-1')
开发者ID:jonathanwcrane,项目名称:boto3,代码行数:30,代码来源:__init__.py

示例3: setUp

    def setUp(self):
        self.root_dir = tempfile.mkdtemp()
        self.version_dirs = os.path.join(self.root_dir, "myservice", "2014-01-01")
        os.makedirs(self.version_dirs)

        self.model_file = os.path.join(self.version_dirs, "service-2.json")
        self.waiter_model_file = os.path.join(self.version_dirs, "waiters-2.json")
        self.paginator_model_file = os.path.join(self.version_dirs, "paginators-1.json")
        self.resource_model_file = os.path.join(self.version_dirs, "resources-1.json")

        self.json_model = {}
        self.waiter_json_model = {}
        self.paginator_json_model = {}
        self.resource_json_model = {}
        self._setup_models()
        self._write_models()

        self.doc_name = "MyDoc"
        self.doc_structure = DocumentStructure(self.doc_name)

        self.loader = Loader(extra_search_paths=[self.root_dir])
        self.botocore_session = botocore.session.get_session()
        self.botocore_session.register_component("data_loader", self.loader)
        self.session = Session(botocore_session=self.botocore_session, region_name="us-east-1")
        self.client = self.session.client("myservice", "us-east-1")
        self.resource = self.session.resource("myservice", "us-east-1")
开发者ID:thedrow,项目名称:boto3,代码行数:26,代码来源:__init__.py

示例4: setUp

    def setUp(self):
        self.root_dir = tempfile.mkdtemp()
        self.version_dirs = os.path.join(
            self.root_dir, 'myservice', '2014-01-01')
        os.makedirs(self.version_dirs)

        self.model_file = os.path.join(self.version_dirs, 'service-2.json')
        self.waiter_model_file = os.path.join(
            self.version_dirs, 'waiters-2.json')
        self.paginator_model_file = os.path.join(
            self.version_dirs, 'paginators-1.json')
        self.resource_model_file = os.path.join(
            self.version_dirs, 'resources-1.json')
        self.example_model_file = os.path.join(
            self.version_dirs, 'examples-1.json')

        self.json_model = {}
        self.waiter_json_model = {}
        self.paginator_json_model = {}
        self.resource_json_model = {}
        self._setup_models()

        self.doc_name = 'MyDoc'
        self.doc_structure = DocumentStructure(self.doc_name)

        self.setup_client_and_resource()
开发者ID:Armin-Smailzade,项目名称:boto3,代码行数:26,代码来源:__init__.py

示例5: test_create_sections_at_instantiation

 def test_create_sections_at_instantiation(self):
     sections = ['intro', 'middle', 'end']
     self.doc_structure = DocumentStructure(
         self.name, section_names=sections)
     # Ensure the sections are attached to the new document structure.
     for section_name in sections:
         section = self.doc_structure.get_section(section_name)
         self.assertEqual(section.name, section_name)
开发者ID:boto,项目名称:botocore,代码行数:8,代码来源:test_document.py

示例6: document_service

    def document_service(self):
        """Documents an entire service.

        :returns: The reStructured text of the documented service.
        """
        doc_structure = DocumentStructure(
            self._service_name, section_names=self.sections,
            target='html')
        self.title(doc_structure.get_section('title'))
        self.table_of_contents(doc_structure.get_section('table-of-contents'))

        self.client_api(doc_structure.get_section('client'))
        self.paginator_api(doc_structure.get_section('paginators'))
        self.waiter_api(doc_structure.get_section('waiters'))
        if self._service_resource:
            self._document_service_resource(
                doc_structure.get_section('service-resource'))
            self._document_resources(doc_structure.get_section('resources'))
        self._document_examples(doc_structure.get_section('examples'))
        return doc_structure.flush_structure()
开发者ID:boto,项目名称:boto3,代码行数:20,代码来源:service.py

示例7: setUp

    def setUp(self):
        self.original_name = 'original'
        self.alias_name = 'alias'
        self.parameter_alias = handlers.ParameterAlias(
            self.original_name, self.alias_name)

        self.operation_model = mock.Mock()
        request_shape = DenormalizedStructureBuilder().with_members(
            {self.original_name: {'type': 'string'}}).build_model()
        self.operation_model.input_shape = request_shape
        self.sample_section = DocumentStructure('')
        self.event_emitter = HierarchicalEmitter()
开发者ID:kyleknap,项目名称:botocore,代码行数:12,代码来源:test_handlers.py

示例8: document_service

    def document_service(self):
        """Documents an entire service.

        :returns: The reStructured text of the documented service.
        """
        doc_structure = DocumentStructure(
            self._service_name, section_names=self.sections)
        self.title(doc_structure.get_section('title'))
        self.table_of_contents(doc_structure.get_section('table-of-contents'))
        self.client_api(doc_structure.get_section('client-api'))
        self.paginator_api(doc_structure.get_section('paginator-api'))
        self.waiter_api(doc_structure.get_section('waiter-api'))
        return doc_structure.flush_structure()
开发者ID:henrysher,项目名称:botocorev063p,代码行数:13,代码来源:service.py

示例9: setUp

    def setUp(self):
        self.root_dir = tempfile.mkdtemp()
        self.version_dirs = os.path.join(
            self.root_dir, 'myservice', '2014-01-01')
        os.makedirs(self.version_dirs)
        self.model_file = os.path.join(self.version_dirs, 'service-2.json')
        self.waiter_model_file = os.path.join(
            self.version_dirs, 'waiters-2.json')
        self.paginator_model_file = os.path.join(
            self.version_dirs, 'paginators-1.json')

        self.json_model = {}
        self.nested_json_model = {}
        self._setup_models()
        self.build_models()
        self.events = HierarchicalEmitter()
        self.setup_client()
        self.doc_name = 'MyDoc'
        self.doc_structure = DocumentStructure(self.doc_name)
开发者ID:freimer,项目名称:botocore,代码行数:19,代码来源:__init__.py

示例10: BaseDocsTest

class BaseDocsTest(unittest.TestCase):
    def setUp(self):
        self.root_dir = tempfile.mkdtemp()
        self.version_dirs = os.path.join(
            self.root_dir, 'myservice', '2014-01-01')
        os.makedirs(self.version_dirs)

        self.model_file = os.path.join(self.version_dirs, 'service-2.json')
        self.waiter_model_file = os.path.join(
            self.version_dirs, 'waiters-2.json')
        self.paginator_model_file = os.path.join(
            self.version_dirs, 'paginators-1.json')
        self.resource_model_file = os.path.join(
            self.version_dirs, 'resources-1.json')

        self.json_model = {}
        self.waiter_json_model = {}
        self.paginator_json_model = {}
        self.resource_json_model = {}
        self._setup_models()
        self._write_models()

        self.doc_name = 'MyDoc'
        self.doc_structure = DocumentStructure(self.doc_name)

        self.loader = Loader(extra_search_paths=[self.root_dir])
        self.botocore_session = botocore.session.get_session()
        self.botocore_session.register_component('data_loader', self.loader)
        self.session = Session(botocore_session=self.botocore_session)
        self.client = self.session.client('myservice', 'us-east-1')
        self.resource = self.session.resource('myservice', 'us-east-1')

    def tearDown(self):
        shutil.rmtree(self.root_dir)

    def _setup_models(self):
        self.json_model = {
            'metadata': {
                'apiVersion': '2014-01-01',
                'endpointPrefix': 'myservice',
                'signatureVersion': 'v4',
                'serviceFullName': 'AWS MyService',
                'protocol': 'query'
            },
            'operations': {
                'SampleOperation': {
                    'name': 'SampleOperation',
                    'input': {'shape': 'SampleOperationInputOutput'},
                    'output': {'shape': 'SampleOperationInputOutput'}
                }
            },
            'shapes': {
                'SampleOperationInputOutput': {
                    'type': 'structure',
                    'members': OrderedDict([
                        ('Foo', {
                            'shape': 'String',
                            'documentation': 'Documents Foo'}),
                        ('Bar', {
                            'shape': 'String',
                            'documentation': 'Documents Bar'}),
                    ])
                },
                'String': {
                    'type': 'string'
                }
            }
        }

        self.waiter_json_model = {
            "version": 2,
            "waiters": {
                "SampleOperationComplete": {
                    "delay": 15,
                    "operation": "SampleOperation",
                    "maxAttempts": 40,
                    "acceptors": [
                        {"expected": "complete",
                         "matcher": "pathAll",
                         "state": "success",
                         "argument": "Biz"},
                        {"expected": "failed",
                         "matcher": "pathAny",
                         "state": "failure",
                         "argument": "Biz"}
                    ]
                }
            }
        }

        self.paginator_json_model = {
            "pagination": {
                "SampleOperation": {
                    "input_token": "NextResult",
                    "output_token": "NextResult",
                    "limit_key": "MaxResults",
                    "result_key": "Biz"
                }
            }
        }
#.........这里部分代码省略.........
开发者ID:jonathanwcrane,项目名称:boto3,代码行数:101,代码来源:__init__.py

示例11: BaseDocsTest

class BaseDocsTest(unittest.TestCase):
    def setUp(self):
        self.root_dir = tempfile.mkdtemp()
        self.version_dirs = os.path.join(self.root_dir, "myservice", "2014-01-01")
        os.makedirs(self.version_dirs)

        self.model_file = os.path.join(self.version_dirs, "service-2.json")
        self.waiter_model_file = os.path.join(self.version_dirs, "waiters-2.json")
        self.paginator_model_file = os.path.join(self.version_dirs, "paginators-1.json")
        self.resource_model_file = os.path.join(self.version_dirs, "resources-1.json")

        self.json_model = {}
        self.waiter_json_model = {}
        self.paginator_json_model = {}
        self.resource_json_model = {}
        self._setup_models()
        self._write_models()

        self.doc_name = "MyDoc"
        self.doc_structure = DocumentStructure(self.doc_name)

        self.loader = Loader(extra_search_paths=[self.root_dir])
        self.botocore_session = botocore.session.get_session()
        self.botocore_session.register_component("data_loader", self.loader)
        self.session = Session(botocore_session=self.botocore_session, region_name="us-east-1")
        self.client = self.session.client("myservice", "us-east-1")
        self.resource = self.session.resource("myservice", "us-east-1")

    def tearDown(self):
        shutil.rmtree(self.root_dir)

    def _setup_models(self):
        self.json_model = {
            "metadata": {
                "apiVersion": "2014-01-01",
                "endpointPrefix": "myservice",
                "signatureVersion": "v4",
                "serviceFullName": "AWS MyService",
                "protocol": "query",
            },
            "operations": {
                "SampleOperation": {
                    "name": "SampleOperation",
                    "input": {"shape": "SampleOperationInputOutput"},
                    "output": {"shape": "SampleOperationInputOutput"},
                }
            },
            "shapes": {
                "SampleOperationInputOutput": {
                    "type": "structure",
                    "members": OrderedDict(
                        [
                            ("Foo", {"shape": "String", "documentation": "Documents Foo"}),
                            ("Bar", {"shape": "String", "documentation": "Documents Bar"}),
                        ]
                    ),
                },
                "String": {"type": "string"},
            },
        }

        self.waiter_json_model = {
            "version": 2,
            "waiters": {
                "SampleOperationComplete": {
                    "delay": 15,
                    "operation": "SampleOperation",
                    "maxAttempts": 40,
                    "acceptors": [
                        {"expected": "complete", "matcher": "pathAll", "state": "success", "argument": "Biz"},
                        {"expected": "failed", "matcher": "pathAny", "state": "failure", "argument": "Biz"},
                    ],
                }
            },
        }

        self.paginator_json_model = {
            "pagination": {
                "SampleOperation": {
                    "input_token": "NextResult",
                    "output_token": "NextResult",
                    "limit_key": "MaxResults",
                    "result_key": "Biz",
                }
            }
        }

        self.resource_json_model = {
            "service": {
                "actions": OrderedDict(
                    [
                        ("SampleOperation", {"request": {"operation": "SampleOperation"}}),
                        (
                            "SampleListReturnOperation",
                            {
                                "request": {"operation": "SampleOperation"},
                                "resource": {
                                    "type": "Sample",
                                    "identifiers": [{"target": "Name", "source": "response", "path": "Samples[].Name"}],
                                    "path": "Samples[]",
#.........这里部分代码省略.........
开发者ID:thedrow,项目名称:boto3,代码行数:101,代码来源:__init__.py

示例12: setUp

 def setUp(self):
     self.name = 'mydoc'
     self.doc_structure = DocumentStructure(self.name)
开发者ID:boto,项目名称:botocore,代码行数:3,代码来源:test_document.py

示例13: TestDocumentStructure

class TestDocumentStructure(unittest.TestCase):
    def setUp(self):
        self.name = 'mydoc'
        self.doc_structure = DocumentStructure(self.name)

    def test_name(self):
        self.assertEqual(self.doc_structure.name, self.name)

    def test_path(self):
        self.assertEqual(self.doc_structure.path, [self.name])
        self.doc_structure.path = ['foo']
        self.assertEqual(self.doc_structure.path, ['foo'])

    def test_add_new_section(self):
        section = self.doc_structure.add_new_section('mysection')

        # Ensure the name of the section is correct
        self.assertEqual(section.name, 'mysection')

        # Ensure we can get the section.
        self.assertEqual(
            self.doc_structure.get_section('mysection'), section)

        # Ensure the path is correct
        self.assertEqual(section.path, ['mydoc', 'mysection'])

        # Ensure some of the necessary attributes are passed to the
        # the section.
        self.assertEqual(section.style.indentation,
                         self.doc_structure.style.indentation)
        self.assertEqual(section.translation_map,
                         self.doc_structure.translation_map)
        self.assertEqual(section.hrefs,
                         self.doc_structure.hrefs)

    def test_delete_section(self):
        section = self.doc_structure.add_new_section('mysection')
        self.assertEqual(
            self.doc_structure.get_section('mysection'), section)
        self.doc_structure.delete_section('mysection')
        with self.assertRaises(KeyError):
            section.get_section('mysection')

    def test_create_sections_at_instantiation(self):
        sections = ['intro', 'middle', 'end']
        self.doc_structure = DocumentStructure(
            self.name, section_names=sections)
        # Ensure the sections are attached to the new document structure.
        for section_name in sections:
            section = self.doc_structure.get_section(section_name)
            self.assertEqual(section.name, section_name)

    def test_flush_structure(self):
        section = self.doc_structure.add_new_section('mysection')
        subsection = section.add_new_section('mysubsection')
        self.doc_structure.writeln('1')
        section.writeln('2')
        subsection.writeln('3')
        second_section = self.doc_structure.add_new_section('mysection2')
        second_section.writeln('4')
        contents = self.doc_structure.flush_structure()

        # Ensure the contents were flushed out correctly
        self.assertEqual(contents, six.b('1\n2\n3\n4\n'))

    def test_flush_structure_hrefs(self):
        section = self.doc_structure.add_new_section('mysection')
        section.writeln('section contents')
        self.doc_structure.hrefs['foo'] = 'www.foo.com'
        section.hrefs['bar'] = 'www.bar.com'
        contents = self.doc_structure.flush_structure()
        self.assertIn(six.b('.. _foo: www.foo.com'), contents)
        self.assertIn(six.b('.. _bar: www.bar.com'), contents)

    def test_available_sections(self):
        self.doc_structure.add_new_section('mysection')
        self.doc_structure.add_new_section('mysection2')
        self.assertEqual(
            self.doc_structure.available_sections,
            ['mysection', 'mysection2']
        )

    def test_context(self):
        context = {'Foo': 'Bar'}
        section = self.doc_structure.add_new_section(
            'mysection', context=context)
        self.assertEqual(section.context, context)

        # Make sure if context is not specified it is empty.
        section = self.doc_structure.add_new_section('mysection2')
        self.assertEqual(section.context, {})

    def test_remove_all_sections(self):
        self.doc_structure.add_new_section('mysection2')
        self.doc_structure.remove_all_sections()
        self.assertEqual(self.doc_structure.available_sections, [])

    def test_clear_text(self):
        self.doc_structure.write('Foo')
        self.doc_structure.clear_text()
#.........这里部分代码省略.........
开发者ID:boto,项目名称:botocore,代码行数:101,代码来源:test_document.py

示例14: TestParameterAlias

class TestParameterAlias(unittest.TestCase):
    def setUp(self):
        self.original_name = 'original'
        self.alias_name = 'alias'
        self.parameter_alias = handlers.ParameterAlias(
            self.original_name, self.alias_name)

        self.operation_model = mock.Mock()
        request_shape = DenormalizedStructureBuilder().with_members(
            {self.original_name: {'type': 'string'}}).build_model()
        self.operation_model.input_shape = request_shape
        self.sample_section = DocumentStructure('')
        self.event_emitter = HierarchicalEmitter()

    def test_alias_parameter_in_call(self):
        value = 'value'
        params = {self.alias_name: value}
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.original_name: value})

    def test_alias_parameter_and_original_in_call(self):
        params = {
            self.original_name: 'orginal_value',
            self.alias_name: 'alias_value'
        }
        with self.assertRaises(AliasConflictParameterError):
            self.parameter_alias.alias_parameter_in_call(
                params, self.operation_model)

    def test_alias_parameter_in_call_does_not_touch_original(self):
        value = 'value'
        params = {self.original_name: value}
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.original_name: value})

    def test_does_not_alias_parameter_for_no_input_shape(self):
        value = 'value'
        params = {self.alias_name: value}
        self.operation_model.input_shape = None
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.alias_name: value})

    def test_does_not_alias_parameter_for_not_modeled_member(self):
        value = 'value'
        params = {self.alias_name: value}

        request_shape = DenormalizedStructureBuilder().with_members(
            {'foo': {'type': 'string'}}).build_model()
        self.operation_model.input_shape = request_shape
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.alias_name: value})

    def test_alias_parameter_in_documentation_request_params(self):
        RequestParamsDocumenter(
            'myservice', 'myoperation', self.event_emitter).document_params(
                self.sample_section, self.operation_model.input_shape)
        self.parameter_alias.alias_parameter_in_documentation(
            'docs.request-params.myservice.myoperation.complete-section',
            self.sample_section
        )
        contents = self.sample_section.flush_structure().decode('utf-8')
        self.assertIn(':type ' + self.alias_name + ':',  contents)
        self.assertIn(':param ' + self.alias_name + ':',  contents)
        self.assertNotIn(':type ' + self.original_name + ':',  contents)
        self.assertNotIn(':param ' + self.original_name + ':',  contents)

    def test_alias_parameter_in_documentation_request_example(self):
        RequestExampleDocumenter(
            'myservice', 'myoperation', self.event_emitter).document_example(
                self.sample_section, self.operation_model.input_shape)
        self.parameter_alias.alias_parameter_in_documentation(
            'docs.request-example.myservice.myoperation.complete-section',
            self.sample_section
        )
        contents = self.sample_section.flush_structure().decode('utf-8')
        self.assertIn(self.alias_name + '=',  contents)
        self.assertNotIn(self.original_name + '=', contents)
开发者ID:kyleknap,项目名称:botocore,代码行数:81,代码来源:test_handlers.py

示例15: _create_docstring

 def _create_docstring(self):
     docstring_structure = DocumentStructure("docstring")
     # Call the document method function with the args and kwargs
     # passed to the class.
     document_model_driven_method(docstring_structure, *self._gen_args, **self._gen_kwargs)
     return docstring_structure.flush_structure().decode("utf-8")
开发者ID:kkung,项目名称:botocore,代码行数:6,代码来源:method.py


注:本文中的botocore.docs.bcdoc.restdoc.DocumentStructure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。