diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-08-17 13:59:12 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-08-17 13:59:12 +0000 |
| commit | a4bc0d09f3d1f633a5780976d1f913e083c9564a (patch) | |
| tree | 1777475e88463b08438f0719be97cc087554eadd /sandbox/cben/make/make2rst.py | |
| parent | 60c69f8cf97125135948a3d35b7698ee80921137 (diff) | |
| parent | 2818db9a234cc37008c5f2bb0e821f9b1fa92de2 (diff) | |
| download | docutils-0.3.9.tar.gz | |
re-added docutils-0.3.9 tag one level deeper (without web/ and sandboxes/)docutils-0.3.9
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.3.9@3815 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/cben/make/make2rst.py')
| -rwxr-xr-x | sandbox/cben/make/make2rst.py | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/sandbox/cben/make/make2rst.py b/sandbox/cben/make/make2rst.py deleted file mode 100755 index 1a4498f0c..000000000 --- a/sandbox/cben/make/make2rst.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -""" -A simple tool for converting a Makefile to reStructuredText. - -Basically it strips all comments starting at column 0 that don't start with -``##`` and converts all the rest to literal blocks. The first comment line -defines the number of spaces after the comment sign to be ignored (this allows -``# text...`` which is more readable than ``#text...``). - -""" - -from __future__ import generators - -import fileinput, sys - -def convert(lines): - """Generate lines of reST from makefile lines.""" - in_literal_block = False # state - comment_spaces = None # stripped from all lines - leading_spaces = 0 # this/last line's indentation - - for line in lines: - if line.isspace(): - # Empty line accepted in both states. - if not in_literal_block: - line = '#\n' - else: - line = '\n' - if line[0] == '#' and not line[:2] == '##': - # Comment line - if in_literal_block: - yield '\n' - in_literal_block = False - - line = line.expandtabs()[1:] - leading_spaces = len(line) - len(line.lstrip(' ')) - if comment_spaces is None: - comment_spaces = leading_spaces - else: - line = line[min(leading_spaces, comment_spaces):] - - yield line - else: - # Literal line - if not in_literal_block: - yield '\n' - yield '::\n' - yield '\n' - in_literal_block = True - - yield '\t' + line - -def main(*args): - sys.stdout.writelines(convert(fileinput.input(args))) - -if __name__ == '__main__': - main(*sys.argv[1:]) |
