Exemple #1
0
    def _build_docs_blob(self):
        """Build importer result docs_blob from collection documentation."""
        contents = [
            schema.DocsBlobContentItem(
                content_name=c.name,
                content_type=c.content_type.value,
                doc_strings=c.doc_strings,
                readme_file=c.readme_file,
                readme_html=c.readme_html,
            ) for c in self.content_objs
        ]

        readme = markup_utils.get_readme_doc_file(self.path)
        if not readme:
            raise exc.ImporterError('No collection readme found')
        rendered_readme = schema.RenderedDocFile(
            name=readme.name, html=markup_utils.get_html(readme))

        rendered_doc_files = []
        doc_files = markup_utils.get_doc_files(
            os.path.join(self.path, DOCUMENTATION_DIR))
        if doc_files:
            rendered_doc_files = [
                schema.RenderedDocFile(name=f.name,
                                       html=markup_utils.get_html(f))
                for f in doc_files
            ]

        return schema.DocsBlob(
            collection_readme=rendered_readme,
            documentation_files=rendered_doc_files,
            contents=contents,
        )
Exemple #2
0
    def test_get_doc_files(self):
        res = markup_utils.get_doc_files(self.directory)
        assert res is None

        for doc_file in [
                "GETTING_STARTED.md",
                "DEEP_DIVE.md",
                "WHOOPS.txt",
                "EXAMPLES.md",
        ]:
            self.fs.create_file(os.path.join(self.directory, doc_file))

        self.fs.create_dir(os.path.join(self.directory, "sub_dir_to_ignore"))
        res = markup_utils.get_doc_files(self.directory)
        assert len(res) == 3
        names = [d.name for d in res]
        assert "GETTING_STARTED.md" in names
        assert "DEEP_DIVE.md" in names
        assert "EXAMPLES.md" in names
        assert "WHOOPS.txt" not in names
    def test_get_doc_files(self):
        res = markup_utils.get_doc_files(self.directory)
        assert res is None

        for doc_file in [
            'GETTING_STARTED.md',
            'DEEP_DIVE.md',
            'WHOOPS.txt',
            'EXAMPLES.md',
        ]:
            self.fs.create_file(os.path.join(self.directory, doc_file))

        self.fs.create_dir(os.path.join(self.directory, 'sub_dir_to_ignore'))
        res = markup_utils.get_doc_files(self.directory)
        assert len(res) == 3
        names = [d.name for d in res]
        assert 'GETTING_STARTED.md' in names
        assert 'DEEP_DIVE.md' in names
        assert 'EXAMPLES.md' in names
        assert 'WHOOPS.txt' not in names
    def _build_docs_blob(self):
        """Build importer result docs_blob from collection documentation."""

        # return an empty DocsBlob if run_ansible_doc=False
        rendered_readme = schema.RenderedDocFile()
        docs_blob = schema.DocsBlob(
            collection_readme=rendered_readme,
            documentation_files=[],
            contents=[],
        )

        if not self.cfg.run_ansible_doc:
            return docs_blob

        contents = [
            schema.DocsBlobContentItem(
                content_name=c.name,
                content_type=c.content_type.value,
                doc_strings=c.doc_strings,
                readme_file=c.readme_file,
                readme_html=c.readme_html,
            ) for c in self.content_objs
        ]

        readme = markup_utils.get_readme_doc_file(self.path)
        if not readme:
            raise exc.ImporterError('No collection readme found')
        rendered_readme = schema.RenderedDocFile(
            name=readme.name, html=markup_utils.get_html(readme))

        rendered_doc_files = []
        doc_files = markup_utils.get_doc_files(
            os.path.join(self.path, DOCUMENTATION_DIR))
        if doc_files:
            rendered_doc_files = [
                schema.RenderedDocFile(name=f.name,
                                       html=markup_utils.get_html(f))
                for f in doc_files
            ]

        execution_environment = ee_utils.process_execution_environment(
            self.path, self.log)

        return schema.DocsBlob(
            collection_readme=rendered_readme,
            documentation_files=rendered_doc_files,
            contents=contents,
            execution_environment=execution_environment,
        )