Merge pull request #5 from hugovk/gh-pages

Generate docs
This commit is contained in:
Bob Mottram 2017-02-11 22:52:04 +00:00 committed by GitHub
commit cc3e7b8052
4 changed files with 19033 additions and 20 deletions

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

Binary file not shown.

10236
docs/jargon.html Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,9 @@
import os
import string
import operator import operator
import os
import datetime
import time import time
def jargonParseEntry(filename): def jargonParseEntry(filename):
if not os.path.isfile(filename): if not os.path.isfile(filename):
return [] return []
@ -18,23 +19,24 @@ def jargonParseEntry(filename):
if len(line) > 2: if len(line) > 2:
for i in range(len(line)): for i in range(len(line)):
if i == 0: if i == 0:
entry.append(line[i].replace('\n','').strip()) entry.append(line[i].replace('\n', '').strip())
if i >= 2: if i >= 2:
text = text + line[i] text = text + line[i]
text = text.replace('\n',' ') text = text.replace('\n', ' ')
# remove any gaps # remove any gaps
pos = text.find(' ') pos = text.find(' ')
while pos != -1: while pos != -1:
text = text.replace(' ',' ') text = text.replace(' ', ' ')
pos = text.find(' ') pos = text.find(' ')
entry.append(text.strip()) entry.append(text.strip())
return entry return entry
# returns the number of sub-definitions within a description
def jargonSubdefinitions(text): def jargonSubdefinitions(text):
"""returns the number of sub-definitions within a description"""
definitions = 0 definitions = 0
prevpos = 0 prevpos = 0
for i in range(10): for i in range(10):
@ -51,10 +53,11 @@ def jargonSubdefinitions(text):
# too many definitions # too many definitions
if definitions > 8: if definitions > 8:
definitions = 0 definitions = 0
return definitions return definitions
def jargonGetEntries(entriesDir): def jargonGetEntries(entriesDir):
entries = [] entries = []
for dirName, subdirList, fileList in os.walk(entriesDir): for dirName, subdirList, fileList in os.walk(entriesDir):
@ -65,16 +68,29 @@ def jargonGetEntries(entriesDir):
entries.sort(key=operator.itemgetter(0)) entries.sort(key=operator.itemgetter(0))
return entries return entries
# saves the license details
def saveLicense(fp, year, publishername): def saveLicense(fp, year, publishername):
"""saves the license details"""
fp.write("Copyright (c) " + str(year) + " " + publishername + "\n") fp.write("Copyright (c) " + str(year) + " " + publishername + "\n")
fp.write("Permission is granted to copy, distribute and/or modify this document\n") fp.write("Permission is granted to copy, distribute and/or modify this "
fp.write("under the terms of the GNU Free Documentation License, Version 1.3\n") "document\n")
fp.write("or any later version published by the Free Software Foundation;\n") fp.write("under the terms of the GNU Free Documentation License, Version "
fp.write("with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.\n") "1.3\n")
fp.write("A copy of the license is included in the section entitled \"GNU\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") 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): def jargonWithDefinitions(text, definitions, isHtml):
result = '' result = ''
prevpos = 0 prevpos = 0
@ -97,6 +113,7 @@ def jargonWithDefinitions(text, definitions, isHtml):
result = result + "\n\n" + "<p>" + text[prevpos:] + "</p>" result = result + "\n\n" + "<p>" + text[prevpos:] + "</p>"
return result return result
def jargonToManpage(manpageFilename, entries, version, publishername): def jargonToManpage(manpageFilename, entries, version, publishername):
year = int(time.strftime("%Y")) year = int(time.strftime("%Y"))
@ -106,14 +123,17 @@ def jargonToManpage(manpageFilename, entries, version, publishername):
if os.path.isfile(manpageFilename + ".gz"): if os.path.isfile(manpageFilename + ".gz"):
os.system("rm " + 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") "\" \"\" \"" + version + "\"\n\n")
fp.write(".SH LICENSE\n\n") fp.write(".SH LICENSE\n\n")
saveLicense(fp, year, publishername) saveLicense(fp, year, publishername)
fp.write(".SH GENERATED\n\n")
saveGenerated(fp)
for entry in entries: for entry in entries:
title = entry[0] title = entry[0]
text = entry[1] text = entry[1]
@ -127,7 +147,9 @@ def jargonToManpage(manpageFilename, entries, version, publishername):
os.system("gzip " + manpageFilename) os.system("gzip " + manpageFilename)
print "manpage can be installed with the command:" 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): def jargonToOrgMode(orgFilename, entries, version, publishername):
year = int(time.strftime("%Y")) year = int(time.strftime("%Y"))
@ -138,12 +160,13 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
if os.path.isfile(orgFilename): if os.path.isfile(orgFilename):
os.system("rm " + orgFilename) os.system("rm " + orgFilename)
fp = open(orgFilename,'w') fp = open(orgFilename, 'w')
fp.write("#+TITLE: The Jargon File\n") fp.write("#+TITLE: The Jargon File\n")
fp.write("#+VERSION " + version + "\n") fp.write("#+VERSION " + version + "\n")
fp.write("#+OPTIONS: ^:nil\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("#+BEGIN_CENTER\n")
fp.write("*Yet more Jargon*\n") fp.write("*Yet more Jargon*\n")
@ -152,6 +175,9 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
fp.write("* License\n\n") fp.write("* License\n\n")
saveLicense(fp, year, publishername) saveLicense(fp, year, publishername)
fp.write("* Generated\n\n")
saveGenerated(fp)
fp.write("* Glossary\n") fp.write("* Glossary\n")
subsection = '' subsection = ''
@ -180,7 +206,7 @@ def jargonToHTML(htmlFilename, entries, version, publishername):
if os.path.isfile(htmlFilename): if os.path.isfile(htmlFilename):
os.system("rm " + htmlFilename) os.system("rm " + htmlFilename)
fp = open(htmlFilename,'w') fp = open(htmlFilename, 'w')
fp.write("<!DOCTYPE html>\n") fp.write("<!DOCTYPE html>\n")
fp.write("<html>\n") fp.write("<html>\n")
@ -193,6 +219,10 @@ def jargonToHTML(htmlFilename, entries, version, publishername):
fp.write(" <p>\n") fp.write(" <p>\n")
saveLicense(fp, year, publishername) saveLicense(fp, year, publishername)
fp.write(" </p>\n") 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") fp.write(" <H2>Glossary</H2>\n")
subsection = '' subsection = ''
@ -215,7 +245,7 @@ def jargonToHTML(htmlFilename, entries, version, publishername):
fp.write(" " + text + "\n") fp.write(" " + text + "\n")
fp.write(" </p>\n") fp.write(" </p>\n")
fp.write(" </body>\n"); fp.write(" </body>\n")
fp.write("</html>\n") fp.write("</html>\n")
fp.close() fp.close()