27 |
|
|
28 |
__docformat__ = 'reStructuredText' |
__docformat__ = 'reStructuredText' |
29 |
|
|
|
import docutils.core |
|
30 |
import config |
import config |
31 |
|
|
32 |
|
import docutils.core |
33 |
|
|
34 |
# Because docutils' own relative path has problems with |
# Because docutils' own relative path has problems with |
35 |
# paths beginning with '../', we use our own :-) |
# paths beginning with '../', we use our own :-) |
36 |
import navidoc.utils.path |
import utils.path |
37 |
docutils.utils.relative_path = navidoc.utils.path.relative_path |
docutils.utils.relative_path = utils.path.relative_path |
38 |
|
|
39 |
def docutils_system_message(self, level, message, *children, **kwargs): |
def docutils_system_message(self, level, message, *children, **kwargs): |
40 |
""" |
""" |
69 |
self.notify_observers(msg) |
self.notify_observers(msg) |
70 |
return msg |
return msg |
71 |
docutils.utils.Reporter.system_message = docutils_system_message |
docutils.utils.Reporter.system_message = docutils_system_message |
72 |
|
|
73 |
|
class Element: |
74 |
|
""" |
75 |
|
cd The general element for all subelements. |
76 |
|
""" |
77 |
|
def __init__(self, list): |
78 |
|
self.list = list |
79 |
|
|
80 |
|
class NamedElement (Element): |
81 |
|
""" |
82 |
|
Element with name and linking features. |
83 |
|
""" |
84 |
|
def do_contents(self, list): |
85 |
|
for el in list: |
86 |
|
self.handle_contained(el) |
87 |
|
dbg("Link: "+self.link) |
88 |
|
def handle_contained(self, el): |
89 |
|
if link_types.has_key(el[0]): |
90 |
|
link = el[1:] |
91 |
|
if len(link): |
92 |
|
self.link = link_types[el[0]](link[0][0]) |
93 |
|
else: |
94 |
|
self.link = self.defaultlink(link[0][0]) |
95 |
|
else: |
96 |
|
self.list.add_sub_element(self.name, el) |
97 |
|
def defaultlink(self, link): |
98 |
|
return link.Link(link) |