Exemplo n.º 1
0
    def f(ext: str,
          data: str,
          extra_plugins_dirs: List[Path] = None,
          metadata: str = None,
          extra_config: Dict = None) -> CompileResult:
        data = dedent(data)
        (tmp_site_path / 'pages' / 'test').with_suffix(ext).write_text(
            data, encoding='utf8')

        metadata = metadata or '.. title: test'
        (tmp_site_path / 'pages' / 'test').with_suffix('.meta').write_text(
            metadata, encoding='utf8')

        config = {
            'EXTRA_PLUGINS_DIRS': map(str, extra_plugins_dirs or []),
            'PAGES': (('pages/*' + ext, 'pages', 'page.tmpl'), ),
        }
        if extra_config:
            config.update(extra_config)

        site = Nikola(**config)
        site.init_plugins()
        site.scan_posts()

        post = site.timeline[0]
        post.compile('en')
        return CompileResult(request, post)