From: Guido Draheim Date: Sun, 25 Mar 2018 22:03:11 +0000 (+0200) Subject: make a better overview and index.html X-Git-Tag: v0.13.70~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5fb25774a30ffbd857163a10ebe7b341d66a6db2;p=zziplib make a better overview and index.html --- diff --git a/docs/dbk2man.py b/docs/dbk2man.py index 0327841..8a2879c 100755 --- a/docs/dbk2man.py +++ b/docs/dbk2man.py @@ -375,6 +375,7 @@ def refentry2(man, refentry, subdirectory = ".", title = ""): found = section.find("refpurpose") if found is not None: refpurpose = found.text # + overview = {} if man: written = 0 for manpage in manpages: @@ -388,19 +389,18 @@ def refentry2(man, refentry, subdirectory = ".", title = ""): manpagetext = text writefile(filename, manpagetext) written += 1 + overview[filename] = OverviewEntry(manpage, manvolnum, refpurpose) if not written: manpage = refentrytitle filename = "%s/man%s/%s.%s" % (subdirectory, manvolnum, manpage, manvolnum) writefile(filename, manpagetext) + overview[filename] = OverviewEntry(manpage, manvolnum, refpurpose) else: manpage = refentrytitle filename = "%s/%s.%s.%s" % (subdirectory, manpage, manvolnum, "html") writefile(filename, text) + overview[filename] = OverviewEntry(manpage, manvolnum, refpurpose) # - overview = {} - for manpage in manpages: - entry = OverviewEntry(manpage, manvolnum, refpurpose) - overview[filename] = entry return overview def splitname(filename): diff --git a/docs/dir2index.py b/docs/dir2index.py index bce2164..dea1c2e 100755 --- a/docs/dir2index.py +++ b/docs/dir2index.py @@ -29,23 +29,69 @@ def htm(text): text = text.replace('>', '>') text = text.replace('"', '"') return text +def splitname(filename): + base = os.path.basename(filename) + name, ext = os.path.splitext(base) + if name.endswith(".3"): name = name[:-2] + return name def parse_html(filename): tree = ET.parse(filename) return tree.getroot() +def zzip_sorted(filenames): + for name in filenames: + if "zziplib" in name: + yield name + for name in filenames: + if "zziplib" not in name: + yield name + def dir2(man, dirs, into): text = "" + "\n" + file2name = {} + file2text = {} for dirname in dirs: - text += "" + filepath = os.path.join(dirname, filename) + file2name[filename] = splitname(filename) + file2text[filename] = open(filepath).read() + # find the overview filenames and generate the pages order + overviews = [] + for filename in file2text: + if " overview" in file2text[filename]: + overviews.append(filename) + logg.warning("overviews = %s", overviews) + logg.warning("overviews = %s", [file2name[f] for f in overviews]) + file2item = {} + pages = [] + for overview in zzip_sorted(overviews): + if overview not in pages: + pages.append(overview) + for line in file2text[overview].split("\n"): + m = re.match('
  • ', line) + if m: + filename = m.group(1) + if filename not in file2item: + file2item[filename] = line + if filename not in pages: + pages.append(filename) + for filename in sorted(file2name): + if filename not in pages: + pages.append(filename) + text += "" text += "" + "\n" writefile("%s/index.html" % into, text)