diff tasks/task_generate_doc.py @ 6:9ce41ef66dfa

python 3 port
author Goffi <goffi@goffi.org>
date Sat, 05 Oct 2019 01:26:51 +0200
parents 09d66acc7c73
children b5fc67c97c50
line wrap: on
line diff
--- a/tasks/task_generate_doc.py	Fri Jun 28 17:44:55 2019 +0200
+++ b/tasks/task_generate_doc.py	Sat Oct 05 01:26:51 2019 +0200
@@ -1,4 +1,4 @@
-#!/ur/bin/env python2
+#!/ur/bin/env python3
 
 import os.path
 from twisted.internet import defer
@@ -8,7 +8,7 @@
 log = getLogger(__name__)
 
 WATCH_DIRS = []
-DOC_DIRS_DEFAULT = (u'doc', u'docs')
+DOC_DIRS_DEFAULT = ('doc', 'docs')
 
 
 def prepare(self):
@@ -16,9 +16,9 @@
     doc_path = self.getConfig("doc_path")
     if doc_path is not None:
         to_watch.add(doc_path)
-    sub_docs = self.getConfig("sub_docs_dict", value_type=u"path")
+    sub_docs = self.getConfig("sub_docs_dict", value_type="path")
     if sub_docs is not None:
-        for d in sub_docs.values():
+        for d in list(sub_docs.values()):
             to_watch.add(d)
     global WATCH_DIRS
     WATCH_DIRS = list(to_watch)
@@ -29,7 +29,7 @@
     # root documentation
     doc_path = self.getConfig("doc_path")
     # sub docs will be generated before the root documentation
-    sub_docs = self.getConfig("sub_docs_dict", value_type=u"path")
+    sub_docs = self.getConfig("sub_docs_dict", value_type="path")
 
     if doc_path is None:
         # we check if there is documentation inside the site
@@ -41,21 +41,21 @@
                 break
 
     if doc_path is None and sub_docs is None:
-        log.info(u"No documentation found for {site_name}, skipping".format(
+        log.info("No documentation found for {site_name}, skipping".format(
             site_name = self.site_name))
         return
 
-    sphinx = self.findCommand('sphinx-build2', 'sphinx-build')
+    sphinx = self.findCommand('sphinx-build')
 
     # we first generate the sub documentations
-    for name, sub_doc_path in sub_docs.iteritems():
-        sub_dir = regex.pathEscape(name or u'')
-        build_path = os.path.join(self.build_path, u'doc', sub_dir)
+    for name, sub_doc_path in list(sub_docs.items()):
+        sub_dir = regex.pathEscape(name or '')
+        build_path = os.path.join(self.build_path, 'doc', sub_dir)
         yield self.runCommand(sphinx, sub_doc_path, build_path)
 
     # then the root one
     if doc_path is not None:
-        build_path = os.path.join(self.build_path, u'doc')
+        build_path = os.path.join(self.build_path, 'doc')
         yield self.runCommand(sphinx, doc_path, build_path)
 
-    log.info(_(u"documentation has been generated"))
+    log.info(_("documentation has been generated"))