Repository: getnikola/nikola

Issue:
doit==0.36.0 not compatible with Nikola<8.2.1
1. doit.cmd_auto was removed
2. Doit internals (TaskLoader) changed:

```
Traceback (most recent call last):
  File "C:\Users\Kwpolska\virtualenvs\nikola\Scripts\nikola-script.py", line 33, in <module>
    sys.exit(load_entry_point('Nikola', 'console_scripts', 'nikola')())
  File "c:\users\kwpolska\git\nikola\nikola\__main__.py", line 166, in main
    _ = DN.run(oargs)
  File "c:\users\kwpolska\git\nikola\nikola\__main__.py", line 376, in run
    return super().run(cmd_args)
  File "c:\users\kwpolska\virtualenvs\nikola\lib\site-packages\doit\doit_cmd.py", line 266, in run
    [CmdOption(opt) for opt in task_loader.cmd_options])
AttributeError: 'NikolaTaskLoader' object has no attribute 'cmd_options'
```


Discussion:

Resolving patch:
diff --git a/nikola/__main__.py b/nikola/__main__.py
--- a/nikola/__main__.py
+++ b/nikola/__main__.py
@@ -36,8 +36,7 @@
 from collections import defaultdict
 
 from blinker import signal
-from doit.cmd_auto import Auto as DoitAuto
-from doit.cmd_base import TaskLoader, _wrap
+from doit.cmd_base import TaskLoader2, _wrap
 from doit.cmd_clean import Clean as DoitClean
 from doit.cmd_completion import TabCompletion
 from doit.cmd_help import Help as DoitHelp
@@ -247,31 +246,41 @@ def clean_tasks(self, tasks, dryrun, *a):
 
 # Nikola has its own "auto" commands that uses livereload.
 # Expose original doit "auto" command as "doit_auto".
-DoitAuto.name = 'doit_auto'
+# doit_auto is not available with doit>=0.36.0.
+try:
+    from doit.cmd_auto import Auto as DoitAuto
+    DoitAuto.name = 'doit_auto'
+except ImportError:
+    DoitAuto = None
 
 
-class NikolaTaskLoader(TaskLoader):
+class NikolaTaskLoader(TaskLoader2):
     """Nikola-specific task loader."""
 
     def __init__(self, nikola, quiet=False):
         """Initialize the loader."""
+        super().__init__()
         self.nikola = nikola
         self.quiet = quiet
 
-    def load_tasks(self, cmd, opt_values, pos_args):
-        """Load Nikola tasks."""
+    def load_doit_config(self):
+        """Load doit configuration."""
         if self.quiet:
-            DOIT_CONFIG = {
+            doit_config = {
                 'verbosity': 0,
                 'reporter': 'zero',
             }
         else:
-            DOIT_CONFIG = {
+            doit_config = {
                 'reporter': ExecutedOnlyReporter,
                 'outfile': sys.stderr,
             }
-        DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render']
-        DOIT_CONFIG.update(self.nikola._doit_config)
+        doit_config['default_tasks'] = ['render_site', 'post_render']
+        doit_config.update(self.nikola._doit_config)
+        return doit_config
+
+    def load_tasks(self, cmd, pos_args):
+        """Load Nikola tasks."""
         try:
             tasks = generate_tasks(
                 'render_site',
@@ -286,15 +295,17 @@ def load_tasks(self, cmd, opt_values, pos_args):
                 raise
             _print_exception()
             sys.exit(3)
-        return tasks + latetasks, DOIT_CONFIG
+        return tasks + latetasks
 
 
 class DoitNikola(DoitMain):
     """Nikola-specific implementation of DoitMain."""
 
     # overwite help command
-    DOIT_CMDS = list(DoitMain.DOIT_CMDS) + [Help, Build, Clean, DoitAuto]
+    DOIT_CMDS = list(DoitMain.DOIT_CMDS) + [Help, Build, Clean]
     TASK_LOADER = NikolaTaskLoader
+    if DoitAuto is not None:
+        DOIT_CMDS.append(DoitAuto)
 
     def __init__(self, nikola, quiet=False):
         """Initialzie DoitNikola."""


Test patch: