commit
cc3e7b8052
8747
docs/jargon-org.txt
Normal file
8747
docs/jargon-org.txt
Normal file
File diff suppressed because one or more lines are too long
BIN
docs/jargon.1.gz
Normal file
BIN
docs/jargon.1.gz
Normal file
Binary file not shown.
10236
docs/jargon.html
Normal file
10236
docs/jargon.html
Normal file
File diff suppressed because one or more lines are too long
@ -1,8 +1,9 @@
|
||||
import os
|
||||
import string
|
||||
import operator
|
||||
import os
|
||||
import datetime
|
||||
import time
|
||||
|
||||
|
||||
def jargonParseEntry(filename):
|
||||
if not os.path.isfile(filename):
|
||||
return []
|
||||
@ -18,23 +19,24 @@ def jargonParseEntry(filename):
|
||||
if len(line) > 2:
|
||||
for i in range(len(line)):
|
||||
if i == 0:
|
||||
entry.append(line[i].replace('\n','').strip())
|
||||
entry.append(line[i].replace('\n', '').strip())
|
||||
if i >= 2:
|
||||
text = text + line[i]
|
||||
text = text.replace('\n',' ')
|
||||
text = text.replace('\n', ' ')
|
||||
|
||||
# remove any gaps
|
||||
pos = text.find(' ')
|
||||
while pos != -1:
|
||||
text = text.replace(' ',' ')
|
||||
text = text.replace(' ', ' ')
|
||||
pos = text.find(' ')
|
||||
|
||||
entry.append(text.strip())
|
||||
|
||||
return entry
|
||||
|
||||
# returns the number of sub-definitions within a description
|
||||
|
||||
def jargonSubdefinitions(text):
|
||||
"""returns the number of sub-definitions within a description"""
|
||||
definitions = 0
|
||||
prevpos = 0
|
||||
for i in range(10):
|
||||
@ -51,10 +53,11 @@ def jargonSubdefinitions(text):
|
||||
|
||||
# too many definitions
|
||||
if definitions > 8:
|
||||
definitions = 0
|
||||
definitions = 0
|
||||
|
||||
return definitions
|
||||
|
||||
|
||||
def jargonGetEntries(entriesDir):
|
||||
entries = []
|
||||
for dirName, subdirList, fileList in os.walk(entriesDir):
|
||||
@ -65,16 +68,29 @@ def jargonGetEntries(entriesDir):
|
||||
entries.sort(key=operator.itemgetter(0))
|
||||
return entries
|
||||
|
||||
# saves the license details
|
||||
|
||||
def saveLicense(fp, year, publishername):
|
||||
"""saves the license details"""
|
||||
fp.write("Copyright (c) " + str(year) + " " + publishername + "\n")
|
||||
fp.write("Permission is granted to copy, distribute and/or modify this document\n")
|
||||
fp.write("under the terms of the GNU Free Documentation License, Version 1.3\n")
|
||||
fp.write("or any later version published by the Free Software Foundation;\n")
|
||||
fp.write("with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.\n")
|
||||
fp.write("A copy of the license is included in the section entitled \"GNU\n")
|
||||
fp.write("Permission is granted to copy, distribute and/or modify this "
|
||||
"document\n")
|
||||
fp.write("under the terms of the GNU Free Documentation License, Version "
|
||||
"1.3\n")
|
||||
fp.write("or any later version published by the Free Software "
|
||||
"Foundation;\n")
|
||||
fp.write("with no Invariant Sections, no Front-Cover Texts, and no "
|
||||
"Back-Cover Texts.\n")
|
||||
fp.write("A copy of the license is included in the section entitled "
|
||||
"\"GNU\n")
|
||||
fp.write("Free Documentation License\".\n\n")
|
||||
|
||||
|
||||
def saveGenerated(fp):
|
||||
"""saves the last-generated timestamp"""
|
||||
utcnow = datetime.datetime.utcnow().strftime("%A, %d %B %Y %I:%M%p UTC")
|
||||
fp.write("This file last generated " + utcnow + "\n\n")
|
||||
|
||||
|
||||
def jargonWithDefinitions(text, definitions, isHtml):
|
||||
result = ''
|
||||
prevpos = 0
|
||||
@ -97,6 +113,7 @@ def jargonWithDefinitions(text, definitions, isHtml):
|
||||
result = result + "\n\n" + "<p>" + text[prevpos:] + "</p>"
|
||||
return result
|
||||
|
||||
|
||||
def jargonToManpage(manpageFilename, entries, version, publishername):
|
||||
year = int(time.strftime("%Y"))
|
||||
|
||||
@ -106,14 +123,17 @@ def jargonToManpage(manpageFilename, entries, version, publishername):
|
||||
if os.path.isfile(manpageFilename + ".gz"):
|
||||
os.system("rm " + manpageFilename + ".gz")
|
||||
|
||||
fp = open(manpageFilename,'w')
|
||||
fp = open(manpageFilename, 'w')
|
||||
|
||||
fp.write(".TH \"The Jargon File\" 1 \"" + time.strftime("%x") + \
|
||||
fp.write(".TH \"The Jargon File\" 1 \"" + time.strftime("%x") +
|
||||
"\" \"\" \"" + version + "\"\n\n")
|
||||
|
||||
fp.write(".SH LICENSE\n\n")
|
||||
saveLicense(fp, year, publishername)
|
||||
|
||||
fp.write(".SH GENERATED\n\n")
|
||||
saveGenerated(fp)
|
||||
|
||||
for entry in entries:
|
||||
title = entry[0]
|
||||
text = entry[1]
|
||||
@ -127,7 +147,9 @@ def jargonToManpage(manpageFilename, entries, version, publishername):
|
||||
|
||||
os.system("gzip " + manpageFilename)
|
||||
print "manpage can be installed with the command:"
|
||||
print "sudo install -m 644 " + manpageFilename + ".gz /usr/local/share/man/man1"
|
||||
print("sudo install -m 644 " + manpageFilename +
|
||||
".gz /usr/local/share/man/man1")
|
||||
|
||||
|
||||
def jargonToOrgMode(orgFilename, entries, version, publishername):
|
||||
year = int(time.strftime("%Y"))
|
||||
@ -138,12 +160,13 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
|
||||
if os.path.isfile(orgFilename):
|
||||
os.system("rm " + orgFilename)
|
||||
|
||||
fp = open(orgFilename,'w')
|
||||
fp = open(orgFilename, 'w')
|
||||
|
||||
fp.write("#+TITLE: The Jargon File\n")
|
||||
fp.write("#+VERSION " + version + "\n")
|
||||
fp.write("#+OPTIONS: ^:nil\n")
|
||||
fp.write("#+STYLE: <link rel=\"stylesheet\" type=\"text/css\" href=\"index.css\" />\n\n")
|
||||
fp.write('#+STYLE: <link rel="stylesheet" type="text/css" '
|
||||
'href="index.css" />\n\n')
|
||||
|
||||
fp.write("#+BEGIN_CENTER\n")
|
||||
fp.write("*Yet more Jargon*\n")
|
||||
@ -152,6 +175,9 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
|
||||
fp.write("* License\n\n")
|
||||
saveLicense(fp, year, publishername)
|
||||
|
||||
fp.write("* Generated\n\n")
|
||||
saveGenerated(fp)
|
||||
|
||||
fp.write("* Glossary\n")
|
||||
|
||||
subsection = ''
|
||||
@ -180,7 +206,7 @@ def jargonToHTML(htmlFilename, entries, version, publishername):
|
||||
if os.path.isfile(htmlFilename):
|
||||
os.system("rm " + htmlFilename)
|
||||
|
||||
fp = open(htmlFilename,'w')
|
||||
fp = open(htmlFilename, 'w')
|
||||
|
||||
fp.write("<!DOCTYPE html>\n")
|
||||
fp.write("<html>\n")
|
||||
@ -193,6 +219,10 @@ def jargonToHTML(htmlFilename, entries, version, publishername):
|
||||
fp.write(" <p>\n")
|
||||
saveLicense(fp, year, publishername)
|
||||
fp.write(" </p>\n")
|
||||
fp.write(" <H2>Generated</H2>\n")
|
||||
fp.write(" <p>\n")
|
||||
saveGenerated(fp)
|
||||
fp.write(" </p>\n")
|
||||
fp.write(" <H2>Glossary</H2>\n")
|
||||
|
||||
subsection = ''
|
||||
@ -215,7 +245,7 @@ def jargonToHTML(htmlFilename, entries, version, publishername):
|
||||
fp.write(" " + text + "\n")
|
||||
fp.write(" </p>\n")
|
||||
|
||||
fp.write(" </body>\n");
|
||||
fp.write(" </body>\n")
|
||||
fp.write("</html>\n")
|
||||
fp.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user