My favorites
|
Sign in
sphinx
Python documentation generator
Project Home
Checkout
|
Browse
|
Changes
|
r7
Source path:
svn
/
trunk
/
sphinx
/
setup_command.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- coding: utf-8 -*-
"""
sphinx.setup_command
~~~~~~~~~~~~~~~~~~~~
Setuptools/distutils commands to assist the building of sphinx
documentation.
:author: Sebastian Wiesner
:contact: basti.wiesner@gmx.net
:copyright: 2008 by Sebastian Wiesner.
:license: MIT.
"""
import sys
import os
from StringIO import StringIO
from distutils.cmd import Command
from sphinx.application import Sphinx
from sphinx.util.console import darkred, nocolor
class BuildDoc(Command):
"""Distutils command to build Sphinx documentation."""
description = 'Build Sphinx documentation'
user_options = [
('fresh-env', 'E', 'discard saved environment'),
('all-files', 'a', 'build all files'),
('source-dir=', 's', 'Source directory'),
('build-dir=', None, 'Build directory'),
('builder=', 'b', 'The builder to use. Defaults to "html"'),
]
boolean_options = ['fresh-env', 'all-files']
def initialize_options(self):
self.fresh_env = self.all_files = False
self.source_dir = self.build_dir = None
self.conf_file_name = 'conf.py'
self.builder = 'html'
def finalize_options(self):
if self.source_dir is None:
if os.path.isdir('doc'):
for root, dirnames, filenames in os.walk('doc'):
if 'conf.py' in filenames:
self.source_dir = root
self.announce('Using source directory %s' % root)
break
self.ensure_dirname('source_dir')
self.source_dir = os.path.abspath(self.source_dir)
if self.build_dir is None:
build = self.get_finalized_command('build')
self.build_dir = os.path.join(build.build_base, 'sphinx')
self.mkpath(self.build_dir)
self.ensure_dirname('build_dir')
self.doctree_dir = os.path.join(self.build_dir, 'doctrees')
self.mkpath(self.doctree_dir)
self.builder_target_dir = os.path.join(self.build_dir, self.builder)
self.mkpath(self.builder_target_dir)
def run(self):
if not sys.stdout.isatty() or sys.platform == 'win32':
# Windows' poor cmd box doesn't understand ANSI sequences
nocolor()
if not self.verbose:
status_stream = StringIO()
else:
status_stream = sys.stdout
app = Sphinx(self.source_dir, self.source_dir,
self.builder_target_dir, self.doctree_dir,
self.builder, {}, status_stream,
freshenv=self.fresh_env)
try:
if self.all_files:
app.builder.build_all()
else:
app.builder.build_update()
except Exception, err:
from docutils.utils import SystemMessage
if isinstance(err, SystemMessage):
sys.stderr, darkred('reST markup error:')
print >>sys.stderr, err.args[0].encode('ascii', 'backslashreplace')
else:
raise
Show details
Hide details
Change log
r7
by ArcRiley on Sep 29, 2008
Diff
Manual svn copy from svn.pysoy.org
Go to:
/
/trunk
/trunk/AUTHORS
/trunk/CHANGES
/trunk/EXAMPLES
/trunk/LICENSE
/trunk/Makefile
/trunk/README
/trunk/TODO
/trunk/babel.cfg
/trunk/doc
/trunk/doc/Makefile
/trunk/doc/_build
/trunk/doc/_static
/trunk/doc/_static/sphinx.png
/trunk/doc/_templates
/trunk/doc/_templates/index.html
...doc/_templates/indexsidebar.html
/trunk/doc/_templates/layout.html
/trunk/doc/builders.rst
/trunk/doc/changes.rst
/trunk/doc/concepts.rst
/trunk/doc/conf.py
/trunk/doc/config.rst
/trunk/doc/contents.rst
/trunk/doc/examples.rst
/trunk/doc/ext
/trunk/doc/ext/appapi.rst
/trunk/doc/ext/autodoc.rst
/trunk/doc/ext/builderapi.rst
/trunk/doc/ext/coverage.rst
/trunk/doc/ext/doctest.rst
/trunk/doc/ext/ifconfig.rst
/trunk/doc/ext/intersphinx.rst
/trunk/doc/ext/math.rst
/trunk/doc/ext/refcounting.rst
/trunk/doc/extensions.rst
/trunk/doc/glossary.rst
/trunk/doc/intro.rst
/trunk/doc/markup
/trunk/doc/markup/code.rst
/trunk/doc/markup/desc.rst
/trunk/doc/markup/index.rst
/trunk/doc/markup/misc.rst
/trunk/doc/markup/para.rst
/trunk/doc/rest.rst
/trunk/doc/templating.rst
/trunk/ez_setup.py
/trunk/setup.cfg
/trunk/setup.py
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 3076 bytes, 89 lines
View raw file
Hosted by