aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/command_build.py
blob: cface15502f06ff8a1d744a3856e94d22e9fdcfd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import tempfile

from nikola.plugin_categories import Command


class CommandBuild(Command):
    """Build the site."""

    name = "build"

    def run(self, *args):
        """Build the site using doit."""

        # FIXME: this is crap, do it right
        with tempfile.NamedTemporaryFile(suffix='.py', delete=False) as dodo:
            dodo.write('''
from doit.reporter import ExecutedOnlyReporter
DOIT_CONFIG = {
        'reporter': ExecutedOnlyReporter,
        'default_tasks': ['render_site'],
}
from nikola import Nikola
import conf
SITE = Nikola(**conf.__dict__)


def task_render_site():
    return SITE.gen_tasks()
            ''')
            dodo.flush()
            os.system('doit -f %s -d . %s' % (dodo.name, ' '.join(args)))