diff --git a/configure.ac b/configure.ac index 01d8c6e7..c78f03ed 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,7 @@ AC_PROG_LN_S AC_PROG_MAKE_SET AM_PROG_CC_C_O PKG_PROG_PKG_CONFIG([0.20]) +AM_PATH_PYTHON([2.6],, [:]) AX_CXX_COMPILE_STDCXX_11([noext], [optional]) diff --git a/doc/Makefile.am b/doc/Makefile.am index d30095df..6a04c5d6 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -61,7 +61,7 @@ help: apiref.rst: $(top_builddir)/lib/includes/nghttp2/nghttp2ver.h \ $(top_builddir)/lib/includes/nghttp2/nghttp2.h - $(builddir)/mkapiref.py --header apiref-header.rst $^ > $@ + $(PYTHON) $(builddir)/mkapiref.py --header apiref-header.rst $^ > $@ clean: -rm apiref.rst diff --git a/doc/mkapiref.py b/doc/mkapiref.py index 3ab088d8..fc73e0b6 100755 --- a/doc/mkapiref.py +++ b/doc/mkapiref.py @@ -23,6 +23,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # Generates API reference from C source code. +from __future__ import print_function # At least python 2.6 is required import re, sys, argparse class FunctionDoc: @@ -32,10 +33,10 @@ class FunctionDoc: self.domain = domain def write(self, out): - print '''.. {}:: {}'''.format(self.domain, self.name) - print '' + print('''.. {}:: {}'''.format(self.domain, self.name)) + print('') for line in self.content: - print ' {}'.format(line) + print(' {}'.format(line)) class StructDoc: def __init__(self, name, content, members, member_domain): @@ -46,17 +47,17 @@ class StructDoc: def write(self, out): if self.name: - print '''.. type:: {}'''.format(self.name) - print '' + print('''.. type:: {}'''.format(self.name)) + print('') for line in self.content: - print ' {}'.format(line) - print '' + print(' {}'.format(line)) + print('') for name, content in self.members: - print ''' .. {}:: {}'''.format(self.member_domain, name) - print '' + print(''' .. {}:: {}'''.format(self.member_domain, name)) + print('') for line in content: - print ''' {}'''.format(line) - print '' + print(''' {}'''.format(line)) + print('') class MacroDoc: def __init__(self, name, content): @@ -64,10 +65,10 @@ class MacroDoc: self.content = content def write(self, out): - print '''.. macro:: {}'''.format(self.name) - print '' + print('''.. macro:: {}'''.format(self.name)) + print('') for line in self.content: - print ' {}'.format(line) + print(' {}'.format(line)) def make_api_ref(infiles): macros = [] @@ -99,12 +100,12 @@ def make_api_ref(infiles): for title, docs in alldocs: if not docs: continue - print title - print '-'*len(title) + print(title) + print('-'*len(title)) for doc in docs: doc.write(sys.stdout) - print '' - print '' + print('') + print('') def process_macro(infile): content = read_content(infile) @@ -204,6 +205,6 @@ if __name__ == '__main__': help='source file') args = parser.parse_args() if args.header: - print args.header.read() + print(args.header.read()) for infile in args.files: make_api_ref(args.files)