2015-03-27 19:50:56 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Sphinx Auto-API
|
|
|
|
"""
|
|
|
|
|
2015-04-01 00:01:41 +00:00
|
|
|
import fnmatch
|
2015-04-07 20:35:50 +00:00
|
|
|
import shutil
|
2015-03-27 19:50:56 +00:00
|
|
|
|
2015-04-21 05:54:32 +00:00
|
|
|
from .domains import DotNetDomain, PythonDomain
|
2015-04-01 00:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
def ignore_file(app, filename):
|
|
|
|
for pat in app.config.autoapi_ignore:
|
|
|
|
if fnmatch.fnmatch(filename, pat):
|
|
|
|
return True
|
|
|
|
return False
|
2015-03-27 19:50:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
def load_yaml(app):
|
|
|
|
if not app.config.autoapi_dir:
|
2015-04-08 05:54:53 +00:00
|
|
|
print "You must configure an autodapi_dir setting."
|
2015-03-27 19:50:56 +00:00
|
|
|
return
|
|
|
|
app.env.autoapi_data = []
|
2015-04-01 00:01:41 +00:00
|
|
|
|
|
|
|
if app.config.autoapi_type == 'dotnet':
|
2015-04-14 22:59:09 +00:00
|
|
|
domain = DotNetDomain(app)
|
2015-04-21 05:54:32 +00:00
|
|
|
elif app.config.autoapi_type == 'python':
|
|
|
|
domain = PythonDomain(app)
|
2015-04-14 22:59:09 +00:00
|
|
|
domain.full()
|
2015-03-27 19:50:56 +00:00
|
|
|
|
|
|
|
|
2015-04-07 20:35:50 +00:00
|
|
|
def build_finished(app, exception):
|
|
|
|
if not app.config.autoapi_keep_files:
|
|
|
|
if app.verbosity > 1:
|
|
|
|
print "Cleaning autoapi out"
|
|
|
|
shutil.rmtree(app.config.autoapi_root)
|
|
|
|
|
|
|
|
|
2015-03-27 19:50:56 +00:00
|
|
|
def setup(app):
|
|
|
|
app.connect('builder-inited', load_yaml)
|
2015-04-07 20:35:50 +00:00
|
|
|
app.connect('build-finished', build_finished)
|
2015-04-01 00:01:41 +00:00
|
|
|
app.add_config_value('autoapi_type', 'dotnet', 'html')
|
2015-03-27 19:50:56 +00:00
|
|
|
app.add_config_value('autoapi_root', 'autoapi', 'html')
|
2015-04-01 00:01:41 +00:00
|
|
|
app.add_config_value('autoapi_ignore', ['*migrations*'], 'html')
|
|
|
|
app.add_config_value('autoapi_dir', '', 'html')
|
2015-04-07 20:35:50 +00:00
|
|
|
app.add_config_value('autoapi_keep_files', True, 'html')
|
2015-04-21 05:54:32 +00:00
|
|
|
app.add_stylesheet('autoapi.css')
|