Merge pull request #1981 from kwoot/fix-html-help-pages-doctool
Fix html help pages doctool
This commit is contained in:
commit
928e83a301
3 changed files with 26 additions and 25 deletions
|
|
@ -114,7 +114,7 @@ Fedora
|
||||||
|
|
||||||
* Install requirements::
|
* Install requirements::
|
||||||
|
|
||||||
# yum install git maven java-1.8.0-openjdk-devel postgresql postgresql-server python-docutils make gettext gnu-free-fonts-compat
|
# yum install git maven java-1.8.0-openjdk-devel postgresql postgresql-server python3-docutils make gettext gnu-free-fonts-compat
|
||||||
|
|
||||||
.. WARNING:: Use the following command in Fedora 16 or below::
|
.. WARNING:: Use the following command in Fedora 16 or below::
|
||||||
|
|
||||||
|
|
@ -437,11 +437,11 @@ Debian/Ubuntu
|
||||||
|
|
||||||
* Install requirements if generating HTML::
|
* Install requirements if generating HTML::
|
||||||
|
|
||||||
# apt-get install make python-docutils
|
# apt-get install make python3-docutils
|
||||||
|
|
||||||
* Install requirements if generating PDF::
|
* Install requirements if generating PDF::
|
||||||
|
|
||||||
# apt-get install make python-docutils texlive-latex-base texlive-latex-recommended texlive-latex-extra textlive-fonts-recommended
|
# apt-get install make python3-docutils texlive-latex-base texlive-latex-recommended texlive-latex-extra textlive-fonts-recommended
|
||||||
|
|
||||||
* Go to the directory where the documentation you want to generate is.
|
* Go to the directory where the documentation you want to generate is.
|
||||||
For example, if you want to generate the user manual in English::
|
For example, if you want to generate the user manual in English::
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Cost management
|
Cost management
|
||||||
###############
|
################
|
||||||
|
|
||||||
.. _costes:
|
.. _costes:
|
||||||
.. contents::
|
.. contents::
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
import sys, shlex, subprocess
|
import sys, shlex, subprocess
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
from docutils.writers import latex2e
|
from docutils.writers import latex2e
|
||||||
import re
|
import re
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import locale
|
import locale
|
||||||
|
|
@ -78,7 +79,7 @@ class DupRefsRemover(object):
|
||||||
|
|
||||||
def handle_line(self, line):
|
def handle_line(self, line):
|
||||||
if line.startswith(".. _") and ":" in line:
|
if line.startswith(".. _") and ":" in line:
|
||||||
r = map(lambda x: x.strip(), line[4:].split(":", 1))
|
r = [x.strip() for x in line[4:].split(":", 1)]
|
||||||
if r[0] in self.ref:
|
if r[0] in self.ref:
|
||||||
# Do some sanity check
|
# Do some sanity check
|
||||||
if self.ref[r[0]] != r[1]:
|
if self.ref[r[0]] != r[1]:
|
||||||
|
|
@ -291,14 +292,14 @@ class DocTool(object):
|
||||||
opts, args = optparser(OPT.docinfo).parse_args(list(args))
|
opts, args = optparser(OPT.docinfo).parse_args(list(args))
|
||||||
|
|
||||||
if opts.docinfo:
|
if opts.docinfo:
|
||||||
f = file(opts.docinfo, "rU")
|
f = open(opts.docinfo, "r")
|
||||||
e = ShellEscapeRunner(sys.stdout)
|
e = ShellEscapeRunner(sys.stdout)
|
||||||
map(e.handle_line, f.readlines())
|
list(map(e.handle_line, f.readlines()))
|
||||||
f.close()
|
f.close()
|
||||||
print
|
print()
|
||||||
|
|
||||||
print ".. contents::"
|
print(".. contents::")
|
||||||
print
|
print()
|
||||||
|
|
||||||
out = DupRefsRemover(sys.stdout)
|
out = DupRefsRemover(sys.stdout)
|
||||||
out_xlate = UnderlineXlate(out)
|
out_xlate = UnderlineXlate(out)
|
||||||
|
|
@ -310,47 +311,47 @@ class DocTool(object):
|
||||||
if not name.endswith(".rst"):
|
if not name.endswith(".rst"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
f = file(name, "rU")
|
f = open(name, "r")
|
||||||
map(is_index_filename(name) and out.handle_line or out_xlate.handle_line,
|
list(map(is_index_filename(name) and out.handle_line or out_xlate.handle_line,
|
||||||
filter(lambda l: ".. contents::" not in l,
|
[l for l in f.readlines() if ".. contents::" not in l]
|
||||||
f.readlines())
|
))
|
||||||
)
|
|
||||||
f.close()
|
f.close()
|
||||||
print
|
print()
|
||||||
|
|
||||||
|
|
||||||
def cmd_htmlindex(self, cmd, *args):
|
def cmd_htmlindex(self, cmd, *args):
|
||||||
opts, args = optparser(OPT.docinfo).parse_args(list(args))
|
opts, args = optparser(OPT.docinfo).parse_args(list(args))
|
||||||
|
|
||||||
if opts.docinfo:
|
if opts.docinfo:
|
||||||
f = file(opts.docinfo, "rU")
|
f = open(opts.docinfo, "r")
|
||||||
e = ShellEscapeRunner(sys.stdout)
|
e = ShellEscapeRunner(sys.stdout)
|
||||||
map(e.handle_line, f.readlines())
|
list(map(e.handle_line, f.readlines()))
|
||||||
f.close()
|
f.close()
|
||||||
print
|
print()
|
||||||
|
|
||||||
args = list(args)
|
args = list(args)
|
||||||
args.sort(str_tuple_sort)
|
#args.sort(key=str_tuple_sort)
|
||||||
|
args.sort()
|
||||||
|
|
||||||
for name in args:
|
for name in args:
|
||||||
# Skip non-RST inputs
|
# Skip non-RST inputs
|
||||||
if not name.endswith(".rst") or not is_index_filename(name):
|
if not name.endswith(".rst") or not is_index_filename(name):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
f = file(name, "rU")
|
f = open(name, "r")
|
||||||
line = f.readline().strip()
|
line = f.readline().strip()
|
||||||
f.close()
|
f.close()
|
||||||
print "#. `%s <%s.html>`__" % (line, name[:-4])
|
print("#. `%s <%s.html>`__" % (line, name[:-4]))
|
||||||
|
|
||||||
|
|
||||||
def cmd_help(self, cmd, *args):
|
def cmd_help(self, cmd, *args):
|
||||||
if args:
|
if args:
|
||||||
self.main([args[0], args[0], "--help"])
|
self.main([args[0], args[0], "--help"])
|
||||||
else:
|
else:
|
||||||
print "Available commands:"
|
print("Available commands:")
|
||||||
for k in dir(self):
|
for k in dir(self):
|
||||||
if k.startswith("cmd_"):
|
if k.startswith("cmd_"):
|
||||||
print " ", k[4:].replace("_", "-")
|
print(" ", k[4:].replace("_", "-"))
|
||||||
|
|
||||||
cmd_commands = cmd_help
|
cmd_commands = cmd_help
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue