annotate nobuild/docutils-plantuml.patch @ 137:9a9dcae45e08

Misc support file changes
author David Bryant <bagnose@gmail.com>
date Sun, 30 Sep 2012 15:25:11 +0930
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
137
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
1 Index: docutils/parsers/rst/directives/__init__.py
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
2 ===================================================================
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
3 --- docutils/parsers/rst/directives/__init__.py (revision 7515)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
4 +++ docutils/parsers/rst/directives/__init__.py (working copy)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
5 @@ -19,6 +19,7 @@
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
6
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
7
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
8 _directive_registry = {
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
9 + 'uml': ('uml', 'Uml'),
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
10 'attention': ('admonitions', 'Attention'),
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
11 'caution': ('admonitions', 'Caution'),
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
12 'code': ('body', 'CodeBlock'),
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
13 Index: docutils/parsers/rst/directives/uml.py
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
14 ===================================================================
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
15 --- docutils/parsers/rst/directives/uml.py (revision 0)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
16 +++ docutils/parsers/rst/directives/uml.py (working copy)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
17 @@ -0,0 +1,64 @@
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
18 +# Author: mauriciocap <mauriciocap@gmail.com>
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
19 +# Copyright: inherited from docutils.sf.net
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
20 +# MCAP
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
21 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
22 +"""
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
23 +Directive to generate uml diagrams using plantuml
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
24 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
25 +Options:
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
26 + - path: prefix without extension (e.g. "images/login" will generate images/login.txt and images/login.png" ). Files will usualy be OVERWRITEN. But: if no content is specified and .txt file exists, png will be generated from this txt
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
27 +"""
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
28 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
29 +__docformat__ = 'reStructuredText'
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
30 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
31 +from docutils.parsers.rst.directives.images import Image
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
32 +from docutils.parsers.rst import directives
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
33 +from docutils._compat import b
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
34 +import os
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
35 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
36 +import sys
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
37 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
38 +class Uml(Image):
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
39 + required_arguments = 0
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
40 + optional_arguments = 1
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
41 + option_spec = Image.option_spec.copy()
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
42 + has_content = True
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
43 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
44 + def run(self):
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
45 + fname= "uml/%06d" % self.lineno #A: default
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
46 + if (len(self.arguments)>0):
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
47 + fname= self.arguments[0]
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
48 + #A: path contains the path for the txt and image without extension
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
49 + (fnameOutDir, fnameBase)= os.path.split(fname)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
50 + txtFname= fname+".txt"
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
51 + imgFname= fname+".png"
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
52 + if self.content:
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
53 + os.path.isdir(fnameOutDir) or os.mkdir(fnameOutDir)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
54 + #A: fnameOutDir exists, BUT only ONE level will be created
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
55 + fo= open(txtFname,"wb")
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
56 + fo.write(b('@startuml\n'))
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
57 + try:
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
58 + fo.write(b(self.state_machine.document.settings.plantuml_hdr+'\n'))
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
59 + except AttributeError:
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
60 + pass
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
61 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
62 + fo.write(b('\n'.join(self.content)))
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
63 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
64 + fo.write(b("\n@enduml\n"))
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
65 + fo.close()
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
66 + #A: txt file OVERWRITEN!
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
67 + if (not self.state.document.settings.file_insertion_enabled):
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
68 + warning = self.state_machine.reporter.warning(
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
69 + 'File and URL access deactivated; ignoring "%s" '
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
70 + 'directive.' % self.name, nodes.literal_block(
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
71 + self.block_text, self.block_text), line=self.lineno)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
72 + return [warning]
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
73 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
74 + plantumlCmd= "plantuml %s"
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
75 + try:
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
76 + plantumlCmd= self.state_machine.document.settings.plantuml_cmd
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
77 + except AttributeError:
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
78 + pass
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
79 + os.system(plantumlCmd % txtFname)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
80 + self.arguments= [imgFname]
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
81 + return Image.run(self)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
82 Index: docutils/parsers/rst/languages/en.py
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
83 ===================================================================
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
84 --- docutils/parsers/rst/languages/en.py (revision 7515)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
85 +++ docutils/parsers/rst/languages/en.py (working copy)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
86 @@ -51,6 +51,7 @@
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
87 #'imagemap': 'imagemap',
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
88 'image': 'image',
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
89 'figure': 'figure',
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
90 + 'uml': 'uml', #MCAP
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
91 'include': 'include',
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
92 'raw': 'raw',
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
93 'replace': 'replace',
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
94 Index: go.sh
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
95 ===================================================================
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
96 --- go.sh (revision 0)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
97 +++ go.sh (working copy)
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
98 @@ -0,0 +1,3 @@
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
99 +#!/bin/bash
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
100 +
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
101 +./setup.py build --force && ./setup.py install --prefix=${HOME}/local
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
102
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
103 Property changes on: go.sh
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
104 ___________________________________________________________________
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
105 Added: svn:executable
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
106 ## -0,0 +1 ##
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
107 +*
9a9dcae45e08 Misc support file changes
David Bryant <bagnose@gmail.com>
parents:
diff changeset
108 \ No newline at end of property