58 |
mputils.__rst_init__() |
mputils.__rst_init__() |
59 |
umlrst.__rst_init__() |
umlrst.__rst_init__() |
60 |
|
|
61 |
|
|
62 |
|
# ***ugly*** |
63 |
|
import docutils.transforms.universal, docutils.nodes |
64 |
|
class FinalCheckVisitor(docutils.transforms.universal.FinalCheckVisitor): |
65 |
|
def visit_citation_reference(self, node): |
66 |
|
if node.resolved or not node.hasattr('refname'): |
67 |
|
return |
68 |
|
refname = node['refname'] |
69 |
|
id = self.document.nameids.get(refname) |
70 |
|
if id is None: |
71 |
|
# Instead of complaining when a reference is not included |
72 |
|
# (i.e., there's no '.. [gzz] bla' for a '[gzz]_'), |
73 |
|
# we insert the missing node, empty. |
74 |
|
|
75 |
|
# Note: I don't really know what I'm doing here, |
76 |
|
# just poking around and guessing which variables |
77 |
|
# contain which things... |
78 |
|
|
79 |
|
id = refname |
80 |
|
xnode = docutils.nodes.reference(refid=refname) |
81 |
|
#node += xnode |
82 |
|
self.document.ids[id] = xnode |
83 |
|
self.document.nameids[refname] = refname |
84 |
|
|
85 |
|
del node['refname'] |
86 |
|
node['refid'] = id |
87 |
|
self.document.ids[id].referenced = 1 |
88 |
|
node.resolved = 1 |
89 |
|
|
90 |
|
## msg = self.document.reporter.error( |
91 |
|
## 'Unknown target name: "%s".' % (node['refname']), |
92 |
|
## base_node=node) |
93 |
|
## msgid = self.document.set_id(msg) |
94 |
|
## prb = nodes.problematic( |
95 |
|
## node.rawsource, node.rawsource, refid=msgid) |
96 |
|
## prbid = self.document.set_id(prb) |
97 |
|
## msg.add_backref(prbid) |
98 |
|
## node.parent.replace(node, prb) |
99 |
|
##else: |
100 |
|
## del node['refname'] |
101 |
|
## node['refid'] = id |
102 |
|
## self.document.ids[id].referenced = 1 |
103 |
|
## node.resolved = 1 |
104 |
|
|
105 |
|
docutils.transforms.universal.FinalCheckVisitor = FinalCheckVisitor |
106 |
|
|
107 |
def _rstFiles(path): |
def _rstFiles(path): |
108 |
files = [f for f in os.listdir(mputils._slashify(path)) \ |
files = [f for f in os.listdir(mputils._slashify(path)) \ |
109 |
if os.path.isfile(mputils._slashify(path)+f) and not f.startswith('.') |
if os.path.isfile(mputils._slashify(path)+f) and not f.startswith('.') |