Ejemplo n.º 1
0
    def test_get_readme_doc_file(self):
        res = markup_utils.get_readme_doc_file(self.directory)
        assert res is None

        file_path = os.path.join(self.directory, 'README.md')
        self.fs.create_file(file_path, contents='## My Collection')
        res = markup_utils.get_readme_doc_file(self.directory)
        assert res.name == 'README.md'
        assert res.text == '## My Collection'
Ejemplo n.º 2
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,
        )
Ejemplo n.º 3
0
 def _get_readme(self):
     self.log.info('Getting role readme')
     readme = markup_utils.get_readme_doc_file(
         os.path.join(self.root, self.rel_path))
     if not readme:
         raise exc.ContentLoadError('No role readme found.')
     self.readme_file = readme.name
     self.readme_html = markup_utils.get_html(readme)
Ejemplo n.º 4
0
    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,
        )
Ejemplo n.º 5
0
 def _get_readme(self):
     readme = markup_utils.get_readme_doc_file(
         os.path.join(self.root, self.rel_path))
     if not readme:
         raise exc.ContentLoadError('No role readme found.')
     return readme