Render and display Python package documentation.
480976
def run(self):
        
        os.environ['JARN_RUN'] = '1'
        self.python.check_valid_python()

        args = self.parse_options(self.args)
        if args:
            arg = args[0]
        else:
            arg = os.curdir
        if arg:
            arg = expanduser(arg)

        if isfile(arg):
            outfile = self.render_file(arg)
        elif isdir(arg):
            outfile = self.render_long_description(arg)
        else:
            err_exit('No such file or directory: %s' % arg)

        self.open_in_browser(outfile)
771596
def render_compressed_output(self, package, package_name, package_type):
        
        method = getattr(self, 'render_{0}'.format(package_type))

        return method(package, package.output_filename)
217502
def description(filename):
    """"""
    # This ends up in the Summary header for PKG-INFO and it should be a
    # one-liner.  It will get rendered on the package page just below the
    # package version header but above the long_description, which ironically
    # gets stuff into the Description header.  It should not include reST, so
    # pick out the first single line after the double header.
    with open(filename) as fp:
        for lineno, line in enumerate(fp):
            if lineno < 3:
                continue
            line = line.strip()
            if len(line) > 0:
                return line
597836
def render_summary(self, include_title=True, request=None):
        """"""
        title = ''
        frames = []
        classes = ['traceback']
        if not self.frames:
            classes.append('noframe-traceback')

        if include_title:
            if self.is_syntax_error:
                title = text_('Syntax Error')
            else:
                title = text_('Traceback <small>(most recent call last)'
                              '</small>')

        for frame in self.frames:
            frames.append(
                text_('<li%s>%s') % (
                    frame.info and text_(' title="%s"' % escape(frame.info)) or
                    text_(''),
                    frame.render()
                ))

        if self.is_syntax_error:
            description_wrapper = text_('<pre class=syntaxerror>%s</pre>')
        else:
            description_wrapper = text_('<blockquote>%s</blockquote>')

        vars = {
            'classes': text_(' '.join(classes)),
            'title': title and text_('<h3 class="traceback">%s</h3>'
                                     % title) or text_(''),
            'frames': text_('\n'.join(frames)),
            'description': description_wrapper % escape(self.exception),
        }
        app = request.app
        template = app.ps.jinja2.env.get_template('debugtoolbar/exception_summary.html')
        return template.render(app=app, request=request, **vars)
366492
def docs(output=DOC_OUTPUT, proj_settings=PROJ_SETTINGS, github=False):
    

    local("export PYTHONPATH='' && "
          "export DJANGO_SETTINGS_MODULE=%s && "
          "sphinx-build -b html %s %s" % (proj_settings, DOC_INPUT, output),
          capture=False)

    if _parse_bool(github):
        local("touch %s/.nojekyll" % output, capture=False)
319619
def _render_content(self):
        """"""
        if self.content_format == "rst" and docutils_publish is not None:
            doc_parts = docutils_publish(
                source=self.raw_content,
                writer_name="html4css1"
            )
            self.rendered_content = doc_parts['fragment']
        elif self.content_format == "rs" and docutils_publish is None:
            raise RuntimeError("Install docutils to pubilsh reStructuredText")
        elif self.content_format == "md" and markdown is not None:
            self.rendered_content = markdown(self.raw_content)
        elif self.content_format == "md" and markdown is None:
            raise RuntimeError("Install Markdown to pubilsh markdown")
        else:  # Assume we've got html
            self.rendered_content = self.raw_content
787433
def render(obj):
    """"""
    def get_v(v):
        return v % env if isinstance(v, basestring) else v

    if isinstance(obj, types.StringType):
        return obj % env
    elif isinstance(obj, types.TupleType) or isinstance(obj, types.ListType):
        rv = []
        for v in obj:
            rv.append(get_v(v))
    elif isinstance(obj, types.DictType):
        rv = {}
        for k, v in obj.items():
            rv[k] = get_v(v)

    return rv
595306
def render(self):
        
        release_notes = []
        for parser in self.parsers:
            parser_content = parser.render()
            if parser_content is not None:
                release_notes.append(parser_content)
        return u"\r\n\r\n".join(release_notes)
1365952
def main():
    """"""

    # Parse command line arguments
    argp = _cli_argument_parser()
    args = argp.parse_args()

    # setup logging
    logging.basicConfig(
        level=args.loglevel,
        format="%(levelname)s %(message)s")

    console.display("Collecting documentation from files")
    collector_metrics = metrics.Metrics()
    docs = collector.parse(args.path, args.trace_parser,
                           metrics=collector_metrics)
    collector_metrics.display()

    console.display("Rendering documentation")

    try:
        if args.output:
            template = renderer.template_from_filename(args.output)
        else:
            template = "json"
        out = renderer.render(docs, template)
    except ValueError as err:
        logging.error(err)
        sys.exit(1)
    except TemplateNotFound as err:
        logging.error(
            "Template `{}` not found. Available templates are: {}".format(
                err.name, renderer.list_templates()))
        sys.exit(1)

    if not args.output:
        print(out)
    else:
        console.display("Writing documentation to", args.output)
        with io.open(args.output, "w", encoding="utf-8") as fp:
            fp.write(out)
966221
def view(self):
        
        print("")   # new line at start
        description, count = "", 0
        if self.repo == "sbo":
            description = SBoGrep(self.name).description()
        else:
            PACKAGES_TXT = Utils().read_file(self.lib)
            for line in PACKAGES_TXT.splitlines():
                if line.startswith(self.name + ":"):
                    description += line[len(self.name) + 2:] + "\n"
                    count += 1
                    if count == 11:
                        break
        if description:
            print("{0}{1}{2}".format(self.COLOR, description,
                                     self.meta.color["ENDC"]))
        else:
            self.msg.pkg_not_found("", self.name, "No matching", "\n")
            raise SystemExit(1)
        if description and self.repo == "sbo":
            print("")
278025
def render(self, doc, context=None, math_option=False, img_path='',
               css_path=CSS_PATH):
        """"""
        # If the thread is already running wait for it to finish before
        # starting it again.
        if self.wait():
            self.doc = doc
            self.context = context
            self.math_option = math_option
            self.img_path = img_path
            self.css_path = css_path
            # This causes run() to be executed in separate thread
            self.start()
436246
def render_output_pydot(self, dotdata, **kwargs):
        """"""
        if not HAS_PYDOT:
            raise CommandError("You need to install pydot python module")

        graph = pydot.graph_from_dot_data(dotdata)
        if not graph:
            raise CommandError("pydot returned an error")
        if isinstance(graph, (list, tuple)):
            if len(graph) > 1:
                sys.stderr.write("Found more then one graph, rendering only the first one.\n")
            graph = graph[0]

        output_file = kwargs['outputfile']
        formats = [
            'bmp', 'canon', 'cmap', 'cmapx', 'cmapx_np', 'dot', 'dia', 'emf',
            'em', 'fplus', 'eps', 'fig', 'gd', 'gd2', 'gif', 'gv', 'imap',
            'imap_np', 'ismap', 'jpe', 'jpeg', 'jpg', 'metafile', 'pdf',
            'pic', 'plain', 'plain-ext', 'png', 'pov', 'ps', 'ps2', 'svg',
            'svgz', 'tif', 'tiff', 'tk', 'vml', 'vmlz', 'vrml', 'wbmp', 'xdot',
        ]
        ext = output_file[output_file.rfind('.') + 1:]
        format_ = ext if ext in formats else 'raw'
        graph.write(output_file, format=format_)
263283
def _render_html(self, libraries):
        """"""

        title = self.options.get("title", "Keyword Documentation")
        date = time.strftime("%A %B %d, %I:%M %p")
        cci_version = cumulusci.__version__

        stylesheet_path = os.path.join(os.path.dirname(__file__), "stylesheet.css")
        with open(stylesheet_path) as f:
            stylesheet = f.read()

        jinjaenv = jinja2.Environment(
            loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), autoescape=False
        )
        jinjaenv.filters["robot_html"] = robot.utils.html_format
        template = jinjaenv.get_template("template.html")
        return template.render(
            libraries=libraries,
            title=title,
            cci_version=cci_version,
            stylesheet=stylesheet,
            date=date,
        )
759218
def _generate_paragraphs(package, subpackages):
    """"""

    # API doc of each module.
    for subpackage in _iter_subpackages(package, subpackages):
        subpackage_name = subpackage.__name__

        yield "## {}".format(subpackage_name)

        # Subpackage documentation.
        yield _doc(_import_module(subpackage_name))

        # List of top-level functions in the subpackage.
        for func in _iter_functions(subpackage):
            yield '##### ' + _doc_function(subpackage, func)

        # All public classes.
        for klass in _iter_classes(subpackage):

            # Class documentation.
            yield "### {}".format(_full_name(subpackage, klass))
            yield _doc(klass)

            yield "#### Methods"
            for method in _iter_methods(klass, package):
                yield '##### ' + _doc_method(klass, method)

            yield "#### Properties"
            for prop in _iter_properties(klass, package):
                yield '##### ' + _doc_property(klass, prop)
52323
def show_info(self):
        """"""

        deltas = self.__get_delta_files()

        table = [['Version', 'Name', 'Type', 'Status']]

        for dir_ in deltas:
            print('delta files in dir: ', dir_)

            for delta in deltas[dir_]:
                line = [delta.get_version(), delta.get_name()]
                if delta.get_type() == DeltaType.PRE_PYTHON:
                    line.append('pre py')
                elif delta.get_type() == DeltaType.PRE_SQL:
                    line.append('pre sql')
                elif delta.get_type() == DeltaType.PYTHON:
                    line.append('delta py')
                elif delta.get_type() == DeltaType.SQL:
                    line.append('delta sql')
                elif delta.get_type() == DeltaType.POST_PYTHON:
                    line.append('post py')
                elif delta.get_type() == DeltaType.POST_SQL:
                    line.append('post sql')

                if self.__is_applied(delta):
                    line.append('Applied')
                else:
                    line.append('Pending')

                table.append(line)

        self.__print_table(table)

        print('')
        print('Applied upgrades in database')

        query = """SELECT
                version,
                description,
                type,
                installed_by,
                installed_on,
                success
                FROM {}
                """.format(self.upgrades_table)

        self.cursor.execute(query)
        records = self.cursor.fetchall()

        table = [['Version', 'Name', 'Type', 'Installed by', 'Installed on',
                  'Status']]

        for i in records:
            line = [str(i[0]), str(i[1])]
            delta_type = i[2]
            if delta_type == 0:
                line.append('baseline')
            elif delta_type == DeltaType.PRE_PYTHON:
                line.append('pre py')
            elif delta_type == DeltaType.PRE_SQL:
                line.append('pre sql')
            elif delta_type == DeltaType.PYTHON:
                line.append('delta py')
            elif delta_type == DeltaType.SQL:
                line.append('delta sql')
            elif delta_type == DeltaType.POST_PYTHON:
                line.append('post py')
            elif delta_type == DeltaType.POST_SQL:
                line.append('post sql')

            line.append(str(i[3]))
            line.append(str(i[4]))

            success = str(i[5])
            if success == 'True':
                line.append('Success')
            else:
                line.append('Failed')

            table.append(line)

        self.__print_table(table)
541414
def output_package(dist):
        """"""
        if dist_is_editable(dist):
            return '%s (%s, %s)' % (
                dist.project_name,
                dist.version,
                dist.location,
            )
        return '%s (%s)' % (dist.project_name, dist.version)
323852
def show_rich_text(self, text, collapse=False, img_path=''):
        """"""
        self.switch_to_plugin()
        self.switch_to_rich_text()
        context = generate_context(collapse=collapse, img_path=img_path,
                                   css_path=self.css_path)
        self.render_sphinx_doc(text, context)