示例#1
0
 def __init__(self, property_data, traverser, config, level=0):
     super(HtmlGenerator, self).__init__(property_data, traverser, config,
                                         level)
     self.separators = {'inline': ', ', 'linebreak': '<br>'}
     self.formatter = HtmlUtils()
     self.table_of_contents = ''
     self.css_content = """
示例#2
0
    def __init__(self, property_data, traverser, config, level=0):
        """
        property_data: pre-processed schemas.
        traverser: SchemaTraverser object
        config: configuration dict
        """
        super(PropertyIndexGenerator, self).__init__(property_data, traverser, config, level)
        self.collapse_list_of_simple_type = False

        # If there's a file to write config to, check it now.
        self.write_config_fh = False
        if config.get('write_config_to'):
            try:
                config_out = open(config['write_config_to'], 'w', encoding="utf8")
                self.write_config_fh = config_out
            except (OSError) as ex:
                warnings.warn('Unable to open %(filename)s to write: %(message)s', {'fileanme': config['write_config_to'], 'message': str(ex)})

        self.properties_by_name = {}
        self.coalesced_properties = {}
        # Shorthand for the overrides.
        self.overrides = config.get('description_overrides', {})

        # Force some config here:
        self.config['omit_version_in_headers'] = True # This puts just the schema name in the section head.
        self.config['wants_common_objects'] = True

        # get the formatter, so we can use the appropriate markup.
        output_format = self.config.get('output_format', 'slate')
        if output_format == 'html':
            from format_utils import HtmlUtils
            self.formatter = HtmlUtils()
        else:  # CSV also uses the markdown formatter.
            from format_utils import FormatUtils
            self.formatter = FormatUtils()
示例#3
0
 def __init__(self, property_data, traverser, config, level=0):
     super(HtmlGenerator, self).__init__(property_data, traverser, config, level)
     self.separators = {
         'inline': ', ',
         'linebreak': '<br>',
         'pattern': '\n\n' # This separator is applied prior to applying markdown_to_html
         }
     self.formatter = HtmlUtils()
     self.table_of_contents = ''
     self.css_content = """
    def __init__(self, property_data, traverser, config, level=0):
        """
        property_data: pre-processed schemas.
        traverser: SchemaTraverser object
        config: configuration dict
        """
        # parse the property index config data
        config_data = config['property_index_config']

        excluded_props = config_data.get('ExcludedProperties', [])
        config['excluded_properties'].extend(
            [x for x in excluded_props if not x.startswith('*')])
        config['excluded_by_match'].extend(
            [x[1:] for x in excluded_props if x.startswith('*')])

        super(PropertyIndexGenerator, self).__init__(property_data, traverser,
                                                     config, level)
        self.collapse_list_of_simple_type = False

        # If there's a file to write config to, check it now.
        self.write_config_fh = False
        if config.get('write_config_to'):
            try:
                config_out = open(config['write_config_to'],
                                  'w',
                                  encoding="utf8")
                self.write_config_fh = config_out
            except (OSError) as ex:
                warnings.warn('Unable to open ' + config['write_config_to'] +
                              ' to write: ' + str(ex))

        self.properties_by_name = {}
        self.coalesced_properties = {}
        # Shorthand for the overrides.
        self.overrides = config_data.get('DescriptionOverrides', {})

        # Force some config here:
        self.config[
            'omit_version_in_headers'] = True  # This puts just the schema name in the section head.
        self.config['wants_common_objects'] = True

        # get the formatter, so we can use the appropriate markup.
        output_format = self.config.get('output_format', 'markdown')
        if output_format == 'html':
            from format_utils import HtmlUtils
            self.formatter = HtmlUtils()
        else:  # CSV also uses the markdown formatter.
            from format_utils import FormatUtils
            self.formatter = FormatUtils()
    def emit(self):
        """ Return the data! """
        self.coalesce_properties()
        output_format = self.config.get('output_format', 'markdown')
        output = ''
        if output_format == 'html':
            from format_utils import HtmlUtils
            formatter = HtmlUtils()
            output = formatter.head_one("Property Index", 0)
            output += self.format_tabular_output(formatter)
            output = self.add_html_boilerplate(output)

        if output_format == 'markdown':
            from format_utils import FormatUtils
            formatter = FormatUtils()
            output = formatter.head_one("Property Index", 0)
            output += self.format_tabular_output(formatter)

        if output_format == 'csv':
            output = self.output_csv()

        return output
示例#6
0
    def emit(self):
        """ Return the data! """
        self.coalesce_properties()
        output_format = self.config.get('output_format', 'markdown')
        output = ''
        frontmatter = backmatter = ''
        if 'property_index_boilerplate' in self.config:
            boilerplate = self.config['property_index_boilerplate']
            frontmatter, backmatter = boilerplate.split('[insert property index]')
        if output_format == 'html':
            from format_utils import HtmlUtils
            formatter = HtmlUtils()
            if frontmatter:
                output = formatter.markdown_to_html(frontmatter)
            else:
                output = formatter.head_one("Property Index", 0)
            output += self.format_tabular_output(formatter)
            output += formatter.markdown_to_html(backmatter)
            toc = self.generate_toc(output)
            if '[add_toc]' in output:
                output = output.replace('[add_toc]', toc, 1)

            output = self.add_html_boilerplate(output)

        if output_format == 'markdown':
            from format_utils import FormatUtils
            formatter = FormatUtils()
            if frontmatter:
                output = frontmatter
            else:
                output = formatter.head_one("Property Index", 0)
            output += self.format_tabular_output(formatter)
            output += backmatter

        if output_format == 'csv':
            output = self.output_csv()

        return output