Merge branch 'pep-394' of https://github.com/wasamasa/aria2 into wasamasa-pep-394

pull/251/merge
Tatsuhiro Tsujikawa 2015-06-05 00:19:22 +09:00
commit 79cdca5f5b
1 changed files with 24 additions and 23 deletions

View File

@ -32,6 +32,7 @@
# files in the program, then also delete it here. # files in the program, then also delete it here.
# #
# Generates API reference from C++ source code. # Generates API reference from C++ source code.
from __future__ import print_function
import re, sys, argparse import re, sys, argparse
class FunctionDoc: class FunctionDoc:
@ -41,10 +42,10 @@ class FunctionDoc:
self.domain = domain self.domain = domain
def write(self, out): def write(self, out):
print '''.. {}:: {}'''.format(self.domain, self.name) print('''.. {}:: {}'''.format(self.domain, self.name))
print '' print()
for line in self.content: for line in self.content:
print ' {}'.format(line) print(' {}'.format(line))
class TypedefDoc: class TypedefDoc:
def __init__(self, name, content): def __init__(self, name, content):
@ -52,10 +53,10 @@ class TypedefDoc:
self.content = content self.content = content
def write(self, out): def write(self, out):
print '''.. type:: {}'''.format(self.name) print('''.. type:: {}'''.format(self.name))
print '' print()
for line in self.content: for line in self.content:
print ' {}'.format(line) print(' {}'.format(line))
class StructDoc: class StructDoc:
def __init__(self, name, content, domain, members, member_domain): def __init__(self, name, content, domain, members, member_domain):
@ -67,19 +68,19 @@ class StructDoc:
def write(self, out): def write(self, out):
if self.name: if self.name:
print '''.. {}:: {}'''.format(self.domain, self.name) print('''.. {}:: {}'''.format(self.domain, self.name))
print '' print()
for line in self.content: for line in self.content:
print ' {}'.format(line) print(' {}'.format(line))
print '' print()
for name, content in self.members: for name, content in self.members:
print ''' .. {}:: {}'''.format(\ print(''' .. {}:: {}'''.format(\
'function' if name.endswith(')') else self.member_domain, 'function' if name.endswith(')') else self.member_domain,
name) name))
print '' print()
for line in content: for line in content:
print ''' {}'''.format(line) print(''' {}'''.format(line))
print '' print()
class MacroDoc: class MacroDoc:
def __init__(self, name, content): def __init__(self, name, content):
@ -87,10 +88,10 @@ class MacroDoc:
self.content = content self.content = content
def write(self, out): def write(self, out):
print '''.. macro:: {}'''.format(self.name) print('''.. macro:: {}'''.format(self.name))
print '' print()
for line in self.content: for line in self.content:
print ' {}'.format(line) print(' {}'.format(line))
def make_api_ref(infiles): def make_api_ref(infiles):
macros = [] macros = []
@ -124,12 +125,12 @@ def make_api_ref(infiles):
for title, docs in alldocs: for title, docs in alldocs:
if not docs: if not docs:
continue continue
print title print(title)
print '-'*len(title) print('-'*len(title))
for doc in docs: for doc in docs:
doc.write(sys.stdout) doc.write(sys.stdout)
print '' print()
print '' print()
def process_macro(infile): def process_macro(infile):
content = read_content(infile) content = read_content(infile)
@ -263,6 +264,6 @@ if __name__ == '__main__':
help='source file') help='source file')
args = parser.parse_args() args = parser.parse_args()
if args.header: if args.header:
print args.header.read() print(args.header.read())
for infile in args.files: for infile in args.files:
make_api_ref(args.files) make_api_ref(args.files)