Exemplo n.º 1
0
    def _get_meta(self, page_):
        with io.open(page_.file.abs_src_path,
                     'r',
                     encoding='utf-8-sig',
                     errors='strict') as f:
            source = f.read()

        _, page_.meta = mkdocs_meta.get_data(source)
Exemplo n.º 2
0
def build_page(title, path, config, md_src=''):
    """ Helper which returns a Page object. """

    files = Files([File(path, config['docs_dir'], config['site_dir'], config['use_directory_urls'])])
    page = Page(title, list(files)[0], config)
    # Fake page.read_source()
    page.markdown, page.meta = meta.get_data(md_src)
    return page, files
Exemplo n.º 3
0
 def get_meta_data(self, path):
     with open(path, 'r') as f:
         _, mdata = meta.get_data(f.read())
         if mdata.get('date_published', None) is None:
             raise Exception(
                 'File {} is missing field `date_published`'.format(path))
         return mdata
     return {}
Exemplo n.º 4
0
def build_page(title, path, config, md_src=''):
    """ Helper which returns a Page object. """

    files = Files([File(path, config['docs_dir'], config['site_dir'], config['use_directory_urls'])])
    page = Page(title, list(files)[0], config)
    # Fake page.read_source()
    page.markdown, page.meta = meta.get_data(md_src)
    return page, files
Exemplo n.º 5
0
def build_page(title, path, config, md_src=None):
    """ Helper which returns a Page object. """

    sitenav = nav.SiteNavigation(config)
    page = nav.Page(title, path, sitenav.url_context, config)
    if md_src:
        # Fake page.read_source()
        page.markdown, page.meta = meta.get_data(md_src)
    return page, sitenav
Exemplo n.º 6
0
def build_page(title, path, config, md_src=None):
    """ Helper which returns a Page object. """

    sitenav = nav.SiteNavigation(config)
    page = nav.Page(title, path, sitenav.url_context, config)
    if md_src:
        # Fake page.read_source()
        page.markdown, page.meta = meta.get_data(md_src)
    return page, sitenav
Exemplo n.º 7
0
    def read_source(self, config):
        source = config['plugins'].run_event(
            'page_read_source', None, config=config, page=self)
        if source is None:
            try:
                with io.open(self.abs_input_path, 'r', encoding='utf-8-sig') as f:
                    source = f.read()
            except IOError:
                log.error('File not found: %s', self.abs_input_path)
                raise

        self.markdown, self.meta = meta.get_data(source)
Exemplo n.º 8
0
    def read_source(self, config):
        source = config['plugins'].run_event('page_read_source',
                                             None,
                                             config=config,
                                             page=self)
        if source is None:
            try:
                with io.open(self.abs_input_path, 'r', encoding='utf-8') as f:
                    source = f.read()
            except IOError:
                log.error('File not found: %s', self.abs_input_path)
                raise

        self.markdown, self.meta = meta.get_data(source)
Exemplo n.º 9
0
    def read_source(self, config):
        source = config['plugins'].run_event('page_read_source', None, config=config, page=self)
        if source is None:
            try:
                with io.open(self.file.abs_src_path, 'r', encoding='utf-8-sig', errors='strict') as f:
                    source = f.read()
            except IOError:
                log.error('File not found: {}'.format(self.file.src_path))
                raise
            except ValueError:
                log.error('Encoding error reading file: {}'.format(self.file.src_path))
                raise

        self.markdown, self.meta = meta.get_data(source)
        self._set_title()
Exemplo n.º 10
0
    def read_source(self, config):
        source = config['plugins'].run_event(
            'page_read_source', page=self, config=config
        )
        if source is None:
            try:
                with io.open(self.file.abs_src_path, 'r', encoding='utf-8-sig', errors='strict') as f:
                    source = f.read()
            except IOError:
                log.error('File not found: {}'.format(self.file.src_path))
                raise
            except ValueError:
                log.error('Encoding error reading file: {}'.format(self.file.src_path))
                raise

        self.markdown, self.meta = meta.get_data(source)
        self._set_title()
Exemplo n.º 11
0
    def on_files(self, files: Files, config: Config):
        new_files = []

        for source_file in files:
            if not source_file.src_path.endswith(".md"):
                continue

            filename = Path(config["docs_dir"]) / Path(source_file.src_path)
            with filename.open() as f:
                _, metadata = get_data(f.read())

                if "uuid" not in metadata or metadata.get("type") != "intake":
                    continue

                dialect_uuid = metadata["uuid"]

                self._redirection_table[dialect_uuid] = source_file.url
                self._integrations.append(
                    {
                        "uuid": dialect_uuid,
                        "name": metadata.get("name"),
                        "destination": source_file.url,
                    }
                )

                newfile = File(
                    path=f"operation_center/integration_catalog/uuid/{dialect_uuid}.md",
                    src_dir="operation_center/integration_catalog/uuid",
                    dest_dir=config["site_dir"],
                    use_directory_urls=True,
                )
                new_files.append(newfile)

        new_files.append(File(
            path=f"operation_center/integration_catalog/index.md",
            src_dir="operation_center/integration_catalog/",
            dest_dir=config["site_dir"],
            use_directory_urls=True,
        ))
        files._files += new_files