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