~ubuntu-branches/ubuntu/trusty/python-keystoneclient/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/ext/apidoc.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-27 12:08:28 UTC
  • mfrom: (1.1.26)
  • Revision ID: package-import@ubuntu.com-20140327120828-yu3vm5g1v1pkl93w
Tags: 1:0.7.1-ubuntu1
New upstream release. (LP: #1298453)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014 OpenStack Foundation
 
2
#
 
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
# not use this file except in compliance with the License. You may obtain
 
5
# a copy of the License at
 
6
#
 
7
#      http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
# Unless required by applicable law or agreed to in writing, software
 
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
# License for the specific language governing permissions and limitations
 
13
# under the License.
 
14
 
 
15
# NOTE(blk-u): Uncomment the [pbr] section in setup.cfg and remove this
 
16
# Sphinx extension when https://launchpad.net/bugs/1260495 is fixed.
 
17
 
 
18
import os.path as path
 
19
 
 
20
from sphinx import apidoc
 
21
 
 
22
 
 
23
# NOTE(blk-u): pbr will run Sphinx multiple times when it generates
 
24
# documentation. Once for each builder. To run this extension we use the
 
25
# 'builder-inited' hook that fires at the beginning of a Sphinx build.
 
26
# We use ``run_already`` to make sure apidocs are only generated once
 
27
# even if Sphinx is run multiple times.
 
28
run_already = False
 
29
 
 
30
 
 
31
def run_apidoc(app):
 
32
    global run_already
 
33
    if run_already:
 
34
        return
 
35
    run_already = True
 
36
 
 
37
    package_dir = path.abspath(path.join(app.srcdir, '..', '..',
 
38
                                         'keystoneclient'))
 
39
    source_dir = path.join(app.srcdir, 'api')
 
40
    apidoc.main(['apidoc', package_dir, '-f',
 
41
                 '-H', 'keystoneclient Modules',
 
42
                 '-o', source_dir])
 
43
 
 
44
 
 
45
def setup(app):
 
46
    app.connect('builder-inited', run_apidoc)