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 os
import datetime
import time
def jargonParseEntry(filename):
if not os.path.isfile(filename):
return []
@ -33,8 +34,9 @@ def jargonParseEntry(filename):
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):
@ -55,6 +57,7 @@ def jargonSubdefinitions(text):
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"))
@ -108,12 +125,15 @@ def jargonToManpage(manpageFilename, entries, version, publishername):
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"))
@ -143,7 +165,8 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
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 = ''
@ -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()