[Epydoc-commits] SF.net SVN: epydoc: [1556] trunk/epydoc/src/epydoc/docwriter/xlink.py
Brought to you by:
edloper
|
From: <ed...@us...> - 2007-02-27 05:16:43
|
Revision: 1556
http://svn.sourceforge.net/epydoc/?rev=1556&view=rev
Author: edloper
Date: 2007-02-26 21:16:41 -0800 (Mon, 26 Feb 2007)
Log Message:
-----------
- Don't fail if docutils module isn't available -- the DocUrlGenerator
class may still be useful.
Modified Paths:
--------------
trunk/epydoc/src/epydoc/docwriter/xlink.py
Modified: trunk/epydoc/src/epydoc/docwriter/xlink.py
===================================================================
--- trunk/epydoc/src/epydoc/docwriter/xlink.py 2007-02-27 04:00:10 UTC (rev 1555)
+++ trunk/epydoc/src/epydoc/docwriter/xlink.py 2007-02-27 05:16:41 UTC (rev 1556)
@@ -75,10 +75,8 @@
import re
import sys
+from optparse import OptionValueError
-from docutils.parsers.rst import roles
-from docutils import nodes, utils
-
from epydoc import log
class UrlGenerator:
@@ -353,6 +351,17 @@
"""
api_register[name].prefix = prefix
+######################################################################
+# Below this point requires docutils.
+try:
+ import docutils
+ from docutils.parsers.rst import roles
+ from docutils import nodes, utils
+ from docutils.readers.standalone import Reader
+except ImportError:
+ docutils = roles = nodes = utils = None
+ class Reader: settings_spec = ()
+
def create_api_role(name, problematic):
"""
Create and register a new role to create links for an API documentation.
@@ -362,6 +371,8 @@
"""
def resolve_api_name(n, rawtext, text, lineno, inliner,
options={}, content=[]):
+ if docutils is None:
+ raise AssertionError('requires docutils')
# node in monotype font
text = utils.unescape(text)
@@ -388,8 +399,6 @@
#{ Command line parsing
# --------------------
-#from docutils import SettingsSpec
-from optparse import OptionValueError
def split_name(value):
"""
@@ -410,7 +419,6 @@
return (name, val)
-from docutils.readers.standalone import Reader
class ApiLinkReader(Reader):
"""
@@ -438,6 +446,11 @@
{'metavar': 'NAME:STRING', 'action': 'append'}
),)) + Reader.settings_spec
+ def __init__(self, *args, **kwargs):
+ if docutils is None:
+ raise AssertionError('requires docutils')
+ Reader.__init__(self, *args, **kwargs)
+
def read(self, source, parser, settings):
self.read_configuration(settings, problematic=True)
return Reader.read(self, source, parser, settings)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|