Subdefinitions in manpages
This commit is contained in:
parent
076b03c903
commit
6f1ddbd381
@ -25,6 +25,27 @@ def jargonParseEntry(filename):
|
|||||||
|
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
# returns the number of sub-definitions within a description
|
||||||
|
def jargonSubdefinitions(text):
|
||||||
|
definitions = 0
|
||||||
|
for i in range(10):
|
||||||
|
definitionStr = str(i+1) + ". "
|
||||||
|
if text.find(definitionStr) == -1:
|
||||||
|
break
|
||||||
|
definitions = definitions + 1
|
||||||
|
|
||||||
|
if definitions == 0:
|
||||||
|
definitions = 1
|
||||||
|
|
||||||
|
# too many definitions
|
||||||
|
if definitions > 5:
|
||||||
|
definitions = 0
|
||||||
|
|
||||||
|
# if definitions > 1:
|
||||||
|
# definitions = definitions - 1
|
||||||
|
|
||||||
|
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):
|
||||||
@ -35,6 +56,18 @@ def jargonGetEntries(entriesDir):
|
|||||||
entries.sort(key=operator.itemgetter(0))
|
entries.sort(key=operator.itemgetter(0))
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
def jargonManpageWithDefinitions(text, definitions):
|
||||||
|
result = ''
|
||||||
|
prevpos = 0
|
||||||
|
for i in range(definitions):
|
||||||
|
pos = text.find(str(i+1) + ". ")
|
||||||
|
if pos > -1 and i > 0:
|
||||||
|
if result != '':
|
||||||
|
result = result + "\n\n"
|
||||||
|
result = result + text[prevpos:pos]
|
||||||
|
prevpos = pos
|
||||||
|
return result + "\n\n" + text[prevpos:]
|
||||||
|
|
||||||
def jargonToManpage(manpageFilename, entries, version):
|
def jargonToManpage(manpageFilename, entries, version):
|
||||||
if not os.path.isdir("man"):
|
if not os.path.isdir("man"):
|
||||||
os.system("mkdir man")
|
os.system("mkdir man")
|
||||||
@ -49,6 +82,10 @@ def jargonToManpage(manpageFilename, entries, version):
|
|||||||
for entry in entries:
|
for entry in entries:
|
||||||
title = entry[0]
|
title = entry[0]
|
||||||
text = entry[1]
|
text = entry[1]
|
||||||
|
definitions = jargonSubdefinitions(entry[1])
|
||||||
|
if definitions > 1:
|
||||||
|
text = jargonManpageWithDefinitions(text, definitions)
|
||||||
|
|
||||||
fp.write(".SH " + title + "\n")
|
fp.write(".SH " + title + "\n")
|
||||||
fp.write(text + "\n\n")
|
fp.write(text + "\n\n")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user