diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nobuild/docutils-plantuml.patch	Sun Sep 30 15:25:11 2012 +0930
@@ -0,0 +1,108 @@
+Index: docutils/parsers/rst/directives/__init__.py
+===================================================================
+--- docutils/parsers/rst/directives/__init__.py	(revision 7515)
++++ docutils/parsers/rst/directives/__init__.py	(working copy)
+@@ -19,6 +19,7 @@
+ 
+ 
+ _directive_registry = {
++      'uml': ('uml', 'Uml'),
+       'attention': ('admonitions', 'Attention'),
+       'caution': ('admonitions', 'Caution'),
+       'code': ('body', 'CodeBlock'),
+Index: docutils/parsers/rst/directives/uml.py
+===================================================================
+--- docutils/parsers/rst/directives/uml.py	(revision 0)
++++ docutils/parsers/rst/directives/uml.py	(working copy)
+@@ -0,0 +1,64 @@
++# Author: mauriciocap <mauriciocap@gmail.com>
++# Copyright: inherited from docutils.sf.net
++# MCAP
++
++"""
++Directive to generate uml diagrams using plantuml
++
++Options:
++  - 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
++"""
++
++__docformat__ = 'reStructuredText'
++
++from docutils.parsers.rst.directives.images import Image
++from docutils.parsers.rst import directives
++from docutils._compat import b
++import os
++
++import sys
++
++class Uml(Image):
++    required_arguments = 0
++    optional_arguments = 1
++    option_spec = Image.option_spec.copy()
++    has_content = True
++
++    def run(self):
++        fname= "uml/%06d" % self.lineno #A: default
++        if (len(self.arguments)>0):
++            fname= self.arguments[0]
++        #A: path contains the path for the txt and image without extension
++        (fnameOutDir, fnameBase)= os.path.split(fname)
++        txtFname= fname+".txt"
++        imgFname= fname+".png"
++        if self.content:
++            os.path.isdir(fnameOutDir) or os.mkdir(fnameOutDir)
++            #A: fnameOutDir exists, BUT only ONE level will be created
++            fo= open(txtFname,"wb")
++            fo.write(b('@startuml\n'))
++            try:
++                fo.write(b(self.state_machine.document.settings.plantuml_hdr+'\n'))
++            except AttributeError:
++                pass
++
++            fo.write(b('\n'.join(self.content)))
++
++            fo.write(b("\n@enduml\n"))
++            fo.close()
++            #A: txt file OVERWRITEN!
++        if (not self.state.document.settings.file_insertion_enabled):
++            warning = self.state_machine.reporter.warning(
++              'File and URL access deactivated; ignoring "%s" '
++              'directive.' % self.name, nodes.literal_block(
++                    self.block_text, self.block_text), line=self.lineno)
++            return [warning]
++
++        plantumlCmd= "plantuml %s"
++        try:
++            plantumlCmd= self.state_machine.document.settings.plantuml_cmd
++        except AttributeError:
++            pass
++        os.system(plantumlCmd % txtFname)
++        self.arguments= [imgFname]
++        return Image.run(self)
+Index: docutils/parsers/rst/languages/en.py
+===================================================================
+--- docutils/parsers/rst/languages/en.py	(revision 7515)
++++ docutils/parsers/rst/languages/en.py	(working copy)
+@@ -51,6 +51,7 @@
+       #'imagemap': 'imagemap',
+       'image': 'image',
+       'figure': 'figure',
++      'uml': 'uml', #MCAP
+       'include': 'include',
+       'raw': 'raw',
+       'replace': 'replace',
+Index: go.sh
+===================================================================
+--- go.sh	(revision 0)
++++ go.sh	(working copy)
+@@ -0,0 +1,3 @@
++#!/bin/bash
++
++./setup.py build --force && ./setup.py install --prefix=${HOME}/local
+
+Property changes on: go.sh
+___________________________________________________________________
+Added: svn:executable
+## -0,0 +1 ##
++*
+\ No newline at end of property