Commits

Georg Brandl committed 2106751

Allow auto-detecting "docs" as sphinx source dir.

  • Participants
  • Parent commits 9cc7e32

Comments (0)

Files changed (1)

File sphinx/setup_command.py

         self.conf_file_name = 'conf.py'
         self.builder = 'html'
 
+    def _guess_source_dir(self):
+        for guess in ('doc', 'docs'):
+            if not os.path.isdir(guess):
+                continue
+            for root, dirnames, filenames in os.walk(guess):
+                if 'conf.py' in filenames:
+                    return root
+
     def finalize_options(self):
         if self.source_dir is None:
-            if os.path.isdir('doc'):
-                for root, dirnames, filenames in os.walk('doc'):
-                    if 'conf.py' in filenames:
-                        self.source_dir = root
-                        self.announce('Using source directory %s' % root)
-                        break
+            self.source_dir = self._guess_source_dir()
+            self.announce('Using source directory %s' % self.source_dir)
         self.ensure_dirname('source_dir')
         self.source_dir = os.path.abspath(self.source_dir)