예제 #1
0
파일: listing.py 프로젝트: aashiquear/moose
 def extractContent(self, filename):
     """
     Extract content to display in listing code box.
     """
     content = common.read(filename)
     content, _ = common.extractContent(content, self.settings)
     return content
예제 #2
0
def extractContent(filename, opts=dict()):
    """Helper for reading contents of a file in order to make assertions."""
    settings = common.get_settings_as_dict(common.extractContentSettings())
    settings.update(opts)
    content, _ = common.extractContent(common.read(MOOSE_DIR + '/' + filename),
                                       settings)
    return content
예제 #3
0
 def extractContent(self, filename):
     """
     Extract content to display in listing code box.
     """
     content = common.read(filename)
     content, _ = common.extractContent(content, self.settings)
     return content
예제 #4
0
    def extractContent(self, filename):
        """Extract the file contents for display."""
        content = common.read(filename)
        if self.settings['block']:
            content = self.extractInputBlocks(content, self.settings['block'])

        content, _ = common.extractContent(content, self.settings)
        return content
예제 #5
0
파일: listing.py 프로젝트: aashiquear/moose
    def extractContent(self, filename):
        """Extract the file contents for display."""
        content = common.read(filename)
        if self.settings['block']:
            content = self.extractInputBlocks(content, self.settings['block'])

        content, _ = common.extractContent(content, self.settings)
        return content
예제 #6
0
 def createToken(self, parent, info, page):
     """
     Tokenize the included content and create dependency between pages.
     """
     include_page = self.translator.findPage(info['subcommand'])
     content, line = common.extractContent(self.reader.read(include_page), self.settings)
     self.reader.tokenize(parent, content, include_page, line=line)
     self.extension.addDependency(include_page)
     return parent
예제 #7
0
 def createToken(self, parent, info, page):
     """
     Tokenize the included content and create dependency between pages.
     """
     include_page = self.translator.findPage(info['subcommand'])
     content, line = common.extractContent(self.reader.read(include_page),
                                           self.settings)
     self.reader.tokenize(parent, content, include_page, line=line)
     self.extension.addDependency(include_page)
     return parent
예제 #8
0
    def createToken(self, parent, info, page):
        """
        Build the tokens needed for displaying code listing.
        """

        filename = common.check_filenames(info['subcommand'])
        flt = floats.create_float(parent,
                                  self.extension,
                                  self.reader,
                                  page,
                                  self.settings,
                                  token_type=Listing)
        # Create code token
        lang = self.settings.get('language')
        content = self.extractContent(filename)
        lang = lang if lang else common.get_language(filename)

        code = core.Code(flt,
                         style="max-height:{};".format(
                             self.settings['max-height']),
                         content=content,
                         language=lang)
        if flt is parent:
            code.attributes.update(**self.attributes)

        if flt is not parent:
            code.name = 'ListingCode'

        # Add bottom modal
        link = self.settings['link']
        link = link if link is not None else self.extension['modal-link']
        if link:
            rel_filename = os.path.relpath(filename, MooseDocs.ROOT_DIR)

            # Get the complete file
            content = common.read(filename)
            settings = common.get_settings_as_dict(
                common.extractContentSettings())
            settings['strip-header'] = False
            content, _ = common.extractContent(content, settings)

            # Create modal for display the files a popup
            code = core.Code(None, language=lang, content=content)
            link = floats.create_modal_link(
                flt,
                url=unicode(rel_filename),
                content=code,
                title=unicode(filename),
                string=u'({})'.format(rel_filename))
            link.name = 'ListingLink'
            link['data-tooltip'] = unicode(rel_filename)

        return parent
예제 #9
0
파일: listing.py 프로젝트: jwpeterson/moose
    def createToken(self, parent, info, page):
        """
        Build the tokens needed for displaying code listing.
        """

        filename = common.check_filenames(info['subcommand'])
        flt = floats.create_float(parent, self.extension, self.reader, page, self.settings,
                                  token_type=Listing)
        # Create code token
        lang = self.settings.get('language')
        content = self.extractContent(filename)
        lang = lang if lang else common.get_language(filename)

        code = core.Code(flt, style="max-height:{};".format(self.settings['max-height']),
                         content=content, language=lang)
        if flt is parent:
            code.attributes.update(**self.attributes)

        if flt is not parent:
            code.name = 'ListingCode'

        # Add bottom modal
        link = self.settings['link']
        link = link if link is not None else self.extension['modal-link']
        if link:
            rel_filename = os.path.relpath(filename, MooseDocs.ROOT_DIR)

            # Get the complete file
            content = common.read(filename)
            settings = common.get_settings_as_dict(common.extractContentSettings())
            settings['strip-header'] = False
            content, _ = common.extractContent(content, settings)

            # Create modal for display the files a popup
            code = core.Code(None, language=lang, content=content)
            link = floats.create_modal_link(flt,
                                            url=unicode(rel_filename),
                                            content=code,
                                            title=unicode(filename),
                                            string=u'({})'.format(rel_filename))
            link.name = 'ListingLink'
            link['data-tooltip'] = unicode(rel_filename)

        return parent