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

Dan Villiom Podlaski Christiansen danchr at gmail.com
Thu Nov 26 13:48:07 CST 2009


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

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -322,28 +322,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')
 
             mandestdir = join('$install_man', 'man' + category)
             htmldestdir = '$install_doc'


More information about the Mercurial-devel mailing list