diff options
| author | Georg Brandl <georg@python.org> | 2010-02-07 23:40:40 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2010-02-07 23:40:40 +0100 |
| commit | be1f7103cb94ad4000cb495b501066b7a568b24e (patch) | |
| tree | c7d3fea9a2c0899cfd208cea5044cd91a35be738 | |
| parent | 4449fb14d18b3492a50d2cef7dd962ad5ddfa185 (diff) | |
| download | sphinx-be1f7103cb94ad4000cb495b501066b7a568b24e.tar.gz | |
Allow auto-detecting "docs" as sphinx source dir.
| -rw-r--r-- | sphinx/setup_command.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py index 1b434fa2..d569b031 100644 --- a/sphinx/setup_command.py +++ b/sphinx/setup_command.py @@ -41,14 +41,18 @@ class BuildDoc(Command): 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) |
