createdoc.py
branchdevel
changeset 281 76572d14bd27
parent 277 f65edc0382cc
child 294 0e75bd39767d
equal deleted inserted replaced
280:c96d569a8ac8 281:76572d14bd27
    10 import re
    10 import re
    11 import os.path
    11 import os.path
    12 import inspect
    12 import inspect
    13 from pkg_resources import parse_version
    13 from pkg_resources import parse_version
    14 
    14 
    15 from docutils.core import publish_doctree
    15 from docutils.core import publish_doctree, publish_from_doctree, publish_string
    16 import docutils
    16 from docutils.utils import new_document
    17 
       
    18 #--
       
    19 from docutils import core
       
    20 from docutils.writers.html4css1 import Writer,HTMLTranslator
    17 from docutils.writers.html4css1 import Writer,HTMLTranslator
    21 
    18 
    22 from iro.view.xmlrpc import TwistedInterface as Current 
    19 from iro.view.xmlrpc import TwistedInterface as Current 
    23 from iro import __version__
    20 from iro import __version__
    24 from createerm import createSchemaPlot, tables, tables_cls
    21 from createerm import createSchemaPlot, tables, tables_cls
    25 
    22 
       
    23 #redering text with rest syntax
    26 class NoHeaderHTMLTranslator(HTMLTranslator):
    24 class NoHeaderHTMLTranslator(HTMLTranslator):
    27     def __init__(self, document):
    25     def __init__(self, document):
    28         HTMLTranslator.__init__(self,document)
    26         HTMLTranslator.__init__(self,document)
    29         self.body_prefix = []
    27         self.body_prefix = []
    30         self.body_suffix = []
    28         self.body_suffix = []
    38     return "%(html_body)s"%subs
    36     return "%(html_body)s"%subs
    39 
    37 
    40 _w.apply_template = d
    38 _w.apply_template = d
    41 
    39 
    42 def reSTify(s):
    40 def reSTify(s):
    43     d =docutils.utils.new_document("")
    41     d = new_document("")
    44     if s.tagname == "paragraph":
    42     if s.tagname == "paragraph":
    45         d.append(s[0])
    43         d.append(s[0])
    46     else:
    44     else:
    47         d.append(s)
    45         d.append(s)
    48 
    46 
    49     return core.publish_from_doctree(d, writer=_w)
    47     return publish_from_doctree(d, writer=_w)
       
    48 
       
    49 
    50 
    50 
    51 
    51 
    52 class Link():
    52 class Link():
    53     def __init__(self,name,title):
    53     def __init__(self,name,title):
    54         self.name=name
    54         self.name=name
    62             return self.getLink()
    62             return self.getLink()
    63         return AttributeError(name)
    63         return AttributeError(name)
    64 
    64 
    65 class Site(Link):
    65 class Site(Link):
    66     pass
    66     pass
       
    67 
    67 
    68 
    68 class Keyword():
    69 class Keyword():
    69     def __init__(self, name=None, typ=None, description=None):
    70     def __init__(self, name=None, typ=None, description=None):
    70         self.name=name
    71         self.name=name
    71         self.typ=typ
    72         self.typ=typ
   172         name=cls.__name__
   173         name=cls.__name__
   173         self.tablename=cls.__tablename__
   174         self.tablename=cls.__tablename__
   174         title=self.tablename[0].upper()+self.tablename[1:]
   175         title=self.tablename[0].upper()+self.tablename[1:]
   175         Link.__init__(self,name,title)
   176         Link.__init__(self,name,title)
   176         
   177         
   177         self.description = Markup(core.publish_string(cls.__doc__,writer=_w))
   178         self.description = Markup(publish_string(cls.__doc__,writer=_w))
   178 
   179 
   179 class File:
   180 class File:
   180     def __init__(self,path):
   181     def __init__(self,path):
   181         self.version = re.search("/iro-(.*).tar.gz",path).group(1)
   182         self.version = re.search("/iro-(.*).tar.gz",path).group(1)
   182         self.name = os.path.basename(path)
   183         self.name = os.path.basename(path)