Ejemplo n.º 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,
        )
Ejemplo n.º 2
0
    def test_get_html(self):
        doc_file = DocFile(text=TEXT_SIMPLE, mimetype='text/markdown')
        html = markup_utils.get_html(doc_file)
        assert html == '<p>{}</p>'.format(TEXT_SIMPLE)

        doc_file = DocFile(text=TEXT_SIMPLE, mimetype='text/rst')
        html = markup_utils.get_html(doc_file)
        assert html is None
Ejemplo n.º 3
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.º 4
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.º 5
0
    def load(self):
        self._log_loading()
        description = self._get_metadata_description()
        readme = self._get_readme()
        for line in self._lint_role(self.rel_path):
            self.log.warning(line)

        return schema.Content(
            name=self.path_name,
            content_type=self.content_type,
            description=description,
            readme_file=readme.name,
            readme_html=markup_utils.get_html(readme),
        )
Ejemplo n.º 6
0
    def load(self):
        self._log_loading()
        description = self._get_metadata_description()
        readme = self._get_readme()

        if self.cfg.run_ansible_lint:
            self._lint_role(self.rel_path)

        return schema.Content(
            name=self.path_name,
            content_type=self.content_type,
            description=description,
            readme_file=readme.name,
            readme_html=markup_utils.get_html(readme),
        )