How to use the atelier.rstgen.header function in atelier

To help you get started, we’ve selected a few atelier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lino-framework / lino / lino / utils / html2rst.py View on Github external
rst += '*'
    elif e.tag == 'a':
        rst += '`'

    if e.text:
        rst += e.text
    for child in e:
        rst += html2rst(child, stripped)

    if e.tag in NEWLINE_TAGS:
        if stripped:
            rst += '\n'
        else:
            rst += '\n\n'
    elif e.tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'):
        rst = rstgen.header(int(e.tag[1]), rst.strip()).strip()
        if stripped:
            rst += '\n'
        else:
            rst = '\n\n' + rst + '\n\n'
    elif e.tag == 'b':
        if rst == '**':
            rst = ''
        else:
            rst += '**'
    elif e.tag == 'em' or e.tag == 'i':
        if rst == '*':
            rst = ''
        else:
            rst += '*'
    elif e.tag == 'a':
        rst += ' <%s>`__' % e.get('href')
github lino-framework / lino / lino / core / renderer.py View on Github external
fields, headers, widths = ar.get_field_info(column_names)

        sums = [fld.zero for fld in fields]
        rows = []
        recno = 0
        for row in ar.sliced_data_iterator:
            recno += 1
            if show_links:
                rows.append([
                    to_rst(x) for x in ar.row2html(
                        recno, fields, row, sums)])
            else:
                rows.append([x for x in ar.row2text(fields, row, sums)])

        if header_level is not None:
            h = rstgen.header(header_level, ar.get_title())
            if stripped:
                h = h.strip()
            yield h
            # s = h + "\n" + s
            # s = tostring(E.h2(ar.get_title())) + s

        if len(rows) == 0:
            s = str(ar.no_data_text)
            if not stripped:
                s = "\n" + s + "\n"
            yield s
            return

        if not ar.actor.hide_sums:
            has_sum = False
            for i in sums:
github lino-framework / lino / lino / api / selenium.py View on Github external
def write_index(self):
        index = self.screenshot_root.child('index.rst')
        if self.ref:
            content = ".. _{0}:\n\n".format(self.ref)
        else:
            content = ""
        content += rstgen.header(1, self.title)
        content += "\n\n\n"
        if self.intro:
            content += unindent(self.intro)
            content += "\n\n\n"

        for name, caption, before, after in self.screenshots:
            content += "\n\n"
            content += rstgen.header(2, caption)
            content += """

{before}

.. image:: {name}
    :alt: {caption}
    :width: 500
github lino-framework / lino / lino / sphinxcontrib / actordoc.py View on Github external
#~ from actordoc import get_actor_description
        #~ from django.conf import settings
        #~ from djangosite.dbutils import set_language
        with translation.override(self.language):
            level, cls = resolve_name(self.content[0])
            if isinstance(cls, models.Field):
                fld = cls
                s = ''
                name = str(fld.model) + '.' + fld.name
                title = force_text(fld.verbose_name).strip()
                
                s += "\n.. index::\n   single: "
                s += str(_('%(field)s (field in %(model)s)') % dict(
                    field=title, model=model_ref(fld.model)))
                s += '\n\n'
                s += rstgen.header(level, _("%s (field)") % title)
                if len(self.content) > 1:
                    s += '\n'.join(self.content[1:])
                    s += '\n\n'
                return s

            if isinstance(cls, Plugin):
                s = ''
                title = str(cls.verbose_name)
                s += "\n.. index::\n   single: "
                s += str(_('%s (app)') % title)
                s += '\n\n.. _' + name + ':\n'
                s += '\n'
                s += rstgen.header(level, _("%s (app)") % title)
                return s

            if not isinstance(cls, type):
github lino-framework / lino / lino / sphinxcontrib / actordoc.py View on Github external
if issubclass(cls, models.Model):
                model = cls

                s = ''
                name = model_name(model).lower()
                title = force_text(model._meta.verbose_name)
                s += "\n.. index::\n   single: "
                s += str(_('%(model)s (model in %(app)s)') % dict(
                    model=title, app=model._meta.app_label))

                s += '\n\n'

                s += '\n\n.. _' + name + ':\n'

                s += '\n'
                s += rstgen.header(level, _("%s (model)") % title)

                s += '\n'
                s += '\n:Internal name: ``%s``\n' % full_model_name(cls)
                s += '\n:Implemented by: %s\n' % typeref(cls)
                s += '\n'

                if len(self.content) > 1:
                    s += '\n'.join(self.content[1:])
                    s += '\n\n'

                model_reports = [
                    r for r in kernel.master_tables if r.model is cls]
                model_reports += [r for r in kernel.slave_tables
                                  if r.model is cls]
                s += rstgen.boldheader(_("Views on %s") %
                                       cls._meta.verbose_name)