ID:38079
 
This is one of those BYONDscape Classics we're always going on about. Using this simple technique (and Python -- which is a free download from python.org), you can... well, I guess what I wrote back in December 2004 sums it up.

Another small and simple Python script. This one encourages you to document your code while simultaneously helping you write the instruction manual for your game! Any line containing a comment starting with "@doc" will be written to a text file. (This idea is stolen from Java.)

# purpose: search all .dm files for the string "//@doc ", strip it out
# along with all leading and trailing space, and write doc lines
# to docs.txt

# usage: put path on the command line (e.g., "./subdirectory");
# if not provided, script will assume current directory

import sys, os

try:
        pathName = sys.argv[1]
except:
        pathName = '.'

outfile = open(pathName + '/' + 'docs.txt', 'w')

for curfile in os.listdir(pathName):
        curfile = curfile.lower()
        if curfile[-3:] == '.dm':
                infile = open(pathName + '/' + curfile, 'r')
                for curline in infile.readlines():
                        if curline.find('//@doc ') > -1:
                                curline = curline.strip().replace('//@doc ', '')
                                outfile.write(curline + '\n')