Exemple #1
0
    def test_render_markdown_undocumented(self):
        args = main.parse_args(
            ['render', 'examples/api.json', '--name=SERVICE'])
        with contextlib.closing(args.metadata):
            m = self.metadata()
            m['group']['apis']['api2']['undocumented'] = True
            iterator = main.render_markdown(m, args)
            output = OrderedDict((str(k), v) for k, v in iterator)

            self.assertEqual(
                set([
                    'en/group.md',
                    'en/index.md',
                    'en/metadata.yaml',
                    'metadata.yaml',
                ]),
                set(output),
            )

            self.assertNotIn('api2', output['en/group.md'])

            md = yaml.safe_load(output['en/metadata.yaml'])
            self.assertEqual(
                {
                    'navigation': [
                        {
                            'location': 'index.md',
                            'title': 'Index'
                        },
                        {
                            'location': 'group.md',
                            'title': 'Group'
                        },
                    ],
                }, md)
Exemple #2
0
    def test_render_markdown_deprecated_at(self):
        args = main.parse_args(
            ['render', 'examples/api.json', '--name=SERVICE'])
        m = self.metadata()
        m['group']['apis']['api2']['deprecated_at'] = 2
        iterator = main.render_markdown(m, args)
        output = OrderedDict((str(k), v) for k, v in iterator)

        self.assertEqual(
            set([
                'en/group.md',
                'en/index.md',
                'en/metadata.yaml',
                'metadata.yaml',
            ]),
            set(output),
        )

        md = yaml.safe_load(output['en/metadata.yaml'])
        self.assertEqual(
            {
                'navigation': [
                    {
                        'location': 'index.md',
                        'title': 'Index'
                    },
                    {
                        'location': 'group.md',
                        'title': 'Group'
                    },
                ],
            }, md)
    def test_render_markdown_undocumented(self):
        m = self.metadata()
        m['api2']['undocumented'] = True
        iterator = main.render_markdown(m, 'SERVICE')
        output = OrderedDict((str(k), v) for k, v in iterator)

        self.assertEqual(
            set([
                'en/api1.md',
                'en/index.md',
                'en/metadata.yaml',
                'metadata.yaml',
            ]),
            set(output),
        )

        md = yaml.safe_load(output['en/metadata.yaml'])
        self.assertEqual(
            {
                'navigation': [
                    {
                        'location': 'index.md',
                        'title': 'Index'
                    },
                    {
                        'location': 'api1.md',
                        'title': 'api1'
                    },
                ],
            }, md)
Exemple #4
0
    def test_render_markdown_multiple_groups(self):
        args = main.parse_args(
            ['render', 'examples/api.json', '--name=SERVICE'])
        with contextlib.closing(args.metadata):
            metadata = self.metadata()
            metadata['group2'] = {
                'apis': {
                    'api2': metadata['group']['apis'].pop('api2')
                }
            }
            iterator = main.render_markdown(metadata, args)
            output = OrderedDict((str(k), v) for k, v in iterator)

            self.assertEqual(
                set([
                    'en/group.md',
                    'en/group2.md',
                    'en/index.md',
                    'en/metadata.yaml',
                    'metadata.yaml',
                ]),
                set(output),
            )

            top_level_md = yaml.safe_load(output['metadata.yaml'])
            self.assertEqual(
                {'site_title': 'SERVICE Documentation: version 2'},
                top_level_md,
            )

            md = yaml.safe_load(output['en/metadata.yaml'])
            self.assertEqual(
                {
                    'navigation': [
                        {
                            'location': 'index.md',
                            'title': 'Index'
                        },
                        {
                            'location': 'group.md',
                            'title': 'Group'
                        },
                        {
                            'location': 'group2.md',
                            'title': 'Group2'
                        },
                    ],
                }, md)
    def test_render_markdown_multiple_groups(self):
        metadata = self.metadata()
        metadata['api2']['api_group'] = 'group'
        iterator = main.render_markdown(metadata, 'SERVICE')
        output = OrderedDict((str(k), v) for k, v in iterator)

        self.assertEqual(
            set([
                'en/api1.md',
                'en/api2.md',
                'en/index.md',
                'en/metadata.yaml',
                'metadata.yaml',
            ]),
            set(output),
        )

        top_level_md = yaml.safe_load(output['metadata.yaml'])
        self.assertEqual(
            {'site_title': 'SERVICE Documentation: version 1'},
            top_level_md,
        )

        md = yaml.safe_load(output['en/metadata.yaml'])
        self.assertEqual(
            {
                'navigation': [{
                    'location': 'index.md',
                    'title': 'Index'
                }, {
                    'location': 'api1.md',
                    'title': 'api1'
                }, {
                    'title':
                    'group',
                    'children': [{
                        'location': 'api2.md',
                        'title': 'api2'
                    }]
                }],
            }, md)
    def test_render_markdown_success(self):
        iterator = main.render_markdown(self.metadata(), 'SERVICE')
        output = OrderedDict((str(k), v) for k, v in iterator)

        self.assertEqual(
            set([
                'en/api1.md',
                'en/api2.md',
                'en/index.md',
                'en/metadata.yaml',
                'metadata.yaml',
            ]),
            set(output),
        )

        top_level_md = yaml.safe_load(output['metadata.yaml'])
        self.assertEqual(
            {'site_title': 'SERVICE Documentation: version 1'},
            top_level_md,
        )

        md = yaml.safe_load(output['en/metadata.yaml'])
        self.assertEqual(
            {
                'navigation': [
                    {
                        'location': 'index.md',
                        'title': 'Index'
                    },
                    {
                        'location': 'api1.md',
                        'title': 'api1'
                    },
                    {
                        'location': 'api2.md',
                        'title': 'api2'
                    },
                ],
            }, md)
Exemple #7
0
    def test_render_markdown_success(self):
        args = main.parse_args(
            ['render', 'examples/api.json', '--name=SERVICE'])

        iterator = main.render_markdown(self.metadata(), args)
        output = OrderedDict((str(k), v) for k, v in iterator)

        self.assertEqual(
            set([
                'en/group.md',
                'en/index.md',
                'en/metadata.yaml',
                'metadata.yaml',
            ]),
            set(output),
        )

        top_level_md = yaml.safe_load(output['metadata.yaml'])
        self.assertEqual(
            {'site_title': 'SERVICE Documentation: version 2'},
            top_level_md,
        )

        md = yaml.safe_load(output['en/metadata.yaml'])
        self.assertEqual(
            {
                'navigation': [
                    {
                        'location': 'index.md',
                        'title': 'Index'
                    },
                    {
                        'location': 'group.md',
                        'title': 'Group'
                    },
                ],
            }, md)