Anonymous avatar Anonymous committed b8f6a0a

fixed the --prune & --ignore options of buildhtml.py

Comments (0)

Files changed (2)

docutils/docs/user/config.txt

 ```````````````````````
 
 _`ignore`
-    List of wildcard (shell globing) patterns to silently ignore.  To
-    specify multiple patterns in configuration files, use
-    colon-separated patterns; on the command line, the option may be
-    used more than once.
+    List of wildcard (shell globing) patterns, specifying files to
+    silently ignore.  To specify multiple patterns, use
+    colon-separated patterns (in configuration files or on the command
+    line); on the command line, the option may also be used more than
+    once.
 
-    Default: ['.svn', 'CVS'].  Options: ``--ignore``.
+    Default: none ([]).  Options: ``--ignore``.
 
 _`prune`
     List of directories not to process.  To specify multiple
-    directories in configuration files, use colon-separated paths; on
-    the command line, the option may be used more than once.
+    directories, use colon-separated paths (in configuration files or
+    on the command line); on the command line, the option may also be
+    used more than once.
 
-    Default: none ([]).  Options: ``--prune``.
+    Default: ['.hg', '.bzr', '.git', '.svn', 'CVS'].  Options:
+    ``--prune``.
 
 _`recurse`
     Recursively scan subdirectories, or ignore subdirectories.

docutils/tools/buildhtml.py

     Runtime settings & command-line options for the front end.
     """
 
+    prune_default = ['.hg', '.bzr', '.git', '.svn', 'CVS']
+
     # Can't be included in OptionParser below because we don't want to
     # override the base class.
     settings_spec = (
            'validator': frontend.validate_boolean}),
          ('Do not scan subdirectories for files to process.',
           ['--local'], {'dest': 'recurse', 'action': 'store_false'}),
-         ('BROKEN Do not process files in <directory>.  This option may be used '
-          'more than once to specify multiple directories.',
+         ('Do not process files in <directory> (shell globbing patterns, '
+          'separated by colons).  This option may be used '
+          'more than once to specify multiple directories.  Default: "%s".'
+          % ':'.join(prune_default),
           ['--prune'],
           {'metavar': '<directory>', 'action': 'append',
-           'validator': frontend.validate_colon_separated_string_list}),
-         ('BROKEN Recursively ignore files or directories matching any of the given '
-          'wildcard (shell globbing) patterns (separated by colons).  '
-          'Default: ".svn:CVS"',
+           'validator': frontend.validate_colon_separated_string_list,
+           'default': prune_default,}),
+         ('Recursively ignore files matching any of the given '
+          'wildcard (shell globbing) patterns (separated by colons).',
           ['--ignore'],
           {'metavar': '<patterns>', 'action': 'append',
-           'default': ['.svn', 'CVS'],
+           'default': [],
            'validator': frontend.validate_colon_separated_string_list}),
          ('Work silently (no progress messages).  Independent of "--quiet".',
           ['--silent'],
                 # influence by modifying dirs.
                 if not recurse:
                     del dirs[:]
-                self.visit(root, files)
+                self.visit(root, files, dirs)
 
-    def visit(self, directory, names):
-        # BUG prune and ignore do not work 
+    def visit(self, directory, names, subdirectories):
         settings = self.get_settings('', directory)
         errout = ErrorOutput(encoding=settings.error_encoding)
         if settings.prune and (os.path.abspath(directory) in settings.prune):
             print >>errout, ('/// ...Skipping directory (pruned): %s' %
                               directory)
             sys.stderr.flush()
-            names[:] = []
+            del subdirectories[:]
             return
         if not self.initial_settings.silent:
             print >>errout, '/// Processing directory: %s' % directory
                 if fnmatch(names[i], pattern):
                     # Modify in place!
                     del names[i]
-        prune = 0
         for name in names:
             if name.endswith('.txt'):
-                prune = self.process_txt(directory, name)
-                if prune:
-                    break
+                self.process_txt(directory, name)
 
     def process_txt(self, directory, name):
         if name.startswith('pep-'):
         settings = self.get_settings(publisher, directory)
         errout = ErrorOutput(encoding=settings.error_encoding)
         pub_struct = self.publishers[publisher]
-        if settings.prune and (directory in settings.prune):
-            return 1
         settings._source = os.path.normpath(os.path.join(directory, name))
         settings._destination = settings._source[:-4]+'.html'
         if not self.initial_settings.silent:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.