Beispiel #1
0
    def createToken(self, parent, info, page):
        if self.settings['module'] is None:
            raise exceptions.MooseDocsException("The 'module' setting is required.")

        if self.settings['object'] is None:
            raise exceptions.MooseDocsException("The 'object' setting is required.")

        master = floats.create_float(parent, self.extension, self.reader, page, self.settings,
                                     **self.attributes)
        try:
            mod = importlib.import_module(self.settings['module'])
        except ImportError:
            msg = "Unable to load the '{}' module."
            raise exceptions.MooseDocsException(msg, self.settings['module'])

        try:
            obj = getattr(mod, self.settings['object'])
        except AttributeError:
            msg = "Unable to load the '{}' attribute from the '{}' module."
            raise exceptions.MooseDocsException(msg, self.settings['object'],
                                                self.settings['module'])

        if hasattr(obj, 'defaultSettings'):
            settings = obj.defaultSettings()
        elif hasattr(obj, 'defaultConfig'):
            settings = obj.defaultConfig()
        else:
            msg = "The '{}' object in the '{}' module does not have a 'defaultSettings' or "\
                  "'defaultConfig' method."
            raise exceptions.MooseDocsException(msg, mod, obj)

        rows = [[key, value[0], value[1]] for key, value in settings.iteritems()]
        tbl = table.builder(rows, headings=[u'Key', u'Default', u'Description'])
        tbl.parent = master
        return master
Beispiel #2
0
    def createHTML(self, parent, token, page):
        rows = []
        for key, value in self.extension.getAcronyms(True).iteritems():
            rows.append([key, value])

        heading = ['Acronym', 'Description'] if token['heading'] else None
        tbl = table.builder(rows, heading)
        self.renderer.render(parent, tbl, page)
Beispiel #3
0
    def createHTML(self, parent, token, page):
        rows = []
        for key, value in self.extension.getAcronyms(True).iteritems():
            rows.append([key, value])

        heading = ['Acronym', 'Description'] if token['heading'] else None
        tbl = table.builder(rows, heading)
        self.renderer.render(parent, tbl, page)
Beispiel #4
0
    def createToken(self, match, parent):
        if self.settings['module'] is None:
            raise exceptions.TokenizeException(
                "The 'module' setting is required.")

        if self.settings['object'] is None:
            raise exceptions.TokenizeException(
                "The 'object' setting is required.")

        master = floats.Float(parent, **self.attributes)

        if self.settings['caption']:
            caption = floats.Caption(master,
                                     prefix=self.settings['prefix'],
                                     key=self.attributes['id'])
            grammar = self.reader.lexer.grammar('inline')
            self.reader.lexer.tokenize(caption, grammar,
                                       self.settings['caption'], match.line)

        try:
            mod = importlib.import_module(self.settings['module'])
        except ImportError:
            msg = "Unable to load the '{}' module."
            raise exceptions.TokenizeException(msg, self.settings['module'])

        try:
            obj = getattr(mod, self.settings['object'])
        except AttributeError:
            msg = "Unable to load the '{}' attribute from the '{}' module."
            raise exceptions.TokenizeException(msg, self.settings['object'],
                                               self.settings['module'])

        if hasattr(obj, 'defaultSettings'):
            settings = obj.defaultSettings()
        elif hasattr(obj, 'defaultConfig'):
            settings = obj.defaultConfig()
        else:
            msg = "The '{}' object in the '{}' module does not have a 'defaultSettings' or "\
                  "'defaultConfig' method."
            raise exceptions.TokenizeException(msg, mod, obj)

        rows = [[key, value[0], value[1]]
                for key, value in settings.iteritems()]
        tbl = table.builder(rows,
                            headings=[u'Key', u'Default', u'Description'])
        tbl.parent = master
        return master
Beispiel #5
0
    def createToken(self, parent, info, page):
        if self.settings['module'] is None:
            raise exceptions.MooseDocsException(
                "The 'module' setting is required.")

        if self.settings['object'] is None:
            raise exceptions.MooseDocsException(
                "The 'object' setting is required.")

        master = floats.create_float(parent,
                                     self.extension,
                                     self.reader,
                                     page,
                                     self.settings,
                                     token_type=table.TableFloat)
        try:
            mod = importlib.import_module(self.settings['module'])
        except ImportError:
            msg = "Unable to load the '{}' module."
            raise exceptions.MooseDocsException(msg, self.settings['module'])

        try:
            obj = getattr(mod, self.settings['object'])
        except AttributeError:
            msg = "Unable to load the '{}' attribute from the '{}' module."
            raise exceptions.MooseDocsException(msg, self.settings['object'],
                                                self.settings['module'])

        if hasattr(obj, 'defaultSettings'):
            settings = obj.defaultSettings()
        elif hasattr(obj, 'defaultConfig'):
            settings = obj.defaultConfig()
        else:
            msg = "The '{}' object in the '{}' module does not have a 'defaultSettings' or "\
                  "'defaultConfig' method."
            raise exceptions.MooseDocsException(msg, mod, obj)

        rows = [[key, value[0], value[1]]
                for key, value in settings.iteritems()]
        tbl = table.builder(rows,
                            headings=[u'Key', u'Default', u'Description'])
        tbl.parent = master

        if master is parent:
            tbl.attributes.update(**self.attributes)

        return parent
Beispiel #6
0
    def createToken(self, match, parent):
        if self.settings['module'] is None:
            raise exceptions.TokenizeException("The 'module' setting is required.")

        if self.settings['object'] is None:
            raise exceptions.TokenizeException("The 'object' setting is required.")

        master = floats.Float(parent, **self.attributes)

        if self.settings['caption']:
            caption = floats.Caption(master, prefix=self.settings['prefix'],
                                     key=self.attributes['id'])
            grammar = self.reader.lexer.grammar('inline')
            self.reader.lexer.tokenize(caption, grammar, self.settings['caption'], match.line)

        try:
            mod = importlib.import_module(self.settings['module'])
        except ImportError:
            msg = "Unable to load the '{}' module."
            raise exceptions.TokenizeException(msg, self.settings['module'])

        try:
            obj = getattr(mod, self.settings['object'])
        except AttributeError:
            msg = "Unable to load the '{}' attribute from the '{}' module."
            raise exceptions.TokenizeException(msg, self.settings['object'],
                                               self.settings['module'])

        if hasattr(obj, 'defaultSettings'):
            settings = obj.defaultSettings()
        elif hasattr(obj, 'defaultConfig'):
            settings = obj.defaultConfig()
        else:
            msg = "The '{}' object in the '{}' module does not have a 'defaultSettings' or "\
                  "'defaultConfig' method."
            raise exceptions.TokenizeException(msg, mod, obj)

        rows = [[key, value[0], value[1]] for key, value in settings.iteritems()]
        tbl = table.builder(rows, headings=[u'Key', u'Default', u'Description'])
        tbl.parent = master
        return master