[PATCH 5 of 5] setup: build the documentation in a subdirectory of `build_temp'

Dan Villiom Podlaski Christiansen danchr at gmail.com
Tue Nov 24 11:43:37 CST 2009


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1259083629 -3600
# Node ID a532117e55a11f2284c3b4624b281f80f982d4af
# Parent  11e718a7094daa770294708458cb3f40c0cd3fd7
setup: build the documentation in a subdirectory of `build_temp'.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -299,28 +299,34 @@ class build_doc(build):
             self.warn("could not find doc directory")
             return
 
+        # avoid cluttering the source directory by copying all documentation
+        # files to the build by-products directory
+        build_dir = join(self.build_temp, 'doc')
+        self.mkpath(build_dir)
+        self.copy_tree('doc', build_dir)
+
         # update extracted documentation
         self.execute(self.extract_documentation,
-                     [join('doc', 'hg.1.gendoc.txt')],
+                     [join(build_dir, 'hg.1.gendoc.txt')],
                      ('extracting %s from source files'
-                      % join('doc', 'hg.1.gendoc.txt')))
+                      % join(build_dir, 'hg.1.gendoc.txt')))
 
         datafiles = self.distribution.data_files
 
         stylesheet = 'style.css'
         datafiles.append((join('doc', self.distribution.get_name()),
-                          [join('doc', stylesheet)]))
+                          [join(build_dir, stylesheet)]))
 
-        for srcfile in fnmatch.filter(os.listdir('doc'),
+        for srcfile in fnmatch.filter(os.listdir(build_dir),
                                       "*.[1-9].txt"):
             base = os.path.splitext(srcfile)[0]
             name, category = base.rsplit('.', 1)
 
-            srcfile = join('doc', srcfile)
+            srcfile = join(build_dir, srcfile)
             # manual file name is e.g. XXX.N
-            manfile = join('doc', base)
+            manfile = join(build_dir, base)
             # HTML file name is e.g. XXX.html
-            htmlfile = join('doc', name + '.html')
+            htmlfile = join(build_dir, name + '.html')
 
             # reader & writer classes
             # NOTE: writers.get_writer_class('manpage') may be used eventually


More information about the Mercurial-devel mailing list