diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-03-12 21:48:30 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-03-12 21:48:30 +0000 |
| commit | 75a70841eb54a3ccbccceff8a39fa7af12f71f57 (patch) | |
| tree | 16bbd07cbd1e54dabfcdc9f9bfac1c23b9ec532d | |
| parent | 2c2b5b917ffd7988d23b24a594f4e8b12f4b1ac5 (diff) | |
| download | docutils-75a70841eb54a3ccbccceff8a39fa7af12f71f57.tar.gz | |
added "ignore" setting for buildhtml
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5019 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
| -rw-r--r-- | HISTORY.txt | 5 | ||||
| -rw-r--r-- | docs/user/config.txt | 8 | ||||
| -rwxr-xr-x | tools/buildhtml.py | 17 |
3 files changed, 29 insertions, 1 deletions
diff --git a/HISTORY.txt b/HISTORY.txt index 0f9e1bb77..4ef02f607 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -149,6 +149,11 @@ Changes Since 0.4 * docs/howto/security.txt: "Deploying Docutils Securely", added to project. +* tools/buildhtml.py: + + -- Added ``ignore`` setting to exclude a list of shell patterns + (default: ``.svn:CVS``). + * tools/editors/emacs/rst.el: - Changed license to "GPL". diff --git a/docs/user/config.txt b/docs/user/config.txt index 2dc134be1..9361db1bb 100644 --- a/docs/user/config.txt +++ b/docs/user/config.txt @@ -992,6 +992,14 @@ No settings are defined for this Writer. [buildhtml application] ``````````````````````` +_`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. + + Default: ['.svn', 'CVS']. Options: ``--ignore``. + _`prune` List of directories not to process. To specify multiple directories in configuration files, use colon-separated paths; on diff --git a/tools/buildhtml.py b/tools/buildhtml.py index bf07a6b5f..e5fda8293 100755 --- a/tools/buildhtml.py +++ b/tools/buildhtml.py @@ -25,9 +25,10 @@ import sys import os import os.path import copy +from fnmatch import fnmatch import docutils from docutils import ApplicationError -from docutils import core, frontend +from docutils import core, frontend, utils from docutils.parsers import rst from docutils.readers import standalone, pep from docutils.writers import html4css1, pep_html @@ -62,6 +63,13 @@ class SettingsSpec(docutils.SettingsSpec): ['--prune'], {'metavar': '<directory>', 'action': 'append', 'validator': frontend.validate_colon_separated_string_list}), + ('Recursively ignore files or directories matching any of the given ' + 'wildcard (shell globbing) patterns (separated by colons). ' + 'Default: ".svn:CVS"', + ['--ignore'], + {'metavar': '<patterns>', 'action': 'append', + 'default': ['.svn', 'CVS'], + 'validator': frontend.validate_colon_separated_string_list}), ('Work silently (no progress messages). Independent of "--quiet".', ['--silent'], {'action': 'store_true', 'validator': frontend.validate_boolean}),)) @@ -185,6 +193,13 @@ class Builder: if not self.initial_settings.silent: print >>sys.stderr, '/// Processing directory:', directory sys.stderr.flush() + # settings.ignore grows many duplicate entries as we recurse + # if we add patterns in config files or on the command line. + for pattern in utils.uniq(settings.ignore): + for i in range(len(names) - 1, -1, -1): + if fnmatch(names[i], pattern): + # Modify in place! + del names[i] prune = 0 for name in names: if name.endswith('.txt'): |
