What layout is appropriate for this document, if any
 rubocop:disable Metrics/PerceivedComplexity
771929
def layout_for(document)
      if index?(document) && layout_exists?("home")
        "home"
      elsif page?(document) && layout_exists?("page")
        "page"
      elsif post?(document) && layout_exists?("post")
        "post"
      elsif layout_exists?("default")
        "default"
      end
    end
653406
def format_issue(issue)
      t(config.format == 'one-line' ? 'issue.oneline' : 'issue.details',
        key: issue.key,
        summary: issue.summary,
        status: issue.status.name,
        assigned: optional_issue_property('unassigned') { issue.assignee.displayName },
        fixVersion: optional_issue_property('none') { issue.fixVersions.first['name'] },
        priority: optional_issue_property('none') { issue.priority.name },
        url: format_issue_link(issue.key))
    end
52985
function (cb, data, layout) {
            var self = this;
            var stack = new Y.Parallel();

            data.displayName = data.name;
            data.name = self.filterFileName(data.name);
            Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
                opts.meta = Y.merge(opts.meta, data);

                //opts.meta.htmlTitle = v.name + ': ' + self.data.project.name;
                opts.meta.title = self.data.project.name;

                opts.meta.moduleName = data.displayName || data.name;
                opts.meta.moduleDescription = self._parseCode(self.markdown(data.description || ' '));
                opts.meta.file = data.file;
                opts.meta.line = data.line;
                opts.meta = self.addFoundAt(opts.meta);
                opts.meta.projectRoot = '../';
                opts.meta.projectAssets = '../assets';
                opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);
                opts = self.populateClasses(opts);
                opts = self.populateModules(opts);
                opts = self.populateFiles(opts);

                if (data.classes && Object.keys(data.classes).length) {
                    opts.meta.moduleClasses = [];
                    Y.each(Object.keys(data.classes), function (name) {
                        var i = self.data.classes[name];
                        if (i) {
                            opts.meta.moduleClasses.push({
                                name: i.name,
                                displayName: i.name
                            });
                        }
                    });
                    opts.meta.moduleClasses.sort(self.nameSort);
                }
                if (data.example && data.example.length) {
                    if (data.example.forEach) {
                        var e = '';
                        data.example.forEach(function (v) {
                            e += self._parseCode(self.markdown(v));
                        });
                        data.example = e;
                    } else {
                        data.example = self._parseCode(self.markdown(data.example));
                    }
                    opts.meta.example = data.example;
                }
                if (data.submodules && Object.keys(data.submodules).length) {
                    opts.meta.subModules = [];
                    Y.each(Object.keys(data.submodules), function (name) {
                        var i = self.data.modules[name];
                        if (i) {
                            opts.meta.subModules.push({
                                name: i.name,
                                displayName: i.name,
                                description: i.description
                            });
                        }
                    });
                    opts.meta.subModules.sort(self.nameSort);
                }

                var view = new Y.DocView(opts.meta);
                var mainLayout = opts.layouts[layout];
                self.render('{{>module}}', view, mainLayout, opts.partials, stack.add(function (err, html) {
                    self.files++;
                    stack.html = html;
                    stack.view = view;
                }));
            });

            stack.done(function () {
                cb(stack.html, stack.view);
            });
        }
948805
def layout
      # This assumes that the container overlaps all the children.

      # Move all children if we have moved.
      @children.each.with_index do |child, index|
        child.x = padding_left + x
        child.y = padding_top + y
      end

      # Make us as wrap around the largest child.
      rect.width = (@children.map {|c| c.width }.max || 0) + padding_left + padding_right
      rect.height = (@children.map {|c| c.height }.max || 0) + padding_top + padding_bottom

      super
    end
782293
def _layout_for_domfuzz(self, path):
        
        old_dir = os.getcwd()
        os.chdir(os.path.join(path))
        try:
            os.mkdir('dist')
            link_name = os.path.join('dist', 'bin')
            if self._platform.system == 'Darwin' and self._target == 'firefox':
                ff_loc = glob.glob('*.app/Contents/MacOS/firefox')
                assert len(ff_loc) == 1
                os.symlink(os.path.join(os.pardir, os.path.dirname(ff_loc[0])),  # pylint: disable=no-member
                           link_name)
                os.symlink(os.path.join(os.pardir, os.pardir, os.pardir, 'symbols'),  # pylint: disable=no-member
                           os.path.join(os.path.dirname(ff_loc[0]), 'symbols'))
            elif self._platform.system == 'Linux':
                os.symlink(os.pardir, link_name)  # pylint: disable=no-member
            elif self._platform.system == 'Windows':
                # create a junction point at dist\bin pointing to the firefox.exe path
                junction_path.symlink(os.curdir, link_name)
        finally:
            os.chdir(old_dir)
209828
def define_layout
      super do |components|
        components << Scruffy::Components::Title.new(:title, :position => [5, 2], :size => [90, 7])
                      
        components << Scruffy::Components::Viewport.new(:one, :position => [10, 50], 
                                                        :size => VIEWPORT_SIZE, :skewY => '-25', 
                                                        &graph_block(:one))
        components << Scruffy::Components::Viewport.new(:two, :position => [30, 50], 
                                                        :size => VIEWPORT_SIZE, :skewY => '-25', 
                                                        &graph_block(:two))
        components << Scruffy::Components::Viewport.new(:three, :position => [50, 50], 
                                                        :size => VIEWPORT_SIZE, :skewY => '-25', 
                                                        &graph_block(:three))
        components << Scruffy::Components::Viewport.new(:four, :position => [70, 50], 
                                                        :size => VIEWPORT_SIZE, :skewY => '-25', 
                                                        &graph_block(:four))


        components << Scruffy::Components::Legend.new(:legend, :position => [5, 13], :size => [90, 5])
      end
    end
1066362
def format(m, formatter)
      m[:overrides].each do |o|
        label = o[:owner] + "." + o[:name]
        o[:link] = formatter.link(o[:owner], o[:name], label, m[:tagname], m[:static])
      end
    end
599205
def place_in_layouts(content, payload, info)
      output = content.dup
      layout = layouts[document.data["layout"].to_s]
      validate_layout(layout)

      used = Set.new([layout])

      # Reset the payload layout data to ensure it starts fresh for each page.
      payload["layout"] = nil

      while layout
        output = render_layout(output, layout, info)
        add_regenerator_dependencies(layout)

        next unless (layout = site.layouts[layout.data["layout"]])
        break if used.include?(layout)

        used << layout
      end
      output
    end
363407
def layout_json(self):
        """"""
        file_fqpn = os.path.join(self.app_path, 'layout.json')
        if self._layout_json is None:
            if os.path.isfile(file_fqpn):
                try:
                    with open(file_fqpn, 'r') as fh:
                        self._layout_json = json.load(fh)
                except ValueError as e:
                    self.handle_error('Failed to load "{}" file ({}).'.format(file_fqpn, e))
            else:
                self.handle_error('File "{}" could not be found.'.format(file_fqpn))
        return self._layout_json
451080
function metrics(context) {
  //x-height
  context.fillStyle = 'blue'
  context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight)

  //ascender
  context.fillStyle = 'pink'
  context.fillRect(27, -layout.height, 36, layout.ascender)

  //cap height
  context.fillStyle = 'yellow'
  context.fillRect(110, -layout.height + layout.baseline , 18, -layout.capHeight)

  //baseline
  context.fillStyle = 'orange'
  context.fillRect(140, -layout.height, 36, layout.baseline)

  //descender
  context.fillStyle = 'green'
  context.fillRect(0, 0, 30, layout.descender)

  //line height
  context.fillStyle = 'red'
  context.fillRect(0, -layout.height + layout.baseline, 52, layout.lineHeight)
  
  //bounds
  context.strokeRect(0, 0, layout.width, -layout.height)
}
802181
def wrap_with type, content, options = {} #:nodoc:
      type_tag, type_html_options = apply_html type, options
      if type_tag
        @template.content_tag type_tag, content, type_html_options
      else
        content
      end
    end
315942
protected function setupLayout()
    {
        if (is_null($this->template)) {
            abort(500, 'The layout is not set');
        }

        $this->viewExistsOrFail(
            $this->template,
            "The layout [$this->template] not found"
        );

        $this->layout = view($this->template);
    }
1089285
def do_layout(payload, layouts)
      info = { :filters => [Jekyll::Filters], :registers => { :site => site } }

      payload['pygments_prefix'] = converter.pygments_prefix
      payload['pygments_suffix'] = converter.pygments_suffix

      # render and transform content (this becomes the final content of the object)
      self.content = engine.render(payload, content, info, data)
      transform

      # output keeps track of what will finally be written
      self.output = content

      # recursively render layouts
      layout = self

      while layout = layouts[layout.data['layout']]
        payload = payload.deep_merge('content' => output, 'page' => layout.data)
        self.output = engine.render(payload, output, info, data, layout.content)
      end
    end
264136
def wrap(self, availWidth, availHeight):
        

        widths = (availWidth - self.rightColumnWidth,
                  self.rightColumnWidth)

        # makes an internal table which does all the work.
        # we draw the LAST RUN's entries!  If there are
        # none, we make some dummy data to keep the table
        # from complaining
        if len(self._lastEntries) == 0:
            _tempEntries = [(0, 'Placeholder for table of contents', 0)]
        else:
            _tempEntries = self._lastEntries

        lastMargin = 0
        tableData = []
        tableStyle = [
            ('VALIGN', (0, 0), (- 1, - 1), 'TOP'),
            ('LEFTPADDING', (0, 0), (- 1, - 1), 0),
            ('RIGHTPADDING', (0, 0), (- 1, - 1), 0),
            ('TOPPADDING', (0, 0), (- 1, - 1), 0),
            ('BOTTOMPADDING', (0, 0), (- 1, - 1), 0),
        ]
        for i, entry in enumerate(_tempEntries):
            level, text, pageNum = entry[:3]
            leftColStyle = self.levelStyles[level]
            if i:  # Not for first element
                tableStyle.append((
                    'TOPPADDING',
                    (0, i), (- 1, i),
                    max(lastMargin, leftColStyle.spaceBefore)))
                # print leftColStyle.leftIndent
            lastMargin = leftColStyle.spaceAfter
            #right col style is right aligned
            rightColStyle = ParagraphStyle(name='leftColLevel%d' % level,
                                           parent=leftColStyle,
                                           leftIndent=0,
                                           alignment=TA_RIGHT)
            leftPara = Paragraph(text, leftColStyle)
            rightPara = Paragraph(str(pageNum), rightColStyle)
            tableData.append([leftPara, rightPara])

        self._table = Table(
            tableData,
            colWidths=widths,
            style=TableStyle(tableStyle))

        self.width, self.height = self._table.wrapOn(self.canv, availWidth, availHeight)
        return self.width, self.height
836921
def to_format
      if !get? && has_errors? && !response_overridden?
        display_errors
      elsif has_view_rendering? || response_overridden?
        default_render
      else
        api_behavior
      end
    rescue ActionView::MissingTemplate
      api_behavior
    end
191734
protected function determine_layout() {
        $this->pagelayout = array();

        // Break up the layout string into pages.
        $pagelayouts = explode(',0', $this->attempt->layout);

        // Strip off any empty last page (normally there is one).
        if (end($pagelayouts) == '') {
            array_pop($pagelayouts);
        }

        // File the ids into the arrays.
        // Tracking which is the first slot in each section in this attempt is
        // trickier than you might guess, since the slots in this section
        // may be shuffled, so $section->firstslot (the lowest numbered slot in
        // the section) may not be the first one.
        $unseensections = $this->sections;
        $this->pagelayout = array();
        foreach ($pagelayouts as $page => $pagelayout) {
            $pagelayout = trim($pagelayout, ',');
            if ($pagelayout == '') {
                continue;
            }
            $this->pagelayout[$page] = explode(',', $pagelayout);
            foreach ($this->pagelayout[$page] as $slot) {
                $sectionkey = array_search($this->slots[$slot]->section, $unseensections);
                if ($sectionkey !== false) {
                    $this->slots[$slot]->firstinsection = true;
                    unset($unseensections[$sectionkey]);
                } else {
                    $this->slots[$slot]->firstinsection = false;
                }
            }
        }
    }
1310900
def _create_layout(self):
        
        waits_for_confirmation = WaitsForConfirmation(self.pymux)

        return FloatContainer(
            content=HSplit([
                # The main window.
                FloatContainer(
                    Background(),
                    floats=[
                        Float(width=lambda: self.pymux.get_window_size().columns,
                              height=lambda: self.pymux.get_window_size().rows,
                              content=DynamicBody(self.pymux))
                    ]),
                # Status bar.
                ConditionalContainer(
                    content=VSplit([
                        # Left.
                        Window(
                            height=1,
                            width=(lambda: D(max=self.pymux.status_left_length)),
                            dont_extend_width=True,
                            content=FormattedTextControl(self._get_status_left_tokens)),
                        # List of windows in the middle.
                        Window(
                            height=1,
                            char=' ',
                            align=self._get_align,
                            content=FormattedTextControl(self._get_status_tokens)),
                        # Right.
                        Window(
                            height=1,
                            width=(lambda: D(max=self.pymux.status_right_length)),
                            dont_extend_width=True,
                            align=WindowAlign.RIGHT,
                            content=FormattedTextControl(self._get_status_right_tokens))
                    ], z_index=Z_INDEX.STATUS_BAR, style='class:statusbar'),
                    filter=Condition(lambda: self.pymux.enable_status),
                )
            ]),
            floats=[
                Float(bottom=1, left=0, z_index=Z_INDEX.MESSAGE_TOOLBAR,
                      content=MessageToolbar(self.client_state)),
                Float(left=0, right=0, bottom=0, content=HSplit([
                    # Wait for confirmation toolbar.
                    ConditionalContainer(
                        content=Window(
                            height=1,
                            content=ConfirmationToolbar(self.pymux, self.client_state),
                            z_index=Z_INDEX.COMMAND_LINE,
                        ),
                        filter=waits_for_confirmation,
                    ),
                    # ':' prompt toolbar.
                    ConditionalContainer(
                        content=Window(
                            height=D(min=1),  # Can be more if the command is multiline.
                            style='class:commandline',
                            dont_extend_height=True,
                            content=BufferControl(
                                buffer=self.client_state.command_buffer,
                                preview_search=True,
                                input_processors=[
                                    AppendAutoSuggestion(),
                                    BeforeInput(':', style='class:commandline-prompt'),
                                    ShowArg(),
                                    HighlightSelectionProcessor(),
                                ]),
                            z_index=Z_INDEX.COMMAND_LINE,
                        ),
                        filter=has_focus(self.client_state.command_buffer),
                    ),
                    # Other command-prompt commands toolbar.
                    ConditionalContainer(
                        content=Window(
                            height=1,
                            style='class:commandline',
                            content=BufferControl(
                                buffer=self.client_state.prompt_buffer,
                                input_processors=[
                                    BeforeInput(self._before_prompt_command_tokens),
                                    AppendAutoSuggestion(),
                                    HighlightSelectionProcessor(),
                                ]),
                            z_index=Z_INDEX.COMMAND_LINE,
                        ),
                        filter=has_focus(self.client_state.prompt_buffer),
                    ),
                ])),
                # Keys pop-up.
                Float(
                    content=ConditionalContainer(
                        content=self.popup_dialog,
                        filter=Condition(lambda: self.client_state.display_popup),
                    ),
                    left=3, right=3, top=5, bottom=5,
                    z_index=Z_INDEX.POPUP,
                ),
                Float(xcursor=True, ycursor=True, content=CompletionsMenu(max_height=12)),
            ]
        )