mirror of https://github.com/kivy/kivy.git
doc: fix doc generation + pep8
This commit is contained in:
parent
80f439b03e
commit
47345370aa
|
@ -69,6 +69,7 @@ base_dir = os.path.dirname(__file__)
|
|||
dest_dir = os.path.join(base_dir, 'sources')
|
||||
examples_framework_dir = os.path.join(base_dir, '..', 'examples', 'framework')
|
||||
|
||||
|
||||
def writefile(filename, data):
|
||||
global dest_dir
|
||||
# avoid to rewrite the file if the content didn't change
|
||||
|
@ -89,8 +90,12 @@ for k in kivy.kivy_modules.list().keys():
|
|||
kivy.kivy_modules.import_module(k)
|
||||
'''
|
||||
|
||||
|
||||
# Search all kivy module
|
||||
l = [(x, sys.modules[x], os.path.basename(sys.modules[x].__file__).rsplit('.', 1)[0]) for x in sys.modules if x.startswith('kivy') and sys.modules[x]]
|
||||
l = [(x, sys.modules[x],
|
||||
os.path.basename(sys.modules[x].__file__).rsplit('.', 1)[0])
|
||||
for x in sys.modules if x.startswith('kivy') and sys.modules[x]]
|
||||
|
||||
|
||||
# Extract packages from modules
|
||||
packages = []
|
||||
|
@ -112,8 +117,7 @@ for name, module, filename in l:
|
|||
packages.sort()
|
||||
|
||||
# Create index
|
||||
api_index = \
|
||||
'''API Reference
|
||||
api_index = '''API Reference
|
||||
-------------
|
||||
|
||||
The API reference is a lexicographic list of all the different classes,
|
||||
|
@ -129,12 +133,13 @@ for package in api_modules:
|
|||
|
||||
writefile('api-index.rst', api_index)
|
||||
|
||||
# Create index for all packages
|
||||
template = \
|
||||
'''==========================================================================================================
|
||||
$SUMMARY
|
||||
==========================================================================================================
|
||||
|
||||
# Create index for all packages
|
||||
template = '\n'.join((
|
||||
'=' * 100,
|
||||
'$SUMMARY',
|
||||
'=' * 100,
|
||||
'''
|
||||
$EXAMPLES_REF
|
||||
|
||||
.. automodule:: $PACKAGE
|
||||
|
@ -144,10 +149,10 @@ $EXAMPLES_REF
|
|||
.. toctree::
|
||||
|
||||
$EXAMPLES
|
||||
'''
|
||||
'''))
|
||||
|
||||
template_examples = \
|
||||
'''.. _example-reference%d:
|
||||
|
||||
template_examples = '''.. _example-reference%d:
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
@ -155,12 +160,13 @@ Examples
|
|||
%s
|
||||
'''
|
||||
|
||||
template_examples_ref = \
|
||||
'''# :ref:`Jump directly to Examples <example-reference%d>`'''
|
||||
template_examples_ref = ('# :ref:`Jump directly to Examples'
|
||||
' <example-reference%d>`')
|
||||
|
||||
|
||||
def extract_summary_line(doc):
|
||||
if doc is None:
|
||||
return ""
|
||||
return
|
||||
for line in doc.split('\n'):
|
||||
line = line.strip()
|
||||
# don't take empty line
|
||||
|
@ -216,7 +222,8 @@ for module in m:
|
|||
example_prefix = example_prefix.replace('.', '_')
|
||||
|
||||
# try to found any example in framework directory
|
||||
list_examples = glob('%s*.py' % os.path.join(examples_framework_dir, example_prefix))
|
||||
list_examples = glob('%s*.py' % os.path.join(
|
||||
examples_framework_dir, example_prefix))
|
||||
for x in list_examples:
|
||||
# extract filename without directory
|
||||
xb = os.path.basename(x)
|
||||
|
@ -235,7 +242,8 @@ for module in m:
|
|||
t = t.replace('$PACKAGE', module)
|
||||
if len(example_output):
|
||||
refid += 1
|
||||
example_output = template_examples % (refid, '\n\n\n'.join(example_output))
|
||||
example_output = template_examples % (
|
||||
refid, '\n\n\n'.join(example_output))
|
||||
t = t.replace('$EXAMPLES_REF', template_examples_ref % refid)
|
||||
t = t.replace('$EXAMPLES', example_output)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue