You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sphinx-autoapi/autoapi/extension.py

52 lines
1.3 KiB
Python

10 years ago
# -*- coding: utf-8 -*-
"""
Sphinx Auto-API
"""
import os
import fnmatch
10 years ago
import shutil
10 years ago
from collections import defaultdict
import traceback
10 years ago
10 years ago
from .settings import env
from .domains import *
def ignore_file(app, filename):
for pat in app.config.autoapi_ignore:
if fnmatch.fnmatch(filename, pat):
return True
return False
10 years ago
def load_yaml(app):
if not app.config.autoapi_dir:
print "You must configure an autodapi_dir setting."
10 years ago
return
app.env.autoapi_data = []
namespaces = defaultdict(list)
if app.config.autoapi_type == 'dotnet':
domain = DotNetDomain(app)
#elif app.config.autoapi_type == 'python':
# domain = PythonDomain
domain.full()
10 years ago
10 years ago
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)
10 years ago
def setup(app):
app.connect('builder-inited', load_yaml)
10 years ago
app.connect('build-finished', build_finished)
app.add_config_value('autoapi_type', 'dotnet', 'html')
10 years ago
app.add_config_value('autoapi_root', 'autoapi', 'html')
app.add_config_value('autoapi_ignore', ['*migrations*'], 'html')
app.add_config_value('autoapi_dir', '', 'html')
10 years ago
app.add_config_value('autoapi_keep_files', True, 'html')