X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=doc%2Fmakehelp.py;fp=doc%2Fmakehelp.py;h=0a171f2cd5c1a032c31c9f48172cc8a91982d84d;hp=0000000000000000000000000000000000000000;hb=e535e2ef833a03ec84d0f002d684c07ddde893f1;hpb=6faaa79dff2fa3ceec44ef46b79e651f1bd9e0aa diff --git a/doc/makehelp.py b/doc/makehelp.py new file mode 100755 index 0000000..0a171f2 --- /dev/null +++ b/doc/makehelp.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# +# Generate an on-line help file for SST 2K from the text generated from +# the XML documentation. +# +# By Eric S. Raymond for the Super Star Trek project +import os, re, sys + +enddelim = "********\n" + +# This is the part most likely to bit-rot +beginmarker1 = "Mnemonic:" +endmarker1 = "Miscellaneous Notes" +beginmarker2 = " ABBREV" +endmarker2 = "Game History and Modifications" + +fp = open("sst-doc.txt", "r") +savetext = "" +state = 0 +while True: + line = fp.readline() + if not line: + break + if state == 0 and line.startswith(beginmarker1): + line = "%% " + line[12:].lstrip() + state = 1 + if state == 0 and line.startswith(beginmarker2): + savetext += enddelim + "%% ABBREV\n" + state = 2 + if state == 1: + if line.find(endmarker1) > -1: + state = 0 + if state == 2: + if line.find(endmarker2) > -1: + state = 0 + if state: + savetext += line + +# Remove the section titles +savetext = re.sub("\n+.*\n*Mnemonic:\\s*", "\n********\n%% ", savetext) + +# Hack Unicode non-breaking spaces into ordinary spaces +savetext = savetext.replace("\xc2\xa0", " ").replace("\240", "") + +sys.stdout.write(savetext + enddelim)