diff options
author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
---|---|---|
committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
commit | d77fdfef70e08114f57cbef5d91707df8717ea9f (patch) | |
tree | 49444e3486c0c333cb7b33dfa721296c08ee4ece /sandbox/cben/make/make2rst.py | |
parent | 53cd16ca6ca5f638cbe5956988e88f9339e355cf (diff) | |
parent | 3993c4097756e9885bcfbd07cb1cc1e4e95e50e4 (diff) | |
download | docutils-0.4.tar.gz |
Release 0.4: tagging released revisiondocutils-0.4
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.4@4268 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:]) |